1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
/*
* 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 com.appGestionIntervention.JsfClasses;
import com.intervention.jsf.beans.intervenant;
import java.io.Serializable;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.persistence.EntityManager;
import org.primefaces.model.chart.ChartSeries;
import org.primefaces.model.chart.CartesianChartModel;
import org.primefaces.model.chart.PieChartModel;
import javax.persistence.PersistenceContext;
/**
*
* @author pc_ahmed
*/
import javax.persistence.PersistenceContext;
@ManagedBean
@SessionScoped
public class ChartsControlle implements Serializable{
@PersistenceContext(unitName = "AppGestionInterventionPU")
private EntityManager em;
private List<InterventionController> intervention;
private PieChartModel pieModel;
private CartesianChartModel categoryModel;
public ChartsControlle(){
pieModel = new PieChartModel();
pieModel.set("", 0);
categoryModel = new CartesianChartModel();
ChartSeries ser = new ChartSeries();
ser.set("", 0);
categoryModel.addSeries(ser);
}
public void chaajum(){
pieModel = new PieChartModel();
categoryModel = new CartesianChartModel();
ChartSeries ser = new ChartSeries();
ser.setLabel("SERIE");
List<Object[]> pielist= ( List<Object[]>)
em.createQuery("select numero_reclamation,matricule_intervenant,etat,count(numero_intervention) as numero from intervention m group by numero_reclamation order by count(numero_intervention) desc").getResultList();
if(pielist!=null){
for(Object[] pie: pielist){
pieModel.set((String) pie[0], (Number) pie[1]);
ser.set((String) pie[0], (Number) pie[1]);
}
categoryModel.addSeries(ser);
}
}
public PieChartModel getPieModel() {
return pieModel;
}
public CartesianChartModel getCategoryModel() {
return categoryModel;
}
public void setPieModel(PieChartModel pieModel) {
this.pieModel = pieModel;
}
public void setCategoryModel(CartesianChartModel categoryModel) {
this.categoryModel = categoryModel;
}
} |
Partager