use of org.xwiki.rendering.internal.macro.chart.source.DataSource in project xwiki-platform by xwiki.
the class ChartMacro method generateChart.
/**
* Builds the chart image according to the specifications passed in.
*
* @param parameters the macro parameters
* @param content the macro content
* @param context the macro transformation context, used for example to find out the current document reference
* @throws MacroExecutionException if an error occurs while generating / saving the chart image
*/
private void generateChart(ChartMacroParameters parameters, String content, MacroTransformationContext context) throws MacroExecutionException {
String source = computeSource(parameters.getSource(), content);
DataSource dataSource;
try {
dataSource = this.componentManager.getInstance(DataSource.class, source);
} catch (ComponentLookupException e) {
throw new MacroExecutionException(String.format("Invalid source parameter [%s]", parameters.getSource()), e);
}
Map<String, String> sourceParameters = getSourceParameters(parameters, source);
dataSource.buildDataset(content, sourceParameters, context);
try {
this.imageWriter.writeImage(new ImageId(parameters), this.chartGenerator.generate(dataSource.getChartModel(), sourceParameters));
} catch (ChartGeneratorException e) {
throw new MacroExecutionException("Error while rendering chart", e);
}
}
Aggregations