First, you should not have two callbacks from the google loader. Use a
single callback that then calls the two draw functions:
google.setOnLoadCallback(function () {
drawChart();
drawChartSales();
});
Fix that and then see if the error persists. If you are still having
problems, post the full code along with a sample of the contents of
sChartData.
On Monday, February 24, 2014 9:52:58 AM UTC-5, Vikas Parab wrote:
>
> Hi Everybody,
>
> I am showing two google line chart on page and they works fine.
>
> Only problem is that, in Firefox Browser console, I am getting error
> saying,
>
> TypeError: chart is undefined (for one chart.)
>
> For other chart also showing same error
>
> TypeError: chart1 is undefined
>
> Few parts of my code:
>
> google.load("visualization", "1", { packages: ["corechart"] });
> google.setOnLoadCallback(drawChart);
> google.setOnLoadCallback(drawChartSales);
>
> function drawChartSales() {
> var sChartData = document.getElementById("chartDataSales").value;
>
> var data = google.visualization.arrayToDataTable(eval(sChartData));
>
> var options1 = {
>
> backgroundColor: "#ccc"
> , colors: ['red', 'green', 'blue', 'yellow', 'orange']
> , vAxis: {
> baselineColor: '#fff'
> , gridlineColor: '#fff'
>
> //, format: "$#,###"
> },
> hAxis: {
> baselineColor: '#f00'
> }
> };
>
> var formatter = new google.visualization.NumberFormat({ prefix:
> '$' });
> formatter.format(data, 1);
> formatter.format(data, 3);
> formatter.format(data, 5);
> formatter.format(data, 7);
> formatter.format(data, 9);
>
> var chart1 = new
> google.visualization.LineChart(document.getElementById('saleschart_div')).draw(data,
> {
> series: {// set the options for all series
> 0: { lineWidth: 1, pointSize: 5 },
> 1: { lineWidth: 1, pointSize: 5 },
> 2: { lineWidth: 1, pointSize:
> 5/*,visibleInLegend: false*/ },
> 3: { lineWidth: 1, pointSize: 5 },
> 4: { lineWidth: 1, pointSize: 5 }
> }
> , title: 'Sales Tracker'
> , vAxis: { format: "$#,###" }
>
> });
>
> chart1.draw(data, options1);
> }
>
> Code for other chart is also same except div id and chart variable. (above
> is chart1 and other is only chart)
>
> Please guide how I can remove those error from error console.
>
> Thanks,
>
>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.