Google chart "Table has no columns" Google chart "Table has no columns" json json

Google chart "Table has no columns"


Your loadData function doesn't return anything, so the json variable is null. I would suggest a slight reorganization of your code to get the effect you want:

function drawChart (json) {    var data = new google.visualization.DataTable(json);    var options = {        vAxis: {minValue: 0}    };    var chart = new google.visualization.AreaChart(document.getElementById('chart_div'));    chart.draw(data, options);}function loadData () {    var request=new XMLHttpRequest();    request.onreadystatechange = function() {        if (request.readyState == 4 && request.status == 200) {            drawChart(request.responseText);        }    }    request.open("GET","testsrun.php?json=true&branch=test",true);    request.send();}google.load('visualization', '1', {packages:['corechart'], callback: loadData});

Also, the numbers in your JSON are being input as strings, which will cause problems with your charts. You need to input them as numbers, eg. {"v":"0"} should be {"v":0}. If you are using PHP's json_encode function to build your JSON, you can pass JSON_NUMERIC_CHECK as a second argument to the function call to make sure your numbers are input correctly:

json_encode($myData, JSON_NUMERIC_CHECK);