Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to create DataTable for ColumnChart by JSON object?
    text
    copied!<p>I'm trying to create a DataTable, with JSON as parameter, for a ColumnChart from the Google visualization api.</p> <p>I generated the following JSON object:</p> <pre><code>{ "cols": [ {"id":"date", "label":"date","pattern":"", "type":"date"}, {"id":"jobsonstatus", "label":"jobsonstatus", "pattern":"", "type":"number"} ], "rows": [ { "c": [ {"v": "01-02-2013", "f": null}, {"v": 128, "f": null} ] }, { "c": [ {"v": "08-02-2013", "f": null}, {"v": 185, "f": null} ] }, { "c": [ {"v": "15-02-2013", "f": null}, {"v": 142, "f": null} ] }, { "c": [ {"v": "22-02-2013", "f": null}, {"v": 86, "f": null} ] } ] } </code></pre> <p>What's wrong with this?</p> <p>Maybe it's something else. The rest of the code is:</p> <pre><code> var chart; //The chart var options; //The options for the chart var data; //The data inside the chart //This function will set up the actual chart but doesn't draw it. function init(){ chart = new google.visualization.ColumnChart(document.getElementById('chart_div')); options = { width:600, height:450, legend: {'position': 'top'}, allowHtml: true }; } function changeData(dataPar){ data = new google.visualization.DataTable(dataPar); drawChart(); } function drawChart(){ chart.draw(data, options); } </code></pre> <p>The JSON object is thrown in the function changeData().</p> <p>And i've got this in the ajax part:</p> <pre><code> dataType: "json", success: function(res, textStatus, jqXHR){ changeData(res); } </code></pre> <p>I'm getting an error with a red background:</p> <blockquote> <p>a[dc] is not a function</p> </blockquote> <p>Does anybody know what's going wrong and what should be the solution?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload