我正在尝试使用JasperReports和DynamicJasper APIs动态生成报告。
我将饼图添加到报告中,但在 drb.addChart(djChart) 聊天添加为空之后。这是我的代码:
private static DynamicReport createPieChart() {
DynamicReportBuilder drb = new DynamicReportBuilder();
DynamicReport dr = new DynamicReport();
try {
AbstractColumn columnName = ColumnBuilder.getNew().setColumnProperty("name", String.class.getName()).setTitle("Name").build();
AbstractColumn columnaId = ColumnBuilder.getNew().setColumnProperty("id", Integer.class.getName()).setTitle("Id").build();
AbstractColumn columnaTotal = ColumnBuilder.getNew().setColumnProperty("total", Long.class.getName()).setTitle("Total").build();
drb.addColumn(columnName);
drb.addColumn(columnaId);
drb.addColumn(columnaTotal);
DJChart djChart = new DJPieChartBuilder().setX(20)
.setY(10)
.setWidth(500)
.setHeight(250)
.setKey((PropertyColumn) columnaId)
.addSerie(columnaTotal).build();
drb.setUseFullPageWidth(true);
drb.addChart(djChart);
dr = drb.build();
} catch (Exception e) {
}
return dr;
}
请帮忙!