简体   繁体   中英

Dynamic Jasper Report Pie Chart

    AbstractColumn columnBranch = ColumnBuilder.getNew().setColumnProperty("branch", String.class.getName())
        .setTitle("Branch").setWidth(new Integer(85)).build();
    AbstractColumn columnAmount = ColumnBuilder.getNew().setColumnProperty("amount", Float.class.getName())
            .build();


    drb.addColumn(columnBranch);
    drb.addColumn(columnAmount);        
    drb.setUseFullPageWidth(true);



    PropertyColumn pc = (PropertyColumn) ColumnBuilder.getNew().setColumnProperty("branch", String.class.getName()).build();
    DJChart djChart = new DJPieChartBuilder()
            // chart
            .setX(10).setY(10).setWidth(210).setHeight(150).setCentered(false).setBackColor(Color.LIGHT_GRAY)
            .setShowLegend(true).setPosition(DJChartOptions.POSITION_FOOTER).setTitle(new StringExpression() {
                public Object evaluate(Map fields, Map variables, Map parameters) {
                    return variables.get("group_state_name");
                }
            }).setTitleColor(Color.DARK_GRAY).setTitleFont(Font.ARIAL_BIG_BOLD).setSubtitle("subtitle")
            .setSubtitleColor(Color.DARK_GRAY).setSubtitleFont(Font.COURIER_NEW_BIG_BOLD)
            .setLegendColor(Color.DARK_GRAY).setLegendFont(Font.COURIER_NEW_MEDIUM_BOLD)
            .setLegendBackgroundColor(Color.WHITE).setLegendPosition(DJChartOptions.EDGE_BOTTOM)
            .setTitlePosition(DJChartOptions.EDGE_TOP).setLineStyle(DJChartOptions.LINE_STYLE_DOTTED)
            .setLineWidth(1).setLineColor(Color.DARK_GRAY).setPadding(5)
            // dataset
            .setKey(pc)
            .addSerie(ColumnBuilder.getNew().setColumnProperty("amount", Float.class.getName()).build())
            // plot
            .setCircular(true).build();
    drb.addChart(djChart);

How to generate chart without having to generate the columns using Dynamic Jasper reports? and without using the abstract column builder?

If I'm understanding your question correctly, use addField instead of addColumn

Please refer this original answer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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