Reputation: 1
Is there any way, to change Category Axis Label Expression's Alignment of a Chart in Jasper Report through Java Code. I want Left alignment of Category Axis Label Expression. As shown the picture below, I want "hello" to be left aligned.
Upvotes: 0
Views: 1262
Reputation: 205785
Starting with BarChartDemo1
, included in the distribution, the changes below create a bar chart with an axis label having its location set to the LOW_END
. For PlotOrientation.VERTICAL
, that means aligned on the left.
JFreeChart chart = ChartFactory.createBarChart(
"Performance: JFreeSVG vs Batik",
"$P{hello}" /* x-axis label*/,
"Milliseconds" /* y-axis label */,
dataset, PlotOrientation.VERTICAL, false, false, false);
…
CategoryPlot plot = (CategoryPlot) chart.getPlot();
CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setLabelLocation(AxisLabelLocation.LOW_END);
Try doing the same for the range axis to see the effect:
rangeAxis.setLabelLocation(AxisLabelLocation.LOW_END);
Upvotes: 1