@Override
protected void encodeOptions(FacesContext context, Chart chart) throws IOException {
super.encodeOptions(context, chart);
ResponseWriter writer = context.getResponseWriter();
BarChartModel model = (BarChartModel) chart.getModel();
String orientation = model.getOrientation();
int barPadding = model.getBarPadding();
int barMargin = model.getBarMargin();
List<String> ticks = model.getTicks();
writer.write(",series:[");
for(Iterator<ChartSeries> it = model.getSeries().iterator(); it.hasNext();) {
ChartSeries series = (ChartSeries) it.next();
series.encode(writer);
if(it.hasNext()) {
writer.write(",");
}
}
writer.write("]");
writer.write(",ticks:[");
for(Iterator<String> tickIt = ticks.iterator(); tickIt.hasNext();) {
writer.write("\"" + ComponentUtils.escapeText(tickIt.next()) + "\"");
if(tickIt.hasNext()) {
writer.write(",");
}
}
writer.write("]");
if(orientation != null) writer.write(",orientation:\"" + orientation + "\"");
if(barPadding != 8) writer.write(",barPadding:" + barPadding);
if(barMargin != 10) writer.write(",barMargin:" + barMargin);
if(model.isStacked()) writer.write(",stackSeries:true");
if(model.isZoom()) writer.write(",zoom:true");
if(model.isAnimate()) writer.write(",animate:true");
if(model.isShowPointLabels()) writer.write(",showPointLabels:true");
if(model.isShowDatatip()) {
writer.write(",datatip:true");
if(model.getDatatipFormat() != null)
writer.write(",datatipFormat:\"" + model.getDatatipFormat() + "\"");
}
}