2016-04-29 56 views
0

有什么方法可以通过Java代码更改Jasper Report中的图表对齐轴类型标签表达式的图表。 我想分类轴标签表达式的左对齐。如下图所示,我希望“你好”左对齐。类别轴标签表达式对齐在jasper中通过Java代码报告

given picture

+0

你好。欢迎来到Stack Overflow。请环顾四周,参加[旅游],并通读[帮助中心]。你也可以阅读关于[问]一个很好的问题。 – Sampada

+0

什么是你好?,传说还是你的jrxml中的textField? –

+0

@PetterFriberg:我认为这是域轴标签。 –

回答

1

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

image

尝试做相同的范围轴看看效果:

rangeAxis.setLabelLocation(AxisLabelLocation.LOW_END);