Java JasperReports图表:在Customize()方法中访问序列表达式的值
我使用的是JasperReports服务器5.0专业版 对于其中一个报告,我使用图表定制器来定制条形图的颜色。评估时间为报告时间 在iReport中,我将序列表达式定义为Java JasperReports图表:在Customize()方法中访问序列表达式的值,java,jasper-reports,jfreechart,Java,Jasper Reports,Jfreechart,我使用的是JasperReports服务器5.0专业版 对于其中一个报告,我使用图表定制器来定制条形图的颜色。评估时间为报告时间 在iReport中,我将序列表达式定义为 $F{form} + "(" + $V{month} + ")" 在Java文件的定制方法中,我想访问上述表达式的值 9月1日、10月2日、1月3日、2月4日 我尝试了以下代码来获取序列值,但没有成功 public JRCategorySeries[] categoryList = null ; JRFill
$F{form} + "(" + $V{month} + ")"
在Java文件的定制方法中,我想访问上述表达式的值
9月1日、10月2日、1月3日、2月4日
我尝试了以下代码来获取序列值,但没有成功
public JRCategorySeries[] categoryList = null ;
JRFillCategoryDataset categoryDS = (JRFillCategoryDataset)jasperChart.getDataset();
categoryList = categoryDS.getSeries();
SubCategoryAxis domainAxis = new SubCategoryAxis("");
domainAxis.setCategoryMargin(0.05);
for (int i = 0 ; i <categoryList.length -1 ; i++ ) {
JRCategorySeries jrcategoryseries = categoryList[i];
domainAxis.addSubCategory(jrcategoryseries.getSeriesExpression().getText());
}
我需要在访问自定义方法系列数据点的帮助。非常感谢您的评论。您可以从传递给自定义类的JFreeChart参数中获取数据集。 此外,要访问在jrxml中为图表设置的属性,JRChart参数也可以访问这些属性 请试试这个
public void customize(JFreeChart chart, JRChart jasperChart) {
// To access the dataset of the chart
CategoryPlot plot = (CategoryPlot) chart.getPlot();
CategoryDataset catData = plot.getDataset();
// to access the key property of chart <br/>
String key = jasperChart.getKey();
}
问候
钱德拉