How to wrap category labels in JfreeChart

I have a pivot chart created using JFreeChart. The category labels are quite large, and they overlap with the label for the next bar. I would like to wrap it on the next line. I did a few searches and found that I should use the code below. setMaximumCategoryLabelLines (2) in the Axis category and yet it does not wrap to the next line.

Please offer solutions.

+5
source share
1 answer

Changing the code as the names of the long category are shown and used, I see the diagram below. It seems to work with complex rendering. Is this the desired effect?BarChartDemo1

private static JFreeChart createChart(CategoryDataset dataset) {
    ...
    // OPTIONAL CUSTOMISATION COMPLETED.
    domainAxis.setMaximumCategoryLabelLines(2);
    ...
}

image

+13

All Articles