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.
Asked
Active
Viewed 1,138 times
0
-
Hello. Welcome to Stack Overflow. Please have a look around and take the [tour], and read through the [help center]. You can also read about [ask] a good question. – Sampada Apr 29 '16 at 09:33
-
What is hello?, the legend or a textField in your jrxml? – Petter Friberg Apr 29 '16 at 12:30
-
@PetterFriberg: I thought it was the domain axis label. – Catalina Island Apr 29 '16 at 16:51
1 Answers
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);
Try doing the same for the range axis to see the effect:
rangeAxis.setLabelLocation(AxisLabelLocation.LOW_END);

trashgod
- 203,806
- 29
- 246
- 1,045