Pie-Chart Problem

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
reji

Pie-Chart Problem

Post by reji » Tue Jul 09, 2002 3:17 am

I am trying to plot a Pie-Chart with following code

Swing component initialization time
--------------------------------------------

JFreeChart afTbsChart = ChartFactory.createPieChart(null, null, true);

Event dispatching time
--------------------------------------------

CategoryDataset tbsData = new DefaultCategoryDataset(apd.bbTbsSeries, apd.getPieDataSet(1));

//apd.bbTbsSeries returns String[] Series names
//apd.getPieDataSet(1) returns Number[][]

tbsPieData = DatasetUtilities.createPieDataset(tbsData, "Category 1");
((PiePlot)afTbsChart.getPlot()).setDataset(tbsPieData);
((PiePlot)afTbsChart.getPlot()).setSectionLabelType(PiePlot.PERCENT_LABELS);
-------------------------------------------------------

I am getting chart plotted with 'PERCENT_LABELS' preceded by '-' character and following error.

I am using jfreechart-0.9.2
JDK 1.3 /Win2000


Exception occurred during event dispatching:
java.lang.NullPointerException
at com.jrefinery.chart.PiePlot.getLegendItemLabels(Unknown Source)
at com.jrefinery.chart.StandardLegend.draw(Unknown Source)
at com.jrefinery.chart.StandardLegend.draw(Unknown Source)
at com.jrefinery.chart.JFreeChart.draw(Unknown Source)
at com.jrefinery.chart.ChartPanel.paintComponent(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintWithBuffer(Unknown Source)
at javax.swing.JComponent._paintImmediately(Unknown Source)
at javax.swing.JComponent.paintImmediately(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unkno
n Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

What is the problem? I was using the same code with previous version (0.8.1), without any problems.

Thanking You,

Reji

reji

Re: Pie-Chart Problem

Post by reji » Thu Jul 11, 2002 2:55 am

Hi,

Anybody Please help me.. I found another clue about the previous problem. If I create Pie-Chart with PieDataset, then it is not giving any error. It gives only while creating Pie-Chart with null PieDataset and setting dataset at event dispatching time..

www.rejimani.com

Ray Mercer

Re: Pie-Chart Problem

Post by Ray Mercer » Tue Jul 16, 2002 1:25 am

There is a post right after the 0.9.2 release about this problem. It is a known bug introduced by adding the "direction" feature. I went into the source and added the fix detailed in that post and it fixed the problem.

Note* you will also have to find the post about the missing gorrilla.jpg to figure out how to get rid of that error (basically, you need to add gorrilla.jpg to the jar after you recompile 0.9.2 from source).

HTH,
Ray

Locked