0.9.5 Exception with Pie Legend

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

0.9.5 Exception with Pie Legend

Post by Don Mitchell » Thu Feb 06, 2003 11:16 pm

Hi,

I just downloaded 0.9.5 and updated my code to the new API. I can't get a legend to work with Pie chart created using ChartFactory.createPieChart() if I set:

legend.setDisplaySeriesShapes(true)

I'm using a CategoryDataset. It looks pie plots don't support this in the legend. The exception is below.

Also, the tooltip and url for each pie slice (when I have multiple pies) only shows the pie slice's category and value. I would also like it to show the series value since there are multiple pies on the screen. Is this possible? Do I have to write it myself?

Thanks,
Don


java.lang.NullPointerException

at sun.java2d.pipe.DuctusShapeRenderer.renderPath(DuctusShapeRenderer.java:53)

at sun.java2d.pipe.DuctusShapeRenderer.fill(DuctusShapeRenderer.java:49)

at sun.java2d.SunGraphics2D.fill(SunGraphics2D.java:2210)

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.JFreeChart.createBufferedImage(Unknown Source)

at com.jrefinery.chart.ChartUtilities.writeChartAsPNG(Unknown Source)

at com.jrefinery.chart.ChartUtilities.writeChartAsPNG(Unknown Source)

David Gilbert

Re: 0.9.5 Exception with Pie Legend

Post by David Gilbert » Fri Feb 07, 2003 1:09 pm

Hi Don,

Thanks for the report. That's a bug which I will fix for 0.9.6. But the only fix I can think of is to ignore the 'display-shapes' flag...because there aren't really any shapes for a pie chart. What were you expecting to see? Maybe it could display a small wedge at the same orientation as the slice in the chart...

Regards,

Dave Gilbert

Don Mitchell

Re: 0.9.5 Exception with Pie Legend

Post by Don Mitchell » Fri Feb 07, 2003 5:11 pm

Dave,

I wasn't expecting to see anything, but my code is generic and lets the user switch between chart types. I was blindly setting that flag in a common part of the code. I've since moved that logic so it won't apply to pie charts.

So ignoring the flag would work fine.

Don

Locked