Pie chart: how to specify the radius of the pie?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
spennec
Posts: 6
Joined: Mon Jan 11, 2010 11:55 am
antibot: No, of course not.

Pie chart: how to specify the radius of the pie?

Post by spennec » Thu Jan 14, 2010 8:47 am

Hello (again),

I'm drawing two pie charts, and insert them into the same PDF page. The exported charts have the same sizes. On both charts, the legend is included, and added on the right of the chart. In fact, these are two instances of the same class but with different values.

The problem is that the pies do not have the same radius, and it doesn't look good on the page...

Is there a way to force a radius when drawing a pie chart? I haven't found any references to such configuration in the book...

Thanks for any help :)

barefoot
Posts: 1
Joined: Thu Feb 25, 2010 12:55 am
antibot: No, of course not.

Re: Pie chart: how to specify the radius of the pie?

Post by barefoot » Thu Feb 25, 2010 1:06 am

I happened upon this post whilst generating a PDF myself over the past couple of weeks--probably you've already solved it somehow, but posting this for posterity anyways. I never did find a great way to explicitly specify the radius of the pie itself (which seems odd), however there is a "trick" to force the radius to be smaller at least: set the label gap.

The specific method is PiePlot.setLabelGap(). The value is expressed as a percentage of the chart width, what it does is set the amount of padding between the pie itself and the section labels that are decorated around it. More padding == less pie, more or less. So, by setting the width/height of the entire chart, e.g. when rendering as a PNG, and then setting the label gap, you should be able to force the radius of your pie to whatever you like. It worked fine for me at least.

spennec
Posts: 6
Joined: Mon Jan 11, 2010 11:55 am
antibot: No, of course not.

Re: Pie chart: how to specify the radius of the pie?

Post by spennec » Thu Feb 25, 2010 8:42 am

Hello barefoot,

Thanks for your reply! Actually, I haven't found any resolution for this problem, so your suggestion might help me :)

I totally agree with you on the fact that it is odd that one cannot force the radius... I'm going to add a feature request about it, and we'll see what happens...

Locked