negate percentages in pie chart

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

negate percentages in pie chart

Post by Jon Locke » Thu Aug 15, 2002 3:32 pm

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!

David Gilbert

Re: negate percentages in pie chart

Post by David Gilbert » Thu Aug 15, 2002 4:04 pm

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.

Jon Locke

Re: negate percentages in pie chart

Post by Jon Locke » Fri Aug 16, 2002 7:39 am

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!

Michael Suzio

Re: negate percentages in pie chart

Post by Michael Suzio » Thu Aug 29, 2002 10:13 pm

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 :-).

Michael Suzio

Re: negate percentages in pie chart

Post by Michael Suzio » Thu Aug 29, 2002 10:17 pm

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.

David Gilbert

Re: negate percentages in pie chart

Post by David Gilbert » Fri Aug 30, 2002 8:07 am

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.

Locked