Search in sources :

Example 1 with SimpleChartModel

use of org.xwiki.rendering.internal.macro.chart.source.SimpleChartModel in project xwiki-platform by xwiki.

the class AbstractTableBlockDataSource method buildDataset.

@Override
public void buildDataset(String macroContent, Map<String, String> parameters, MacroTransformationContext context) throws MacroExecutionException {
    validateParameters(parameters);
    TableBlock tableBlock = getTableBlock(macroContent, context);
    int[] dataRange = getDataRange(tableBlock);
    TableDatasetBuilder datasetBuilder;
    setChartModel(new SimpleChartModel());
    switch(getDatasetType()) {
        case CATEGORY:
            datasetBuilder = new TableCategoryDatasetBuilder();
            break;
        case PIE:
            datasetBuilder = new TablePieDatasetBuilder();
            break;
        case TIMETABLE_XY:
            datasetBuilder = new TableTimeTableXYDatasetBuilder();
            break;
        default:
            throw new MacroExecutionException(String.format("Unsupported dataset type [%s]", getDatasetType().getName()));
    }
    setAxes();
    datasetBuilder.setLocaleConfiguration(getLocaleConfiguration());
    datasetBuilder.setParameters(parameters);
    if (SERIES_COLUMNS.equals(series)) {
        datasetBuilder.setTranspose(true);
    }
    buildDataset(tableBlock, dataRange, datasetBuilder);
    setDataset(datasetBuilder.getDataset());
}
Also used : SimpleChartModel(org.xwiki.rendering.internal.macro.chart.source.SimpleChartModel) TableBlock(org.xwiki.rendering.block.TableBlock) MacroExecutionException(org.xwiki.rendering.macro.MacroExecutionException)

Aggregations

TableBlock (org.xwiki.rendering.block.TableBlock)1 SimpleChartModel (org.xwiki.rendering.internal.macro.chart.source.SimpleChartModel)1 MacroExecutionException (org.xwiki.rendering.macro.MacroExecutionException)1