0

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.

given picture

Alex K
  • 22,315
  • 19
  • 108
  • 236

1 Answers1

1

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);

image

Try doing the same for the range axis to see the effect:

rangeAxis.setLabelLocation(AxisLabelLocation.LOW_END);
trashgod
  • 203,806
  • 29
  • 246
  • 1,045