views:

346

answers:

2

Is it possible to draw a 3D chart using JfreeChart like in the following link.If possible can anyone give some hints and some snippets of code on what parameters of Plot can be used to do this.

link text

A: 

I little birdie told me that you can find a .pdf of the JFreeChart documentation on a popular BitTorrent tracker.

Ted Dziuba
I have that file but the problem its more of a documentation stuff which does not tell much how it can be used...
Harish
+1  A: 

It's possible though it won't look exactly the same. The easiest way is to create a dataset (descendant of org.jfree.data.general.PieDataset) and use one of org.jfree.chart.ChartFactory methods:

PieDataset data = new DefaultPieDataset();
data.setValue("Section1", 30);
data.setValue("Section2", 60);
data.setValue("Section3", 120);
JFreeChart pieChart = ChartFactory.createPieChart3D(
 "My Pie Chart", // title
 data,           // data set
 true,           // draw a legend
 true,           // show tooltips over sections
 false);         // do not generate image map with URLs

You can then further customize your chart through pieChart methods. For example, here's how to explode one pie section:

 PiePlot plot = (PiePlot) pieChart.getPlot();
 plot.setExplodePercent("Section2", 0.25);
ChssPly76
cool thanks...Can you suggest good color codes and ofcourse not colors..My bad I have a poor sense for colors
Harish
Sorry, I'm not sure what you mean by "color codes and not colors"? As picking colors goes I'm no designer :-) but you can search SO for "chart colors" - there are quite a few questions / answers. I'd go with predefined palette rather than trying random stuff, though. Good luck with your project.
ChssPly76