-
Type:
New Feature
-
Resolution: Fixed
-
Priority:
Normal
-
Affects Version/s: 3.0.1
-
Security Level: Jimmy
-
None
Use Case
Users need to generate a report periodically in a working thread at the server without rendering a ZK Charts in a browser. highcharts provides a nodejs export server, and it accepts Charts JSON to produce an image/PDF. But there is no API to get Charts JSON.
Let users compose JSON manually is a burden for them.
Workaround
public String generateChartJson() throws NoSuchFieldException, IllegalAccessException {
Charts chart = new Charts();
PlotData plotData = new PlotData(chart) {
@Override
public void onChange(OptionDataEvent event) {
//on purpose do nothing to avoid accessing an Execution
}
};
Field field = Charts.class.getDeclaredField("_plotData");
field.setAccessible(true);
field.set(chart, plotData);
chart.setModel(model);
return chart.getPlotData().toJSONString();
}