I am getting a json string from the response. How can I create a data table from that?
e.g.
var jasonString = "..........";
var data = new google.visualization.DataTable(jasonString);
In some cases, you might see a JavaScript literal or JSON version of a DataTable used, for instance when data is sent over the Internet by a Chart Tools Datasource, or as a possible input value for a ChartWrapper. A DataTable is used to create the original data table.
This is only for a very special case of JSON string. If you have a random JSON object and you'd like to show it in a DataTable, then convert to an array first. See stackoverflow.com/questions/20881213/… Show activity on this post. According to this page it says you can just put the JSON response directly into google.visualization.DataTable
If you change values in a DataTable after it is passed into a visualization's draw () method, the changes will not immediately change the chart. You must call draw () again to reflect any changes. Note: Google Charts does not perform any validation on datatables.
The DataTable object is used to hold the data passed into a visualization. A DataTable is a basic two-dimensional table. All data in each column must have the same data type.
You can use the function arrayToDataTable
var jsonString = ".........."; // json string of array
var array = JSON.parse(jsonString);
var dataTableData = google.visualization.arrayToDataTable(array);
// use dataTableData to build dataTable
According to this page it says you can just put the JSON response directly into google.visualization.DataTable
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