Reputation: 1158
I have a horizontal bar chart. I want to make it such that I only show the labels for the domains, but not the range because I already have labels at the end of each bar showing their exact value. This is what the bar chart currently looks like :
I want to get rid of the tick labels on the range (0, 25, 50, 75, 100) while keeping the tick labels on the domain. How can I do this without getting rid of both? I've tried :
public class BarCustomizer implements JRChartCustomizer {
@Override
public void customize(JFreeChart chart, JRChart jasperChart) {
BarRenderer renderer = (BarRenderer) chart.getCategoryPlot().getRenderer();
renderer.setMaximumBarWidth(0.99);
renderer.setItemMargin(-2);
ValueAxis rangeAxis = chart.getCategoryPlot().getRangeAxis();
rangeAxis.setVerticalTickLabels(false);
rangeAxis.setTickLabelsVisible(false);
}
}
But this just makes labels on both axis go invisible.
Upvotes: 0
Views: 468
Reputation: 1158
I solved the issue by setting the setTickLabelsVisible for both axis (even though by default the domain axis should show the tick labels). It seems that setting only one of the axis would result in setting true or false for both axis (weird bug). So setting the domain axis to setTickLabelsVisible(true) while setting the range axis setTickLabelsVisible(false) solved my issue.
Upvotes: 1