Madhusudan
Madhusudan

Reputation: 4815

How to show labels on top of bar with some space in jasper report?

I am working on a jasper report in which I am using java customizers to make some changes in the chart look. In my report I am creating a bar chart which looks like below:

enter image description here

Here I am using following code to show labels on top of bars:

CategoryPlot plot = (CategoryPlot)chart.getPlot();
BarRenderer barRenderer = (BarRenderer)plot.getRenderer();
CategoryPlot categoryPlot = (CategoryPlot) chart.getPlot();
categoryPlot.getRenderer().setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER));

I want to increase the space between top of bars and labels. I am not getting a way to do this. Can someone suggest me how to do this?

Upvotes: 2

Views: 1372

Answers (1)

Eric Leibenguth
Eric Leibenguth

Reputation: 4277

Try adding an offset to the label anchor:

categoryPlot.getRenderer().setItemLabelAnchorOffset(10.0d);

Upvotes: 2

Related Questions