I'm new with google-visualization. I'm developing a full dashboard like google full dashboard example
Following the example I declare data like this:
var data = google.visualization.arrayToDataTable([
['CodiceCliente', 'Cliente', 'QtàO13', 'QtàO14','UM'],
['0000038893', 'Coop',300,350, 'CT'] .... ]);
Now I want to load data from server. I create a Json like this:
{
"cols": [
{"id": "codiceCliente","label": "Cod. Cliente","type": "string"},
{"id": "clienteDesc","label": "Cliente","type": "string"},
{"id": "qtaO13","label": "Qtà O13","type": "number"},
{"id": "qtaO14","label": "Qtà O14","type": "number"},
{"id": "um","label": "UM","type": "string"}
],
"rows": [
{
"c": [
{"v": "0000038893"},
{"v": "Coop"},
{"v": "300"},
{"v": "350"},
{"v": "CT"} ]
},
{.... }, ... ]}
In html page i use this code to get data from server:
var jsonData = $.ajax({
url: "getJson.do",
dataType:"json",
async: false
}).responseText;
var data = google.visualization.DataTable(jsonData);
When I open the page, I get this error: " Object # has no method 'zg' at format+it,default+it,ui+it,controls+it,corechart+it.I.js:183 "
where am I wrong? JSON format is wrong?
Use your JSON REST URL to visualize. Click on the Load URL button, Enter URL and Submit. Users can also visualize JSON in graph by uploading the JSON file. JSON Visualizer works well on Windows, MAC, Linux, Chrome, Firefox, Edge, and Safari.
Double-click the chart you want to change. At the right, click Setup. Select the cells you want to include in your chart. Optional: To add more data to the chart, click Add another range.
Reading CSV files If you want to build a chart out of CSV (comma-separated values) data, you have two choices: Convert the data into the Google Charts datatable format. Place the CSV file on the web server serving the chart, and query it using the technique on this page.
You are missing the new
keyword in the DataTable constructor. It should be:
var data = new google.visualization.DataTable(jsonData);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With