繁体   English   中英

通过Java代码在jasper Report中进行类别轴标签表达对齐

[英]Category Axis Label Expression Alignment In jasper Report through Java code

有什么方法可以通过Java代码更改Jasper Report中图表的类别轴标签表达式的对齐方式。 我想要类别轴标签表达式的左对齐。 如下图所示,我希望“ hello”保持对齐。

给定图片

从分发中包含的BarChartDemo1开始,以下更改将创建一个条形图,其轴标签的位置设置为LOW_END 对于PlotOrientation.VERTICAL ,这意味着在左侧对齐。

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

图片

尝试对范围轴执行相同操作以查看效果:

rangeAxis.setLabelLocation(AxisLabelLocation.LOW_END);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM