private void encodeSeriesDef(FacesContext facesContext, UIChart chart, List<ChartSeries> series) throws IOException {
ResponseWriter writer = facesContext.getResponseWriter();
writer.write("var " + getSeriesDefVar(chart) + " = [");
for (int i=0; i<series.size();i++) {
ChartSeries currentSeries = series.get(i);
String fieldName = getFieldName(currentSeries.getValueExpression("value"));
writer.write("{displayName:\"" + currentSeries.getLabel() + "\", yField:\"" + fieldName + "\"");
if(currentSeries.getStyle() != null) {
writer.write(",style:" + currentSeries.getStyle());
}
writer.write("}");
if(i != series.size() -1)