JFreeChart - How to Improve Shortcuts in a Pie Chart

I basically have a very similar problem in the following article: http://www.jfree.org/phpBB2/viewtopic.php?t=24713

Besides the fact that instead of differences in versions, my results for shortcuts are very similar to the 3rd pie chart, where I would prefer that they look like the 1st chart (more space on the line - wider lines), so that they donโ€™t need to wrap on the next line so fast. I tried everything I can think of to increase the size of the shortcuts, but nothing works.

My main thinking is to configure where the label starts to write, and after a lot of debugging of the source, I was able to expand the window size, but not the actual line. I could not find a way to do this without editing the source using some kind of configuration, and even then I could not adjust the text correctly, only the field. And it took a lot of effort, the code is not in the same place for both.

Any suggestions on how to set up the pie chart so that the labels, as shown in the above article, worked more like the 1st chart than the last chart. I did what was suggested on this post:

plot.setInteriorGap(0.02); plot.setMaximumLabelWidth(0.20); plot.setLabelLinkStyle(PieLabelLinkStyle.CUBIC_CURVE); 

but it didnโ€™t matter. By default, this is not CUBIC_CURVE in the latest version. SetInteriorGap had a slight improvement, but it was minimal. And the other line did nothing.

Which really worries how much white space is left and right of the generated chart. It would be great to use this space somehow.

+4
source share
1 answer

I am not sure about the first release. However, I have some idea of โ€‹โ€‹what to do with the remaining spaces.

If you are converting a chart into an image, you can try to crop the spaces around it using the following:

 BufferedImage chartImage = chart.createBufferedImage(width, height); chartImage = chartImage.getSubImage(howMuchToTrimOnLeft, howMuchtoTrimOnTop, width - howMuchToTrimOnLeft - howMuchToTrimOnRight, height - howMuchtoTrimOnTop - howMuchToTrimOnBottom); 

The resulting chartImage will contain the cropped version. Make sure the initial width and height are larger than the size of the area you want the chart to fit, then crop it to size.

0
source

Source: https://habr.com/ru/post/1402592/


All Articles