In this section we are providing you an example to create a Polar Chart.
Description of Program
For creating a Polar Chart we use the object of XYDataset. Before creating the object of XYDataset we have to create the objects of XYSeries for representing the data. We add the data in this series by add() method. And then we add this series to XYSeriesCollection by addSeries() method. XYSeriesCollection object represent the collection of XYSeries objects, which is used as a dataset.
Description of code
Firstly we have to create the object of XYSeries that is used to represent the data items.
XYSeries s1=new XYSeries("a");
And then we add the data in the series by add() method.
After creating the data series we have to create the object of XYSeriesCollection object that is used to represent the collection of XYSeries objects, which is used as a dataset.
JFreeChart chart = ChartFactory.createPolarChart("Polar Chart", dataset, true, true, false);
After added the data in dataset we create the Polar Chart by invoking the createPolarChart() method. This method is a static method of ChartFactory class and its returns the object of JFreeChart type. This method syntax is:
Public static JFreeChart createPolarChart(java.lang.String title, XYDataset dataset, boolean legend, boolean tooltips, boolean urls);
ChartFrame frame1=new ChartFrame(?Polar Chart",chart);
After this we create the object of ChartFrame. It is used to display a chart.
Here is a code of the Program :
Output of the Program :
We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.
Posted on: April 13, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles