<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: pe:gChart browser shows no content until refreshed</title><link>https://answers.axonivy.com/questions/2572/pe-gchart-browser-shows-no-content-until-refreshed</link><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;when loading a page with a pe:gChart my browser turns white and I get the following browser console error:&lt;/p&gt;
&lt;p&gt;"Uncaught Error: The container #form:j_id_6c:chartForm:gChart is not defined."&lt;/p&gt;
&lt;p&gt;After refreshing the page (F5) everything works fine, the chart is displayed correctly etc.&lt;/p&gt;
&lt;p&gt;Code:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; &amp;lt;h:form id="chartForm" style="text-align: center;"&amp;gt;
        &amp;lt;div id="gChartDiv"&amp;gt;
            &amp;lt;pe:gChart value="#{data.testModel}" title="Test"
                rendered="#{!data.noDataYet}" id="gChart"&amp;gt;
            &amp;lt;/pe:gChart&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/h:form&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Already posted on primefaces forums &lt;a title="here" href="https://forum.primefaces.org/viewtopic.php?f=14&amp;amp;t=50285&amp;amp;p=154488#p154488/"&gt;here&lt;/a&gt;, but since the pfe and pf versions are set in ivy they couldn't really help.&lt;/p&gt;
&lt;p&gt;Any idea on fixing this?&lt;/p&gt;
&lt;p&gt;Cheers&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/2572/pe-gchart-browser-shows-no-content-until-refreshed" rel="self"></atom:link><language>en</language><lastBuildDate>Thu, 06 Apr 2017 17:03:10 -0400</lastBuildDate><item><title>Answer by Alex Suter</title><link>https://answers.axonivy.com/questions/2572/pe-gchart-browser-shows-no-content-until-refreshed/2575</link><description>&lt;p&gt;This sample works in Ivy: &lt;a href="https://www.primefaces.org/showcase-ext/sections/gchart/basic.jsf;jsessionid=node0gzhije8myrwx1x5550c6oe8h0345257.node0"&gt;https://www.primefaces.org/showcase-ext/sections/gchart/basic.jsf;jsessionid=node0gzhije8myrwx1x5550c6oe8h0345257.node0&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I did the following:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;.xhtml&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;pe:gChart value="#{data.chartModel}" title="How Much Pizza I Ate Last Night"&amp;gt;
&amp;lt;/pe:gChart&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;data model&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;chartModel &amp;gt; org.primefaces.extensions.component.gchart.model.GChartModel&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Java class&lt;/strong&gt; &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;package test;
import java.util.Random;
import org.primefaces.extensions.component.gchart.model.GChartModel;
import org.primefaces.extensions.component.gchart.model.GChartModelBuilder;
import org.primefaces.extensions.component.gchart.model.GChartType;

public class ChartModelCreator  {

    private Random random = new Random();  
    private int mushrooms = random.nextInt(10);  
    private int onions = random.nextInt(10);  
    private GChartModel chartModel = null;

    public ChartModelCreator() {  
        chartModel = new GChartModelBuilder()
                .setChartType(GChartType.PIE)  
                .addColumns("Topping", "Slices")
                .addRow("Mushrooms", mushrooms)  
                .addRow("Onions", onions)
                .build();  
    }

    public GChartModel getChartModel(){  
        return chartModel;  
    }

}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;ivy logic&lt;/strong&gt;
Directly after start() make an ivy script step, which applys&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import test.ChartModelCreator;
ChartModelCreator creator = new ChartModelCreator();
in.chartModel = creator.getChartModel();
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;How das your model look like? Which browser version do you use?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Alex Suter</dc:creator><pubDate>Thu, 06 Apr 2017 17:03:10 -0400</pubDate><guid>https://answers.axonivy.com/questions/2572/pe-gchart-browser-shows-no-content-until-refreshed/2575</guid></item></channel></rss>