Search in sources :

Example 1 with PivotTableData

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

the class PivotGridPanel method createColumnModel.

protected ColumnModel createColumnModel(PivotTableData data) {
    List<ColumnConfig> config = new ArrayList<ColumnConfig>();
    ColumnConfig rowHeader = new ColumnConfig("header", "", 150);
    rowHeader.setRenderer(new RowHeaderRenderer());
    rowHeader.setSortable(false);
    rowHeader.setMenuDisabled(true);
    config.add(rowHeader);
    int colIndex = 1;
    List<PivotTableData.Axis> leaves = data.getRootColumn().getLeaves();
    for (PivotTableData.Axis axis : leaves) {
        String id = "col" + colIndex;
        String label = axis.getLabel();
        if (label == null) {
            label = I18N.CONSTANTS.value();
        }
        ColumnConfig column = new ColumnConfig(id, label, 75);
        column.setNumberFormat(IndicatorNumberFormat.INSTANCE);
        column.setAlignment(Style.HorizontalAlignment.RIGHT);
        column.setSortable(false);
        column.setMenuDisabled(true);
        propertyMap.put(axis, id);
        columnMap.put(colIndex, axis);
        config.add(column);
        colIndex++;
    }
    ColumnModel columnModel = new ColumnModel(config);
    int depth = data.getRootColumn().getDepth();
    int row = 0;
    for (int d = 1; d <= depth; ++d) {
        List<PivotTableData.Axis> children = data.getRootColumn().getDescendantsAtDepth(d);
        if (d < depth) {
            int col = 1;
            for (PivotTableData.Axis child : children) {
                int colSpan = child.getLeaves().size();
                columnModel.addHeaderGroup(row, col, new HeaderGroupConfig(child.getLabel(), 1, colSpan));
                col += colSpan;
            }
            row++;
        }
    }
    return columnModel;
}
Also used : ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) PivotTableData(org.activityinfo.shared.report.content.PivotTableData) ArrayList(java.util.ArrayList) HeaderGroupConfig(com.extjs.gxt.ui.client.widget.grid.HeaderGroupConfig) ColumnModel(com.extjs.gxt.ui.client.widget.grid.ColumnModel)

Example 2 with PivotTableData

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

the class PivotChartGenerator method generate.

@Override
public void generate(User user, PivotChartReportElement element, Filter inheritedFilter, DateRange dateRange) {
    Filter filter = GeneratorUtils.resolveElementFilter(element, dateRange);
    Filter effectiveFilter = inheritedFilter == null ? new Filter(filter, new Filter()) : new Filter(inheritedFilter, filter);
    PivotTableData data = generateData(user.getId(), LocaleHelper.getLocaleObject(user), element, effectiveFilter, element.getCategoryDimensions(), element.getSeriesDimensions());
    ScaleUtil.Scale scale = computeScale(element, data);
    PivotChartContent content = new PivotChartContent();
    content.setXAxisTitle(composeXAxisTitle(element));
    content.setYAxisTitle(composeYAxisTitle(element));
    content.setEffectiveFilter(filter);
    content.setFilterDescriptions(generateFilterDescriptions(filter, element.allDimensionTypes(), user));
    content.setYMin(scale.getValmin());
    content.setYStep(scale.getStep());
    content.setData(data);
    element.setContent(content);
}
Also used : Filter(org.activityinfo.shared.command.Filter) PivotTableData(org.activityinfo.shared.report.content.PivotTableData) PivotChartContent(org.activityinfo.shared.report.content.PivotChartContent)

Example 3 with PivotTableData

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

the class PivotTableGenerator method generate.

@Override
public void generate(User user, PivotTableReportElement element, Filter inheritedFilter, DateRange dateRange) {
    Filter filter = GeneratorUtils.resolveElementFilter(element, dateRange);
    Filter effectiveFilter = inheritedFilter == null ? filter : new Filter(inheritedFilter, filter);
    PivotTableData data = generateData(user.getId(), LocaleHelper.getLocaleObject(user), element, effectiveFilter, element.getRowDimensions(), element.getColumnDimensions());
    PivotContent content = new PivotContent();
    content.setEffectiveFilter(effectiveFilter);
    content.setFilterDescriptions(generateFilterDescriptions(filter, element.allDimensionTypes(), user));
    content.setData(data);
    element.setContent(content);
}
Also used : Filter(org.activityinfo.shared.command.Filter) PivotTableData(org.activityinfo.shared.report.content.PivotTableData) PivotContent(org.activityinfo.shared.report.content.PivotContent)

Example 4 with PivotTableData

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

the class ExcelChartRenderer method render.

