Search in sources :

Example 11 with PivotTableData

use of org.activityinfo.legacy.shared.reports.content.PivotTableData in project activityinfo by bedatadriven.

the class ChartRendererJC method createAxisChart.

protected Chart createAxisChart(PivotChartReportElement element, boolean includeTitle, int width, int height, int dpi) throws IOException, ChartDataException, PropertyException {
    PivotTableData table = element.getContent().getData();
    // find our categories and series leaves
    List<PivotTableData.Axis> categories = table.getRootRow().getLeaves();
    List<PivotTableData.Axis> series = table.getRootColumn().getLeaves();
    IAxisDataSeries dataSeries = new DataSeries(toLabelArray(element.getContent(), categories), element.getContent().getXAxisTitle(), element.getContent().getYAxisTitle(), includeTitle ? element.getTitle() : null);
    dataSeries.addIAxisPlotDataSet(new AxisChartDataSet(toDataArray(categories, series), toLabelArray(element.getContent(), series), computePaints(series), computeChartType(element), computeAxisChartProperties(dpi, element)));
    return new AxisChart(dataSeries, computeChartProperties(dpi), computeAxisProperties(dpi, element.getContent()), computeLegendProperties(element, dpi, series), width, height);
}
Also used : AxisChart(org.krysalis.jcharts.axisChart.AxisChart) PivotTableData(org.activityinfo.legacy.shared.reports.content.PivotTableData) IAxisDataSeries(org.krysalis.jcharts.chartData.interfaces.IAxisDataSeries) DataSeries(org.krysalis.jcharts.chartData.DataSeries) IAxisDataSeries(org.krysalis.jcharts.chartData.interfaces.IAxisDataSeries) AxisChartDataSet(org.krysalis.jcharts.chartData.AxisChartDataSet)

Example 12 with PivotTableData

use of org.activityinfo.legacy.shared.reports.content.PivotTableData in project activityinfo by bedatadriven.

the class ExcelPivotTableRenderer method render.

@Override
public void render(Workbook book, PivotTableReportElement element) {
    /* Generate the actual pivot table data */
    final PivotTableData table = element.getContent().getData();
    /* Generate the excel sheet */
    new BaseExcelTableRenderer<PivotTableReportElement, PivotTableData.Axis>(book, element) {

        @Override
        public List<FilterDescription> generateFilterDescriptions() {
            return element.getContent().getFilterDescriptions();
        }

        private CellStyle[] rowHeaderStyles;

        @Override
        public void generate() {
            /* Initialize Cell Styles */
            initColHeaderStyles(table.getRootColumn());
            initRowHeaderStyles();
            /* Generate the column headers */
            generateColumnHeaders(1, table.getRootColumn());
            int headerHeight = rowIndex;
            /* Create the rows */
            // row headers are in column 1
            sheet.setColumnWidth(0, 40 * 256);
            generateRows(table.getRootRow().getChildList(), 0);
            /* Finalize the sheet */
            sheet.setRowSumsBelow(false);
            sheet.createFreezePane(1, headerHeight);
        }

        protected void initRowHeaderStyles() {
            int depth = table.getRootRow().getDepth();
            rowHeaderStyles = new CellStyle[depth];
            for (int i = 0; i != depth; ++i) {
                CellStyle style = book.createCellStyle();
                style.setIndention((short) i);
                style.setWrapText(true);
                Font font = createBaseFont();
                if (i + 1 != depth) {
                    /* Has sub headers */
                    font.setBoldweight(Font.BOLDWEIGHT_BOLD);
                } else {
                    font.setBoldweight(Font.BOLDWEIGHT_NORMAL);
                }
                style.setFont(font);
                rowHeaderStyles[i] = style;
            }
        }

        protected void generateRows(List<PivotTableData.Axis> rows, int indent) {
            for (PivotTableData.Axis pivotRow : rows) {
                Row row = sheet.createRow(rowIndex++);
                Cell headerCell = row.createCell(0);
                headerCell.setCellValue(factory.createRichTextString(pivotRow.getLabel()));
                headerCell.setCellStyle(rowHeaderStyles[indent]);
                if (pivotRow.isLeaf()) {
                    for (Entry<PivotTableData.Axis, Integer> entry : colIndexMap.entrySet()) {
                        PivotTableData.Cell pivotCell = pivotRow.getCell(entry.getKey());
                        if (pivotCell != null) {
                            Cell cell = row.createCell(entry.getValue());
                            cell.setCellValue(pivotCell.getValue());
                        }
                    }
                } else {
                    int groupStart = rowIndex;
                    generateRows(pivotRow.getChildList(), indent + 1);
                    int groupEnd = rowIndex;
                    sheet.groupRow(groupStart, groupEnd);
                }
            }
        }
    };
}
Also used : FilterDescription(org.activityinfo.legacy.shared.reports.content.FilterDescription) PivotTableData(org.activityinfo.legacy.shared.reports.content.PivotTableData) List(java.util.List)

Aggregations

PivotTableData (org.activityinfo.legacy.shared.reports.content.PivotTableData)12 Filter (org.activityinfo.legacy.shared.command.Filter)2 Bucket (org.activityinfo.legacy.shared.command.result.Bucket)2 FilterDescription (org.activityinfo.legacy.shared.reports.content.FilterDescription)2 PivotChartContent (org.activityinfo.legacy.shared.reports.content.PivotChartContent)2 PivotContent (org.activityinfo.legacy.shared.reports.content.PivotContent)2 Dimension (org.activityinfo.legacy.shared.reports.model.Dimension)2 PivotTableReportElement (org.activityinfo.legacy.shared.reports.model.PivotTableReportElement)2 ChartModel (com.extjs.gxt.charts.client.model.ChartModel)1 XAxis (com.extjs.gxt.charts.client.model.axis.XAxis)1 YAxis (com.extjs.gxt.charts.client.model.axis.YAxis)1 GridEvent (com.extjs.gxt.ui.client.event.GridEvent)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 PivotSites (org.activityinfo.legacy.shared.command.PivotSites)1 PivotTableDataBuilder (org.activityinfo.legacy.shared.impl.pivot.PivotTableDataBuilder)1 CategoryComparator (org.activityinfo.legacy.shared.impl.pivot.order.CategoryComparator)1 DefinedCategoryComparator (org.activityinfo.legacy.shared.impl.pivot.order.DefinedCategoryComparator)1 AdminDimension (org.activityinfo.legacy.shared.reports.model.AdminDimension)1 DispatcherSync (org.activityinfo.server.command.DispatcherSync)1