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;
}
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);
}
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);
}
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());
}
}
}
};
}
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);
}
}
Aggregations