use of org.activityinfo.shared.report.model.PivotChartReportElement in project activityinfo by bedatadriven.
the class ItextReportRendererTest method htmlImages.
@Test
public void htmlImages() throws IOException {
DummyPivotTableData data = new DummyPivotTableData();
PivotChartContent chartContent = new PivotChartContent();
chartContent.setData(data.table);
chartContent.setYMin(0);
chartContent.setYStep(100);
chartContent.setFilterDescriptions(Collections.EMPTY_LIST);
PivotChartReportElement chart = new PivotChartReportElement(Type.Pie);
chart.setTitle("My Pie Chart");
chart.setCategoryDimensions(data.colDims);
chart.setSeriesDimensions(data.rowDims);
chart.setContent(chartContent);
PivotContent tableContent = new PivotContent();
tableContent.setFilterDescriptions(Collections.EMPTY_LIST);
tableContent.setData(data.table);
PivotTableReportElement table = new PivotTableReportElement();
table.setColumnDimensions(data.colDims);
table.setRowDimensions(data.rowDims);
table.setTitle("My Table");
table.setContent(tableContent);
BubbleMapMarker marker1 = new BubbleMapMarker();
marker1.setLat(-2.45);
marker1.setLng(28.8);
marker1.setX(100);
marker1.setY(100);
marker1.setRadius(25);
TileBaseMap baseMap = new TileBaseMap();
baseMap.setTileUrlPattern("http://mt{s}.aimaps.net/nordkivu.cd/v1/z{z}/{x}x{y}.png");
MapContent mapContent = new MapContent();
mapContent.setFilterDescriptions(Collections.EMPTY_LIST);
mapContent.setBaseMap(baseMap);
mapContent.setZoomLevel(8);
mapContent.setCenter(new Extents(-2.2, -2.1, 28.85, 28.9).center());
mapContent.setMarkers(Arrays.asList((MapMarker) marker1));
MapReportElement map = new MapReportElement();
map.setTitle("My Map");
map.setContent(mapContent);
ReportContent content = new ReportContent();
content.setFilterDescriptions(Collections.EMPTY_LIST);
Report report = new Report();
report.setContent(content);
report.addElement(chart);
report.addElement(table);
report.addElement(new TextReportElement("Testing 1..2.3.. français"));
report.addElement(map);
renderToPdf(report, "piechart.pdf");
renderToHtml(report, "piechart.html");
// renderToHtmlUsingWriter(report, "piechart2.html");
renderToRtf(report, "piechart.rtf");
}
use of org.activityinfo.shared.report.model.PivotChartReportElement in project activityinfo by bedatadriven.
the class ReportJsonFactory method decodePivotChartReportElement.
public PivotChartReportElement decodePivotChartReportElement(JsonObject element) {
PivotChartReportElement pivotChartElement = new PivotChartReportElement();
JsonElement title = element.get("title");
if (title != null) {
pivotChartElement.setTitle(title.getAsString());
}
JsonElement sheetTitle = element.get("sheetTitle");
if (sheetTitle != null) {
pivotChartElement.setSheetTitle(sheetTitle.getAsString());
}
JsonElement type = element.get("type");
if (type != null) {
pivotChartElement.setType(PivotChartReportElement.Type.valueOf(type.getAsString()));
}
JsonElement categoryAxisTitle = element.get("categoryAxisTitle");
if (categoryAxisTitle != null) {
pivotChartElement.setCategoryAxisTitle(categoryAxisTitle.getAsString());
}
JsonElement valueAxisTitle = element.get("valueAxisTitle");
if (valueAxisTitle != null) {
pivotChartElement.setValueAxisTitle(valueAxisTitle.getAsString());
}
JsonObject filter = element.get("filter").getAsJsonObject();
pivotChartElement.setFilter(decodeFilter(filter));
JsonArray categoryDimensions = element.get("categoryDimensions").getAsJsonArray();
if (categoryDimensions.size() > 0) {
pivotChartElement.setCategoryDimensions(decodeDimensionList(categoryDimensions));
}
JsonArray seriesDimensions = element.get("seriesDimensions").getAsJsonArray();
if (seriesDimensions.size() > 0) {
pivotChartElement.setSeriesDimensions(decodeDimensionList(seriesDimensions));
}
return pivotChartElement;
}
use of org.activityinfo.shared.report.model.PivotChartReportElement in project activityinfo by bedatadriven.
the class ExcelReportRenderer method render.
@Override
public void render(ReportElement element, OutputStream os) throws IOException {
HSSFWorkbook book = new HSSFWorkbook();
if (element instanceof Report) {
render(book, (Report) element);
} else if (element instanceof PivotTableReportElement) {
pivotTableRenderer.render(book, (PivotTableReportElement) element);
} else if (element instanceof TableElement) {
tableRenderer.render(book, (TableElement) element);
} else if (element instanceof PivotChartReportElement) {
chartRenderer.render(book, (PivotChartReportElement) element);
}
book.write(os);
}
use of org.activityinfo.shared.report.model.PivotChartReportElement in project activityinfo by bedatadriven.
the class PPTRenderer method render.
@Override
public void render(ReportElement element, OutputStream os) throws IOException {
if (element instanceof Report) {
SlideShow ppt = new SlideShow();
Report report = (Report) element;
for (ReportElement child : report.getElements()) {
if (child instanceof MapReportElement) {
mapRenderer.render((MapReportElement) child, ppt);
} else if (child instanceof PivotChartReportElement) {
chartRenderer.render((PivotChartReportElement) child, ppt);
}
}
ppt.write(os);
} else if (element instanceof MapReportElement) {
mapRenderer.render((MapReportElement) element, os);
} else if (element instanceof PivotChartReportElement) {
chartRenderer.render((PivotChartReportElement) element, os);
}
}
use of org.activityinfo.shared.report.model.PivotChartReportElement in project activityinfo by bedatadriven.
the class EmptyChartsTest method generate.
@Test
public void generate() {
PivotChartReportElement element = new PivotChartReportElement(Type.StackedBar);
element.setIndicator(1);
element.addCategoryDimension(new Dimension(DimensionType.Partner));
element.addSeriesDimension(new Dimension(DimensionType.Database));
DispatcherSync dispatcher = createMock(DispatcherSync.class);
expect(dispatcher.execute(isA(PivotSites.class))).andReturn(new PivotSites.PivotResult(Collections.EMPTY_LIST));
expect(dispatcher.execute(isA(GetDimensionLabels.class))).andReturn(new GetDimensionLabels.DimensionLabels(Collections.EMPTY_MAP));
replay(dispatcher);
IndicatorDAO indicatorDAO = createMock(IndicatorDAO.class);
expect(indicatorDAO.findById(eq(1))).andReturn(new Indicator());
replay(indicatorDAO);
PivotChartGenerator generator = new PivotChartGenerator(dispatcher, indicatorDAO);
generator.generate(new User(), element, new Filter(), new DateRange());
}
Aggregations