Search in sources :

Example 6 with PivotChartReportElement

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");
}
Also used : ReportContent(org.activityinfo.shared.report.content.ReportContent) MapMarker(org.activityinfo.shared.report.content.MapMarker) IconMapMarker(org.activityinfo.shared.report.content.IconMapMarker) BubbleMapMarker(org.activityinfo.shared.report.content.BubbleMapMarker) MapContent(org.activityinfo.shared.report.content.MapContent) Report(org.activityinfo.shared.report.model.Report) DummyPivotTableData(org.activityinfo.server.report.DummyPivotTableData) BubbleMapMarker(org.activityinfo.shared.report.content.BubbleMapMarker) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement) Extents(org.activityinfo.shared.util.mapping.Extents) TextReportElement(org.activityinfo.shared.report.model.TextReportElement) MapReportElement(org.activityinfo.shared.report.model.MapReportElement) PivotContent(org.activityinfo.shared.report.content.PivotContent) TileBaseMap(org.activityinfo.shared.map.TileBaseMap) PivotChartReportElement(org.activityinfo.shared.report.model.PivotChartReportElement) PivotChartContent(org.activityinfo.shared.report.content.PivotChartContent) Test(org.junit.Test)

Example 7 with PivotChartReportElement

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;
}
Also used : JsonArray(com.google.gson.JsonArray) JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) PivotChartReportElement(org.activityinfo.shared.report.model.PivotChartReportElement)

Example 8 with PivotChartReportElement

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);
}
Also used : Report(org.activityinfo.shared.report.model.Report) PivotChartReportElement(org.activityinfo.shared.report.model.PivotChartReportElement) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) TableElement(org.activityinfo.shared.report.model.TableElement)

Example 9 with PivotChartReportElement

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);
    }
}
Also used : MapReportElement(org.activityinfo.shared.report.model.MapReportElement) Report(org.activityinfo.shared.report.model.Report) SlideShow(org.apache.poi.hslf.usermodel.SlideShow) ReportElement(org.activityinfo.shared.report.model.ReportElement) PivotChartReportElement(org.activityinfo.shared.report.model.PivotChartReportElement) MapReportElement(org.activityinfo.shared.report.model.MapReportElement) PivotChartReportElement(org.activityinfo.shared.report.model.PivotChartReportElement)

Example 10 with PivotChartReportElement

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());
}
Also used : IndicatorDAO(org.activityinfo.server.database.hibernate.dao.IndicatorDAO) GetDimensionLabels(org.activityinfo.shared.command.GetDimensionLabels) User(org.activityinfo.server.database.hibernate.entity.User) Dimension(org.activityinfo.shared.report.model.Dimension) Indicator(org.activityinfo.server.database.hibernate.entity.Indicator) PivotSites(org.activityinfo.shared.command.PivotSites) DateRange(org.activityinfo.shared.report.model.DateRange) Filter(org.activityinfo.shared.command.Filter) PivotChartGenerator(org.activityinfo.server.report.generator.PivotChartGenerator) PivotChartReportElement(org.activityinfo.shared.report.model.PivotChartReportElement) DispatcherSync(org.activityinfo.server.command.DispatcherSync) Test(org.junit.Test)

Aggregations

PivotChartReportElement (org.activityinfo.shared.report.model.PivotChartReportElement)12 Report (org.activityinfo.shared.report.model.Report)6 Test (org.junit.Test)6 PivotTableReportElement (org.activityinfo.shared.report.model.PivotTableReportElement)5 MapReportElement (org.activityinfo.shared.report.model.MapReportElement)4 JsonArray (com.google.gson.JsonArray)2 JsonElement (com.google.gson.JsonElement)2 JsonObject (com.google.gson.JsonObject)2 DummyPivotTableData (org.activityinfo.server.report.DummyPivotTableData)2 PivotChartContent (org.activityinfo.shared.report.content.PivotChartContent)2 ReportContent (org.activityinfo.shared.report.content.ReportContent)2 ReportElement (org.activityinfo.shared.report.model.ReportElement)2 TableElement (org.activityinfo.shared.report.model.TableElement)2 TextReportElement (org.activityinfo.shared.report.model.TextReportElement)2 DispatcherSync (org.activityinfo.server.command.DispatcherSync)1 IndicatorDAO (org.activityinfo.server.database.hibernate.dao.IndicatorDAO)1 Indicator (org.activityinfo.server.database.hibernate.entity.Indicator)1 User (org.activityinfo.server.database.hibernate.entity.User)1 PivotChartGenerator (org.activityinfo.server.report.generator.PivotChartGenerator)1 Filter (org.activityinfo.shared.command.Filter)1