显示没有表格的图表 [英] Show Chart with no Table

查看:126
本文介绍了显示没有表格的图表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用DynamicJasper生成一个Jasper报告,它只是一个图表,上面没有任何表格。似乎没有隐藏列或抑制表的方法。我只选择生成图表有哪些选择?我愿意接受一个不使用DynamicJasper的解决方案,只使用JasperReports java API。

I'm trying to generate a Jasper Report using DynamicJasper which is just a chart, with no table appearing above it. There doesn't seem to be a method for hiding a column or for suppressing the table. What are my options for generating just a chart? I would be open to a solution that does not use DynamicJasper, just the JasperReports java API.

public void go() throws ColumnBuilderException, ClassNotFoundException, JRException {
    super();

    final AbstractColumn areas = ColumnBuilder.getNew()
            .setColumnProperty("area", String.class.getName())
            .setTitle("Area")
            .setWidth(30)
            .build();

    final AbstractColumn exercises = ColumnBuilder.getNew()
            .setColumnProperty("exercises", Integer.class.getName())
            .setTitle("Exercises")
            .setWidth(30)
            .build();

    final DynamicReportBuilder reportBuilder = new DynamicReportBuilder();
    reportBuilder.addColumn(areas);
    reportBuilder.addColumn(exercises);
    reportBuilder.setUseFullPageWidth(true);

    final GroupBuilder groupBuilder = new GroupBuilder();
    groupBuilder.setCriteriaColumn((PropertyColumn) areas);
    groupBuilder.setGroupLayout(GroupLayout.EMPTY);
    final DJGroup group = groupBuilder.build();

    reportBuilder.addGroup(group);
    reportBuilder.addChart(this.chart((PropertyColumn) areas, exercises));

    final DynamicReport dynamicReport = reportBuilder.build();
    final JasperPrint jasperPrint =
            DynamicJasperHelper.generateJasperPrint(
                    dynamicReport,
                    new ClassicLayoutManager(),
                    new JRBeanCollectionDataSource(this.getData()));

    /* PDF */
    final JRPdfExporter exporter = new JRPdfExporter();
    exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
    exporter.setExporterOutput(new SimpleOutputStreamExporterOutput("/tmp/my.pdf"));
    exporter.exportReport();
}


推荐答案

而不是 addColumn 使用 addField 。感谢 Petter Friberg 评论

这篇关于显示没有表格的图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