Search code examples
jfreechart

Increase width of label container


I have a label which breaks up as the container in which it is written (blue box) is quite small. As you can see in the screenshot, the word centuries is spread across 2 lines. I could not find any method which could increase the container and display the word correctly.
Is it possible to increase the width without impacting the size of the pie chart?

chart http://uploadpie.com/ORbZv


Solution

  • The label space is defined as a percentage of the entire canvas. If you give the label more space, you will end up with a smaller pie.

    You can manipulate the percentages using these methods:

    piePlot.setLabelGap(0);
    piePlot.setInteriorGap(0.0);
    piePlot.setMaximumLabelWidth(0.30);