I think that the order of your page generation is wrong.
Try to move your function and its reference to the head section, also see if
you can create a table function which is already generated, thus you'll be
able to assign the LineChart the data.
Something in the form of:

var data = new google.visualization.DataTable(
     {
       cols: [{id: 'data', label: 'Date', type: 'string'},
              {id: 'nbVisits', label: 'Visiteurs', type: 'number'}],
       rows: [{c:[{v: 'Apr-04'}, {v: 4245}]},
              {c:[{v: 'May-02'}, {v: 20327}]},
              {c:[{v: 'May-30'}, {v: 18599}]},
              {c:[{v: 'Hune-27'}, {v: 17196}]},
              {c:[{v: 'Jul-25'}, {v: 19483}]}
             ]
     },
   0.6
)


See if this will help. I know that I'm using this method and it works.


On Wed, Oct 5, 2011 at 9:11 PM, asgallant <[email protected]> wrote:

> 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.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
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