Search in sources :

Example 1 with PivotChartContent

use of org.activityinfo.shared.report.content.PivotChartContent 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);
}
Also used : Filter(org.activityinfo.shared.command.Filter) PivotTableData(org.activityinfo.shared.report.content.PivotTableData) PivotChartContent(org.activityinfo.shared.report.content.PivotChartContent)

Example 2 with PivotChartContent

use of org.activityinfo.shared.report.content.PivotChartContent 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 3 with PivotChartContent

use of org.activityinfo.shared.report.content.PivotChartContent in project activityinfo by bedatadriven.

the class ChartOFCView method show.

/**
 * Updates the view to the given PivotChartContent
 *
 * @param element
 */
@Override
public void show(PivotChartReportElement element) {
    PivotChartContent content = element.getContent();
    PivotTableData table = element.getContent().getData();
    if (gridPanel != null) {
        gridPanel.show(element);
    }
    List<PivotTableData.Axis> categories = table.getRootRow().getLeaves();
    List<PivotTableData.Axis> series = table.getRootColumn().getLeaves();
    ChartModel cm = new ChartModel();
    cm.setBackgroundColour(TRANSPARENT_BG);
    cm.setNumDecimals(0);
    cm.setDecimalSeparatorComma(true);
    cm.setXAxis(createXAxis(categories));
    cm.setYAxis(createYAxis(content, table));
    switch(element.getType()) {
        case Bar:
        case StackedBar:
        case ClusteredBar:
            addBarSeries(cm, categories, series);
            break;
        case Pie:
            addPieChart(cm, categories, series);
            break;
        case Line:
            addLineSeries(cm, categories, series);
            break;
    }
    setModel(cm);
}
Also used : PivotTableData(org.activityinfo.shared.report.content.PivotTableData) ChartModel(com.extjs.gxt.charts.client.model.ChartModel) XAxis(com.extjs.gxt.charts.client.model.axis.XAxis) YAxis(com.extjs.gxt.charts.client.model.axis.YAxis) PivotChartContent(org.activityinfo.shared.report.content.PivotChartContent)

Example 4 with PivotChartContent

use of org.activityinfo.shared.report.content.PivotChartContent in project activityinfo by bedatadriven.

the class ItextReportRendererTest method chartTest.

@Test
public void chartTest() 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);
    ReportContent content = new ReportContent();
    content.setFilterDescriptions(Collections.EMPTY_LIST);
    Report report = new Report();
    report.setContent(content);
    report.addElement(chart);
    renderToPdf(report, "chartTest.pdf");
    renderToRtf(report, "chartTest.rtf");
}
Also used : ReportContent(org.activityinfo.shared.report.content.ReportContent) Report(org.activityinfo.shared.report.model.Report) DummyPivotTableData(org.activityinfo.server.report.DummyPivotTableData) PivotChartReportElement(org.activityinfo.shared.report.model.PivotChartReportElement) PivotChartContent(org.activityinfo.shared.report.content.PivotChartContent) Test(org.junit.Test)

Aggregations

PivotChartContent (org.activityinfo.shared.report.content.PivotChartContent)4 DummyPivotTableData (org.activityinfo.server.report.DummyPivotTableData)2 PivotTableData (org.activityinfo.shared.report.content.PivotTableData)2 ReportContent (org.activityinfo.shared.report.content.ReportContent)2 PivotChartReportElement (org.activityinfo.shared.report.model.PivotChartReportElement)2 Report (org.activityinfo.shared.report.model.Report)2 Test (org.junit.Test)2 ChartModel (com.extjs.gxt.charts.client.model.ChartModel)1 XAxis (com.extjs.gxt.charts.client.model.axis.XAxis)1 YAxis (com.extjs.gxt.charts.client.model.axis.YAxis)1 Filter (org.activityinfo.shared.command.Filter)1 TileBaseMap (org.activityinfo.shared.map.TileBaseMap)1 BubbleMapMarker (org.activityinfo.shared.report.content.BubbleMapMarker)1 IconMapMarker (org.activityinfo.shared.report.content.IconMapMarker)1 MapContent (org.activityinfo.shared.report.content.MapContent)1 MapMarker (org.activityinfo.shared.report.content.MapMarker)1 PivotContent (org.activityinfo.shared.report.content.PivotContent)1 MapReportElement (org.activityinfo.shared.report.model.MapReportElement)1 PivotTableReportElement (org.activityinfo.shared.report.model.PivotTableReportElement)1 TextReportElement (org.activityinfo.shared.report.model.TextReportElement)1