boolean hasCategories = !categories.isEmpty();
//data
writer.write("data:[" );
for(Iterator<ChartSeries> it = model.getSeries().iterator(); it.hasNext();) {
ChartSeries series = it.next();
writer.write("[");
for(Iterator<Object> x = series.getData().keySet().iterator(); x.hasNext();) {
Object xValue = x.next();
Number yValue = series.getData().get(xValue);
String yValueAsString = yValue != null ? yValue.toString() : "null";
if(hasCategories) {
writer.write(yValueAsString);
} else {
writer.write("[");
writer.write(xValue + "," + yValueAsString);
writer.write("]");
}
if(x.hasNext()) {
writer.write(",");
}
}
writer.write("]");
if(it.hasNext()) {
writer.write(",");
}
}
writer.write("]");
//common config
encodeCommonConfig(context, chart);
//series
writer.write(",series:[");
for(Iterator<ChartSeries> it = model.getSeries().iterator(); it.hasNext();) {
ChartSeries series = (ChartSeries) it.next();
writer.write("{");
writer.write("label:'" + series.getLabel() + "'");
if(series instanceof LineChartSeries) {
LineChartSeries lineChartSeries = (LineChartSeries) series;
writer.write(",showLine:" + lineChartSeries.isShowLine());
writer.write(",markerOptions:{style:'" + lineChartSeries.getMarkerStyle() + "'}");
}