HOW-TO Add a chart (old api)

This documentation refers to the old chart API, please use the new api
DynamicReportBuilder drb = new DynamicReportBuilder();
//ReportBuilder initialization
//Group and columns creation

DJChartBuilder cb = new DJChartBuilder();                               // create a chart builder
DJChart chart =  cb.addType(DJChart.PIE_CHART)                          // define the type of chart (Pie)
                        .setOperation(DJChart.CALCULATION_SUM)         // define the type of operation to be done
                        .setColumnsGroup(g1)                           // define the group that will enclose values
                        .setColumn(columnAmount)                       // define the column used for series and categories

drb.addChart(chart);    //add the chart to the dynamic report

DJChartBuilder is the builder class, very convenient. To create a chart these parameters are needed

  • type: A constant of DJChart; indicates the type of chart. So far only valid values are:
  • Operation: A constant of DJChart; indicates the operation over the values the chart will perform.
  • ColumnsGroup: The group that will enclose the values used in the chart. Each time the group changes, a new chart will be printed.
  • Column: You can pass one or more. Each column will define a new series. Column title is used as category

Refer to ChartReportTest for a working example.

Also refer to ChartReportTest2 for a multiple series chart working example.

This code generate a report like this:




Fork me on GitHub