}
protected void encodeScript(FacesContext context, Chart chart) throws IOException{
ResponseWriter writer = context.getResponseWriter();
String type = chart.getType();
BasePlotRenderer plotRenderer = CHART_RENDERERS.get(type);
String clientId = chart.getClientId(context);
startScript(writer, clientId);
writer.write("$(function(){");
writer.write("PrimeFaces.cw('Chart','" + chart.resolveWidgetVar() + "',{");
writer.write("id:'" + clientId + "'");
writer.write(",type:'" + type + "'");
plotRenderer.render(context, chart);
encodeClientBehaviors(context, chart);
writer.write("},'charts');});");
endScript(writer);
}