You could try replacing $(document).ready(function () {...}); with 
google.setOnLoadCallback(function () {...}); which would provide *similar* but 
not quite the same functionality.  Given the complexity of your set up, 
there could be issues with doing that.

Alternatively, you could wrap the drawing function inside another, which 
first loads the API and then issues the callback to draw when the API is 
loaded:

function initCharts (tbl) {
    google.load("visualization", "1", { packages: ["corechart"] });
    google.setOnLoadCallback(function () {
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Date');
        data.addColumn('number', 'Visiteurs');
        data.addRows(tbl.length);
        
        for (var i = 0; i < tbl.length; i++) {
        data.setValue(i, 0, tbl[i].date);
        data.setValue(i, 1, tbl[i].nbVisits);
        }
        
        var chart = new google.visualization.LineChart(document.
getElementById('chartDiv'));
        chart.draw(data, {
            left: 50,
            top: 0,
            width: 570,
            height: 330,
            chartArea: {
                left:80,
                top:20,
                width:500,
                height:250
            },
            legend: 'none',
            hAxis: {
                showTextEvery: 4
                /*, slantedText: true*/
            }
        });
    });
}

Then change all the drawChart(tbl) calls to initChart(tbl).  The loader is 
smart enough to know when the API has already been loaded, so when you call 
it a second time, it skips the loading and initiates the callback function 
again, so there should be little to no performance impact on your site.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-visualization-api/-/gg2LV85mv0QJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.

Reply via email to