Forum Discussion
Hi Emil,
The blog post linked to above can be found here. However, please note that it's quite old, and I don't believe it covers running google chart inside a report like this.
I was able to reproduce the issue that you're seeing in one of my local instances. The underlying issue for seemed to be that the google.charts.load function that we call at the top would never indicate that it had finished loading, so my callback function never ran to actually draw the chart.
I was able to resolve this in a roundabout way by instead manually checking within my drawChart() function if each piece had been loaded. If not, I would set a timeout to wait a bit and check again later like the sample code below. Also note that i was using the sample code found here to just render a static pie chart. You'll need to update the checks in your code to instead look for the Gantt constructor.
function drawChart() {
// Check that everything is loaded
if (!google.visualization || !google.visualization.DataTable || !google.visualization.PieChart) {
// If not, wait 50 ms and try again
setTimeout(drawChart, 50);
return;
}
// Define the chart to be drawn.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Element');
data.addColumn('number', 'Percentage');
data.addRows([
['Nitrogen', 0.78],
['Oxygen', 0.21],
['Other', 0.01]
]);
// Instantiate and draw the chart.
var chart = new google.visualization.PieChart(document.getElementById('myPieChart'));
chart.draw(data, null);
}
google.charts.load('current', {packages: ['corechart']});
// Manually call our drawChart() function
drawChart();
Chris
Christopher Gillis
Aras Labs Software Engineer
Thank you Christopher. This workaround is working fine for me as well.
Great support! Fast and verry helpful. :-)
//Emil