@Override
public void render(Workbook book, PivotChartReportElement element) {
    /* Generate the actual pivot table data */
    element.getContent().getData();
    /* Generate the excel sheet */
    new BaseExcelRenderer<PivotChartReportElement>(book, element) {

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

        @Override
        public void generate() {
            PivotTableData data = this.element.getContent().getData();
            List<PivotTableData.Axis> rows = data.getRootRow().getLeaves();
            List<PivotTableData.Axis> cols = data.getRootColumn().getLeaves();
            Row headerRow = sheet.createRow(rowIndex++);
            for (int i = 0; i != cols.size(); ++i) {
                Cell colHeaderCell = headerRow.createCell(i + 1);
                colHeaderCell.setCellValue(factory.createRichTextString(cols.get(i).flattenLabel()));
            }
            for (int i = 0; i != rows.size(); ++i) {
                Row row = sheet.createRow(rowIndex++);
                // header
                Cell rowHeaderCell = row.createCell(0);
                rowHeaderCell.setCellValue(factory.createRichTextString(rows.get(i).flattenLabel()));
                // values
                for (int j = 0; j != cols.size(); ++j) {
                    Cell valueCell = row.createCell(j + 1);
                    valueCell.setCellValue(rows.get(i).getCell(cols.get(j)).getValue());
                }
            }
        }
    };
}
Also used : PivotTableData(org.activityinfo.shared.report.content.PivotTableData) FilterDescription(org.activityinfo.shared.report.content.FilterDescription) Row(org.apache.poi.ss.usermodel.Row) Cell(org.apache.poi.ss.usermodel.Cell)

Example 5 with PivotTableData

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

the class ItextPivotTableRenderer method render.

@Override
public void render(DocWriter writer, Document document, PivotTableReportElement element) throws DocumentException {
    document.add(ThemeHelper.elementTitle(element.getTitle()));
    ItextRendererHelper.addFilterDescription(document, element.getContent().getFilterDescriptions());
    ItextRendererHelper.addDateFilterDescription(document, element.getFilter().getDateRange());
    PivotTableData data = element.getContent().getData();
    if (data.isEmpty()) {
        // TODO: i18n
        document.add(new Paragraph("Aucune Données"));
    } else {
        int colDepth = data.getRootColumn().getDepth();
        List<PivotTableData.Axis> colLeaves = data.getRootColumn().getLeaves();
        int colBreadth = colLeaves.size();
        Table table = new Table(colBreadth + 1, 1);
        table.setUseVariableBorders(true);
        table.setWidth(100.0f);
        table.setWidths(calcColumnWidths(document, data, colLeaves));
        table.setBorderWidth(0);
        for (int depth = 1; depth <= colDepth; ++depth) {
            if (depth == 1) {
                Cell cell = ThemeHelper.cornerCell();
                cell.setRowspan(colDepth);
                table.addCell(cell);
            }
            List<PivotTableData.Axis> columns = data.getRootColumn().getDescendantsAtDepth(depth);
            for (PivotTableData.Axis column : columns) {
                Cell cell = ThemeHelper.columnHeaderCell(column.getLabel(), column.isLeaf());
                cell.setColspan(Math.max(1, column.getLeaves().size()));
                table.addCell(cell);
            }
        }
        table.endHeaders();
        for (PivotTableData.Axis row : data.getRootRow().getChildren()) {
            writeRow(table, row, colLeaves, 0);
        }
        document.add(table);
    }
}
Also used : Table(com.lowagie.text.Table) PivotTableData(org.activityinfo.shared.report.content.PivotTableData) Cell(com.lowagie.text.Cell) Paragraph(com.lowagie.text.Paragraph)

Aggregations

PivotTableData (org.activityinfo.shared.report.content.PivotTableData)15 PivotContent (org.activityinfo.shared.report.content.PivotContent)4 Dimension (org.activityinfo.shared.report.model.Dimension)4 AdminDimension (org.activityinfo.shared.report.model.AdminDimension)3 PivotTableReportElement (org.activityinfo.shared.report.model.PivotTableReportElement)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 DummyPivotTableData (org.activityinfo.server.report.DummyPivotTableData)2 Filter (org.activityinfo.shared.command.Filter)2 Bucket (org.activityinfo.shared.command.result.Bucket)2 EntityCategory (org.activityinfo.shared.report.content.EntityCategory)2 FilterDescription (org.activityinfo.shared.report.content.FilterDescription)2 PivotChartContent (org.activityinfo.shared.report.content.PivotChartContent)2 Axis (org.activityinfo.shared.report.content.PivotTableData.Axis)2 ReportContent (org.activityinfo.shared.report.content.ReportContent)2 SimpleCategory (org.activityinfo.shared.report.content.SimpleCategory)2 DateDimension (org.activityinfo.shared.report.model.DateDimension)2 Report (org.activityinfo.shared.report.model.Report)2 Cell (org.apache.poi.ss.usermodel.Cell)2 Row (org.apache.poi.ss.usermodel.Row)2