Reputation: 139
I want to create a Bar Chart, using JFreeChart, with vertical labels above the bars. I can do this using an ItemLabelPositioner as follows:
BarRenderer renderer = (BarRenderer)plot.getRenderer();
ItemLabelPosition pOut = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.CENTER_LEFT, TextAnchor.CENTER_LEFT, -Math.PI / 2.0);
renderer.setBasePositiveItemLabelPosition(pOut);
However, the labels on the tallest bars go off the top of the chart. Is there a way I can prevent this without doing complicated calculations on label sizes and setting the upper margin?
Upvotes: 1
Views: 753
Reputation: 1266
You may use something like this :
renderer.setItemLabelAnchorOffset(10); //giving some margins
Upvotes: 0