use of org.activityinfo.legacy.shared.reports.content.PivotTableData in project activityinfo by bedatadriven.
the class PivotTableBinder method generateElement.
private PivotContent generateElement() {
PivotTableReportElement model = (PivotTableReportElement) getModel();
PivotTableDataBuilder builder = new PivotTableDataBuilder();
PivotTableData data = builder.build(model.getRowDimensions(), model.getColumnDimensions(), cachedResult.getBuckets());
PivotContent content = new PivotContent();
content.setEffectiveFilter(cachedFilter);
content.setData(data);
return content;
}
use of org.activityinfo.legacy.shared.reports.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());
}
}
}
};
}
use of org.activityinfo.legacy.shared.reports.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(), user.getLocaleObject(), 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);
}
use of org.activityinfo.legacy.shared.reports.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(), user.getLocaleObject(), 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);
}
use of org.activityinfo.legacy.shared.reports.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().getEndDateRange());
PivotTableData data = element.getContent().getData();
if (data.isEmpty()) {
document.add(new Paragraph(I18N.CONSTANTS.noData()));
} 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);
}
}
Aggregations