I have problem with Invalid data table format: must have at least 2 columns. error from my code. I know there's an answer here but it's not for me.
I grabbed the idea of ajax from google but it's for pie chart. Later I found this link seems to be useful. Again, as I follow the instruction from the page - unlucky me.
Json
[
["Time","Order","Delivered","Income"],
["00:00",52327,0,52327],
["04:00",39703,0,39703],
["08:00",189949,0,189949],
["12:00",209406,0,209406],
["16:00",134622,0,134622],["20:00",121045,0,121045]
]
JS
google.charts.load('current', {
'packages': ['bar']
});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var jsonData = $.ajax({
url: "https://paste-bin.xyz/raw/12684",//ajax data
dataType: "json",
async: false
}).responseText;
// Create our data table out of JSON data loaded from server.
var data = new google.visualization.DataTable(jsonData);
var chart = new google.charts.Bar(document.getElementById('chart1'));
chart.draw(data);
}
According to the reference in both google and the tutorial, it should working. I also make a fiddle version here : https://jsfiddle.net/c3sd61rv/ (classic version here : https://jsfiddle.net/y5o7L0dn/1/)