Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2009-2013 PrimeTek.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.primefaces.component.chart.line;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import org.primefaces.component.chart.BaseChartRenderer;
import org.primefaces.component.chart.UIChart;
import org.primefaces.model.chart.CartesianChartModel;
import org.primefaces.model.chart.ChartSeries;
import org.primefaces.model.chart.LineChartSeries;
public class LineChartRenderer extends BaseChartRenderer {
@Override
public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
LineChart chart = (LineChart) component;
encodeMarkup(context, chart);
encodeScript(context, chart);
}
protected void encodeScript(FacesContext context, UIChart uichart) throws IOException{
ResponseWriter writer = context.getResponseWriter();
LineChart chart = (LineChart) uichart;
String clientId = chart.getClientId(context);
startScript(writer, clientId);
writer.write("$(function(){");
writer.write("PrimeFaces.cw('LineChart','" + chart.resolveWidgetVar() + "',{");
writer.write("id:'" + clientId + "'");
encodeData(context, chart);
encodeOptions(context, chart);
encodeClientBehaviors(context, chart);
writer.write("},'charts');});");
endScript(writer);
}
protected void encodeData(FacesContext context, LineChart chart) throws IOException {
ResponseWriter writer = context.getResponseWriter();
CartesianChartModel model = (CartesianChartModel) chart.getValue();
List categories = chart.getCategories();
boolean hasCategories = !categories.isEmpty();
//data
writer.write(",data:[" );
for(Iterator it = model.getSeries().iterator(); it.hasNext();) {
ChartSeries series = it.next();
writer.write("[");
for(Iterator