I created a simple pie chart based on the demo pie chart and the slice labels show up as negative, like : "Groceries (-4.5%)". I also want to customize those labels to include other information. Does anyone have a chunk of sample source that does something like this?
Thanks!
negate percentages in pie chart
Re: negate percentages in pie chart
Hi Jon,
The negative percentages bug was introduced (by me) in 0.9.2 and has been fixed in CVS. I've been a little busy lately, but should get 0.9.3 released before the end of this month.
The section labels are formed in the drawLabel(...) method in the PiePlot class. You could subclass PiePlot and override the method...that would probably be easier if I separated out the label formation from the actual drawing.
Regards,
DG.
The negative percentages bug was introduced (by me) in 0.9.2 and has been fixed in CVS. I've been a little busy lately, but should get 0.9.3 released before the end of this month.
The section labels are formed in the drawLabel(...) method in the PiePlot class. You could subclass PiePlot and override the method...that would probably be easier if I separated out the label formation from the actual drawing.
Regards,
DG.
Re: negate percentages in pie chart
Hey thanks!
Was thinking maybe labels should be JLabels. That way people could use the full power of "<html>...</html>" in their pie chart labels!
Was thinking maybe labels should be JLabels. That way people could use the full power of "<html>...</html>" in their pie chart labels!
Re: negate percentages in pie chart
What's the status on this issue and the release of 0.9.3? I'm reluctant to embark on
a lot of programming or compiling source from CVS to fix this minor bug if maybe
a "real" release is forthcoming...
I tried diff'ing the current CVS version of PiePlot against the 0.9.2 version, but I can't for the life of me see where the negative percent bug was introduced, or how it was
fixed... is there maybe a "one-line" fix to PiePlot that will patch this until I can get 0.9.3? I've got a project due out the door, oh... *September 2nd* that kinda needs this fix
.
a lot of programming or compiling source from CVS to fix this minor bug if maybe
a "real" release is forthcoming...
I tried diff'ing the current CVS version of PiePlot against the 0.9.2 version, but I can't for the life of me see where the negative percent bug was introduced, or how it was
fixed... is there maybe a "one-line" fix to PiePlot that will patch this until I can get 0.9.3? I've got a project due out the door, oh... *September 2nd* that kinda needs this fix

Re: negate percentages in pie chart
Ah. I see a compiled version of the CVS release is available here:
http://homepage.ntlworld.com/richard_c_ ... freechart/
I'll give that a try. Hopefully, no "gotcha" cases pop up that break something else
. I'm not doing much custom programming of JFreeChart classes, so hopefully, I'm safe.
http://homepage.ntlworld.com/richard_c_ ... freechart/
I'll give that a try. Hopefully, no "gotcha" cases pop up that break something else

Re: negate percentages in pie chart
Hi Michael,
The fix is in the drawLabel(...) method of the PiePlot class. Now that you can specify the direction (clockwise or anticlockwise) for the pie chart, the percentage amount needs to have the sign reversed for the clockwise direction.
One workaround without modifying the JFreeChart 0.9.2 code is simply to call setDirection(ANTICLOCKWISE) in the PiePlot class.
Regards,
DG.
The fix is in the drawLabel(...) method of the PiePlot class. Now that you can specify the direction (clockwise or anticlockwise) for the pie chart, the percentage amount needs to have the sign reversed for the clockwise direction.
One workaround without modifying the JFreeChart 0.9.2 code is simply to call setDirection(ANTICLOCKWISE) in the PiePlot class.
Regards,
DG.