public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
Components.generateIdIfNotSpecified(component);
ResponseWriter writer = facesContext.getResponseWriter();
Chart chart = (Chart) component;
ChartView view = chart.getChartView();
if (!chart.isRendered() || view == null)
return;
writer.startElement("div", chart);
writeIdAttribute(facesContext, chart);
Rendering.writeComponentClassAttribute(writer, chart);
writer.writeAttribute("style", "width: " + chart.getWidth() + "px;" + " height:" + chart.getHeight() + "px;", "style");
String actionFiledId = chart.getClientId(facesContext) + MapRenderUtilities.ACTION_FIELD_SUFFIX;
Rendering.writeNewLine(writer);
Rendering.renderHiddenField(writer, actionFiledId, null);
Rendering.writeNewLine(writer);
BufferedImage image = chart.make();
final byte[] imageAsByteArray = Rendering.encodeAsPNG(image);
final JfcRenderHints renderHints = chart.getRenderHints();
final ChartRenderingInfo renderingInfo = renderHints.getRenderingInfo();
String mapId = renderHints.getMapId(chart);
String map = MapRenderUtilities.getImageMapExt(chart, mapId, renderingInfo,
new StandardToolTipTagFragmentGenerator(), new StandardURLTagFragmentGenerator());
renderHints.setMap(map);
if (view.getChartPopup() != null) {
encodeChartPopup(facesContext, chart, view, renderingInfo);
}
chart.setImageBytes(imageAsByteArray);
final Integer oldEntityIndex = chart.getEntityIndex();