use of org.activityinfo.shared.report.content.SimpleCategory in project activityinfo by bedatadriven.
the class ItextReportRendererTest method manyColumns.
@Test
public void manyColumns() throws IOException {
PivotTableData data = new PivotTableData();
Dimension partner = new Dimension(DimensionType.Partner);
Dimension year = new DateDimension(DateUnit.YEAR);
EntityCategory avsi = new EntityCategory(100, "AVSI RRMP");
Axis avsiRow = data.getRootRow().addChild(partner, avsi, avsi.getLabel(), comparator);
for (int y = 2011; y < 2030; ++y) {
Axis col = data.getRootColumn().addChild(year, new SimpleCategory("" + y), "" + y, comparator);
avsiRow.setValue(col, (double) y);
}
PivotContent tableContent = new PivotContent(data, Lists.<FilterDescription>newArrayList());
PivotTableReportElement table = new PivotTableReportElement();
table.addRowDimension(partner);
table.addColDimension(year);
table.setContent(tableContent);
ReportContent content = new ReportContent();
content.setFilterDescriptions(Collections.EMPTY_LIST);
Report report = new Report();
report.setContent(content);
report.addElement(table);
renderToPdf(report, "narrowColumns.pdf");
renderToRtf(report, "narrowColumns.rtf");
}
use of org.activityinfo.shared.report.content.SimpleCategory in project activityinfo by bedatadriven.
the class ItextReportRendererTest method nestedColumns.
@Test
public void nestedColumns() throws IOException {
Dimension province = new AdminDimension(1);
Dimension partner = new Dimension(DimensionType.Partner);
Dimension year = new DateDimension(DateUnit.YEAR);
Dimension month = new DateDimension(DateUnit.MONTH);
EntityCategory avsi = new EntityCategory(100, "AVSI RRMP");
PivotTableData data = new PivotTableData();
Axis sudKivu = data.getRootColumn().addChild(province, new EntityCategory(1, "Sud Kivu"), "Sud Kivu", comparator);
Axis y2010 = sudKivu.addChild(year, new SimpleCategory("2010"), "2010", comparator);
Axis y2011 = sudKivu.addChild(year, new SimpleCategory("2010"), "2010", comparator);
Axis jan2010 = y2010.addChild(month, new SimpleCategory("Jan"), "Jan", comparator);
Axis feb2010 = y2010.addChild(month, new SimpleCategory("Feb"), "Feb", comparator);
Axis jan2011 = y2011.addChild(month, new SimpleCategory("Jan"), "Jan", comparator);
Axis feb2011 = y2011.addChild(month, new SimpleCategory("Feb"), "Feb", comparator);
Axis avsiRow = data.getRootRow().addChild(partner, avsi, avsi.getLabel(), comparator);
avsiRow.setValue(jan2010, 1d);
avsiRow.setValue(feb2010, 2d);
avsiRow.setValue(jan2011, 3d);
avsiRow.setValue(feb2011, 4d);
PivotContent tableContent = new PivotContent(data, Lists.<FilterDescription>newArrayList());
PivotTableReportElement table = new PivotTableReportElement();
table.addRowDimension(partner);
table.addColDimension(province);
table.addColDimension(year);
table.addColDimension(month);
table.setContent(tableContent);
ReportContent content = new ReportContent();
content.setFilterDescriptions(Collections.EMPTY_LIST);
Report report = new Report();
report.setContent(content);
report.addElement(table);
renderToPdf(report, "nestedColumns.pdf");
renderToRtf(report, "nestedColumns.rtf");
renderToXls(report, "nestedColumns.xls");
}
Aggregations