Mick Francis
Mick Francis

Reputation: 139

How can I make a JFreeChart Bar Chart's plot expand to show vertical labels above the bars?

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

Answers (1)

yavuzkavus
yavuzkavus

Reputation: 1266

You may use something like this :

renderer.setItemLabelAnchorOffset(10); //giving some margins

Upvotes: 0

Related Questions