1

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?

Mick Francis
  • 139
  • 6

1 Answers1

0

You may use something like this :

renderer.setItemLabelAnchorOffset(10); //giving some margins
yavuzkavus
  • 1,268
  • 11
  • 17
  • I don't think this helps solve my immediate problem, but this is a useful piece of functionality for another issue I have, so thanks! – Mick Francis Mar 11 '14 at 14:34