/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Bean;
import javax.annotation.PostConstruct;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import org.primefaces.model.chart.Axis;
import org.primefaces.model.chart.AxisType;
import org.primefaces.model.chart.BarChartModel;
import org.primefaces.model.chart.HorizontalBarChartModel;
import org.primefaces.model.chart.ChartSeries;
import javax.annotation.PostConstruct;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import org.primefaces.model.chart.Axis;
import org.primefaces.model.chart.AxisType;
import org.primefaces.model.chart.BarChartModel;
import org.primefaces.model.chart.LineChartModel;
import org.primefaces.model.chart.ChartSeries;
import org.primefaces.model.chart.LineChartSeries;
@ManagedBean
public class ChartView implements Serializable {
private LineChartModel animatedModel1;
private BarChartModel animatedModel2;
private BarChartModel animatedModel3;
private BarChartModel animatedModel4;
@PostConstruct
public void init() {
createAnimatedModels();
}
public LineChartModel getAnimatedModel1() {
return animatedModel1;
}
public BarChartModel getAnimatedModel2() {
return animatedModel2;
}
public BarChartModel getAnimatedModel3() {
return animatedModel3;
}
public BarChartModel getAnimatedModel4() {
return animatedModel4;
}
private void createAnimatedModels() {
animatedModel1 = initLinearModel();
animatedModel1.setTitle("Line Chart");
animatedModel1.setAnimate(true);
animatedModel1.setLegendPosition("se");
Axis yAxis = animatedModel1.getAxis(AxisType.Y);
yAxis.setMin(0);
yAxis.setMax(10);
animatedModel2 = initBarModel();
animatedModel2.setTitle("RMPs abertas por unidade");
animatedModel2.setAnimate(true);
yAxis = animatedModel2.getAxis(AxisType.Y);
yAxis.setMin(0);
yAxis.setMax(200);
animatedModel3 = initBarModel2();
animatedModel3.setTitle("RMPs direcionadas por unidade");
animatedModel3.setAnimate(true);
yAxis = animatedModel3.getAxis(AxisType.Y);
yAxis.setMin(0);
yAxis.setMax(200);
animatedModel4 = initBarModel3();
animatedModel4.setTitle("RMPs por status");
animatedModel4.setAnimate(true);
yAxis = animatedModel4.getAxis(AxisType.Y);
yAxis.setMin(0);
yAxis.setMax(200);
}
private BarChartModel initBarModel() {
BarChartModel model = new BarChartModel();
ChartSeries boys = new ChartSeries();
boys.set("Auditoria", 120);
boys.set("Secretaria", 100);
boys.set("Operacional", 44);
boys.set("Finanças", 150);
boys.set("T.I", 25);
model.addSeries(boys);
return model;
}
private BarChartModel initBarModel2() {
BarChartModel model = new BarChartModel();
ChartSeries boys2 = new ChartSeries();
boys2.set("Auditoria", 10);
boys2.set("Secretaria", 40);
boys2.set("Operacional", 12);
boys2.set("Finanças", 15);
boys2.set("T.I", 25);
model.addSeries(boys2);
return model;
}
private BarChartModel initBarModel3() {
BarChartModel model = new BarChartModel();
ChartSeries boys3 = new ChartSeries();
boys3.set("Pendente", 10);
boys3.set("Respondida", 40);
boys3.set("Não procede", 12);
boys3.set("Concluída e eficaz", 15);
boys3.set("Concluída e ineficaz", 25);
model.addSeries(boys3);
return model;
}
private LineChartModel initLinearModel() {
LineChartModel model = new LineChartModel();
LineChartSeries series1 = new LineChartSeries();
series1.setLabel("Series 1");
series1.set(1, 2);
series1.set(2, 1);
series1.set(3, 3);
series1.set(4, 6);
series1.set(5, 8);
LineChartSeries series2 = new LineChartSeries();
series2.setLabel("Series 2");
series2.set(1, 6);
series2.set(2, 3);
series2.set(3, 2);
series2.set(4, 7);
series2.set(5, 9);
model.addSeries(series1);
model.addSeries(series2);
return model;
}
}