Hi All I am developing a java application. In this application i need to show a radar grap.when some body assigne rating then each rating should show on x y z axis. please suggest me some good way to do this task. Thanks Yogi
Hi Friend,
Try the following code:
import java.awt.*; import org.jfree.ui.*; import org.jfree.chart.*; import org.jfree.chart.plot.*; import org.jfree.chart.labels.*; import org.jfree.chart.title.*; import org.jfree.data.category.*; public class RadarChart extends ApplicationFrame { public DefaultCategoryDataset dataset; public SpiderWebPlot plot; public RadarChart(String title) { super(title); String series1 = "First"; String series2 = "Second"; String series3 = "Third"; String category1 = "Category 1"; String category2 = "Category 2"; String category3 = "Category 3"; String category4 = "Category 4"; String category5 = "Category 5"; DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(1.0, series1, category1); dataset.addValue(4.0, series1, category2); dataset.addValue(3.0, series1, category3); dataset.addValue(5.0, series1, category4); dataset.addValue(5.0, series1, category5); dataset.addValue(5.0, series2, category1); dataset.addValue(7.0, series2, category2); dataset.addValue(6.0, series2, category3); dataset.addValue(8.0, series2, category4); dataset.addValue(4.0, series2, category5); dataset.addValue(4.0, series3, category1); dataset.addValue(3.0, series3, category2); dataset.addValue(2.0, series3, category3); dataset.addValue(3.0, series3, category4); dataset.addValue(6.0, series3, category5); SpiderWebPlot plot = new SpiderWebPlot(dataset); plot.setStartAngle(54); plot.setInteriorGap(0.40); plot.setToolTipGenerator(new StandardCategoryToolTipGenerator()); JFreeChart chart = new JFreeChart("", TextTitle.DEFAULT_FONT, plot, false); ChartUtilities.applyCurrentTheme(chart); ChartPanel chartPanel = new ChartPanel(chart); this.plot = (SpiderWebPlot) chartPanel.getChart().getPlot(); this.dataset = (DefaultCategoryDataset) plot.getDataset(); chartPanel.setPreferredSize(new Dimension(500, 270)); setContentPane(chartPanel); } public static void main(String[] args) { RadarChart demo = new RadarChart("Chart"); demo.pack(); RefineryUtilities.centerFrameOnScreen(demo); demo.setVisible(true); } }
Here we have used jfreechart api.
Thanks
Ads