I have defined a bar chart in Jasper Studio and it's generating this kind of result:
The values on top of bars are overlapping. I would like either of:
- reduce labels' text size and limit them to two decimal places.
- change the vertical position of labels to avoid overlapping.
I'm not sure but I think that Jasper Studio doesn't allow to configure any of it.
I've seen about implementing in code JRChartCustomizer
but I don't know how to modify labels' texts or positions.
EDIT
I've tried this way:
public void customize(JFreeChart fc, JRChart jrc) {
CategoryPlot catPlot = fc.getCategoryPlot();
if (jrc.getDataset() instanceof JRFillChartDataset) {
JRFillChartDataset jrFillChartDataset = (JRFillChartDataset) jrc.getDataset();
CategoryLabelGenerator categoryLabelGenerator = (CategoryLabelGenerator) jrFillChartDataset.getLabelGenerator();
categoryLabelGenerator.getNumberFormat().setMaximumFractionDigits(1);
But is useless because getLabelGenerator() creates a new CategoryLabelGenerator on each calling so setting values to its NumberFormat instance is pointless.