CLEYSON
O erro deve estar aqui …
rendered="#{not empty analiseBean.qtdtotalboletos}"/>
O rendered deve ser booleano (true/false)
Diego_Adriano
Então … O gráfico chega a ser exibido … porém vazio, sem as linhas …
Veja a imagem
build_successful
Diego, vc verificou com o debug se realmente os gets “getQtdvencidos() e getValorvencidos()” estão trazendo algum valor!?
Diego_Adriano
Sim, estão sim … e só pra confirmar eu dei um PrintLn e estão lá …
CLEYSON
Fiz algumas modificações e testei com sucesso ....
Segue pra exemplo
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<body>
<h:form id="formPrincipal" prependId="false" ><!---->
<p:growl id="grow" showDetail="true"/>
<p:panel header="Gráfico">
<h:form id="formDados">
<h:panelGrid columns="2">
<p:lineChart id="linha" value="#{analiseBean.linearModel}" legendPosition="e"
title="Boletos" minY="0" maxY="50" style="height:300px"
rendered="#{not empty analiseBean.qtdtotalboletos}"/>
<p:commandButton value="Gerar" action="#{analiseBean.gerarAnalise}" ajax="false"
update="formDados"/>
</h:panelGrid>
</h:form>
</p:panel>
</h:form>
</body>
</html>
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import org.primefaces.model.chart.CartesianChartModel;
import org.primefaces.model.chart.LineChartSeries;
@ManagedBean
@ViewScoped
public class AnaliseBean implements Serializable {
private int qtdtotalboletos=0;
private CartesianChartModel linearModel;
public AnaliseBean() {
createLinearModel();
}
public CartesianChartModel getLinearModel() {
return linearModel;
}
private void createLinearModel() {
linearModel = new CartesianChartModel();
System.out.println("GRAFICO");
LineChartSeries series1 = new LineChartSeries();
series1.setLabel("Total Boletos");
//System.out.println(""+getQtdtotalboletos()+"| "+ getValortotalboletos());
series1.set(20, 10);
LineChartSeries series2 = new LineChartSeries();
series2.setLabel("Total Vencidos");
//System.out.println(""+getQtdvencidos()+"| "+ getValorvencidos());
series1.set(12, 6);
linearModel.addSeries(series1);
linearModel.addSeries(series2);
}
public String gerarAnalise(){
getLinearModel().getSeries().get(0).set(15, 15);
getLinearModel().getSeries().get(1).set(5, 6);
return "";
}
/*private void createLinearModel() {
linearModel = new CartesianChartModel();
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.setMarkerStyle("diamond");
series2.set(1, 6);
series2.set(2, 3);
series2.set(3, 2);
series2.set(4, 7);
series2.set(5, 9);
linearModel.addSeries(series1);
linearModel.addSeries(series2);
}*/
/**
* @return the qtdtotalboletos
*/
public int getQtdtotalboletos() {
return qtdtotalboletos;
}
/**
* @param qtdtotalboletos the qtdtotalboletos to set
*/
public void setQtdtotalboletos(int qtdtotalboletos) {
this.qtdtotalboletos = qtdtotalboletos;
}
}
Como o build_successful disse verificar os gets e se estão dentro do intervalo mínimo e máximo ...
Verifica se o Bean implementa a classe Serializable
joelson123
Teria como demonstrar como traz as informações do banco e utiliza ela no grafico.