Dynamic Legend to resolve ring chart sizing issues.

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
twister
Posts: 1
Joined: Tue Jul 24, 2012 4:02 pm
antibot: No, of course not.

Dynamic Legend to resolve ring chart sizing issues.

Post by twister » Tue Jul 24, 2012 4:49 pm

Hi Kind Helper,

Firstly, I am new to JFree charts, my previous reporting experience is using Jasper Reports for all my needs, but now I am walking into new area (using iText for reporting) due to strict requirements from client and also its great to master new libraries. My question is as follows:

Initial requirement: I needed to create ring pie charts to illustrate my database results after a certain operation. Everything was well (samples worked) until i tried it out with actual data base results.
1.) I noticed that ring pie chart decreases in size when there are considerably larger number of items(labels) in the Legend. Basically Chart Size is inversely proportional to the size/number of items in the legend.
2.) Shifted the Legend to the right, increased the canvas width. A litter better but still very noticeable when compared to other ring pie charts.

After going through this forum and few other resources online, it seems that JFree Chart renders the legend first and then later the graphical chart. Considering this, my question is as follows:

a) Are there any "set" methods that i would define a fixed size (width and height) for the pie chart, regardless of size/number of items(labels) in the legend.
b) What i was thinking - since I am aware of the dataset, I can find out the maximum number of items that would be occupied in a particular chart's legend. Therefore, is there way to dynamically and explicitly set the the legend size of the pie chart, hence then all the ring pie chart generated should theoretically speaking be of the same size regardless of the number of items in the legend.

Image

Port Usage is the chart with the mentioned issue; lack of consistency in the size of the charts. Appreciate any sample demos :)

Thanks in advance,
tg

remiohead
Posts: 201
Joined: Fri Oct 02, 2009 3:53 pm
antibot: No, of course not.

Re: Dynamic Legend to resolve ring chart sizing issues.

Post by remiohead » Wed Jul 25, 2012 9:19 pm

The issue is surely the length of the labels rather than the number of them.

I would you suggest your options are trimming the labels (by using a custom PieSectionLabelGenerator), changing the font size for longer text labels, and changing the label gap (plot.setLabelGap(double)).

NBAMj
Posts: 1
Joined: Wed Sep 05, 2012 12:21 pm
antibot: No, of course not.

Re: Dynamic Legend to resolve ring chart sizing issues.

Post by NBAMj » Wed Sep 05, 2012 12:23 pm

Use plot.setSectionDepth(Double percent) to control the width/thickness of your Pie/Ring sections :)

hisn
Posts: 1
Joined: Fri Feb 01, 2013 11:12 am
antibot: No, of course not.

Re: Dynamic Legend to resolve ring chart sizing issues.

Post by hisn » Fri Feb 01, 2013 11:16 am

NBAMj wrote:Use plot.setSectionDepth(Double percent) to control the width/thickness of your Pie/Ring sections :)
Thank you very much NBAMj. I tried plot.setSectionDepth, it works very well! :)

Your post solved a issue that troubling me for days. Thanks again.

amit_tanwani
Posts: 2
Joined: Wed Nov 19, 2014 6:18 am
antibot: No, of course not.

Re: Dynamic Legend to resolve ring chart sizing issues.

Post by amit_tanwani » Wed Nov 19, 2014 6:32 am

RingPlot
still not get the appropiate soltuion , i want fixed radius graph(Ring Plot) with fixed sectional depth
Please help thanks in advance

Locked