1

I attempt to use <p:chart> with LineChartModel, but when I load the page, nothing is displayed and there is a JS error.

This is my model

@ManagedBean
@SessionScoped
public class InterfaceBean {

   private LineChartModel   model                   = new LineChartModel();

   @PostConstruct
   public void init()
   {
      this.drawInterfaceChart();
   }
   public void drawInterfaceChart(){

      model = initLineChartModel();
      model.setTitle("toto");
      model.setAnimate(true);
      model.setLegendPosition("se");
      Axis yAxis = model.getAxis(AxisType.Y);
      yAxis.setMin(0);
      yAxis.setMax(100);
   }


   private LineChartModel initLineChartModel(){
      LineChartModel model   = new LineChartModel();
      LineChartSeries series = new LineChartSeries();

      int limit = (listExecution.size() > 10) ? 10 : listExecution.size();

      for (int i=0; i<limit; i++) 
      {
        series.set("execution "+i, listExecution.get(i).getSuccessRate());
      }

      model.addSeries(series);
      return model;
   }

}

This is my view

<h:panelGrid columns="2" columnClasses="left,right" style="width:100%">
    <p:chart type="line" rendered="true" model="#{interfaceBean.model}" style="width:400px;" />
</h:panelGrid>

This is the JS error

Uncaught TypeError: Cannot read property 'LinearAxisRenderer' of undefined

After reading so many topics about this kind of problem, I added this on the web page

<h:outputStylesheet name="charts/charts.css" library="primefaces" />
<h:outputScript name="charts/charts.js" library="primefaces" />

But I still have the same JavaScript error and the lineChart is always not displayed.

How is this caused and how can I solve it?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Binou Dieng
  • 57
  • 2
  • 9
  • Are you manually including jQuery? Are you using another component library which also auto-includes jQuery? When unsure, check generated HTML `` element. – BalusC Jul 29 '15 at 09:05
  • Yes @BalusC, i have include some jquery libraries manually and that was the problem.I had removed most of them and it works fine now!:-) – Binou Dieng Aug 24 '15 at 09:36

0 Answers0