I have queried data from an external source using python, created a
DataTable using the library using *gviz_api* and then transformed into json
by using the .ToJSon method, problem is that when trying to create a graph
out of this the error "This table has no columns" keeps rising.
Here is the rellevant part of my script.
schema = [('id2',), ('id3',), ('id1',)]
data_gviz=[['556', '556', '556\n']]
#Load into a gv.DataTable
data_table = gv.DataTable(schema)
data_table.LoadData(data_gviz)
# Create a JSON string.
json_data = data_table.ToJSon()
return json_data
-----------------------
<script type="text/javascript">
// Load the Visualization API and the scatterplot package.
google.charts.load('current', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var jsonData = $.ajax({
url: "getData.py",
dataType: "json",
async: false
}).responseText;
// Create our data table out of JSON data loaded from server.
var data = new google.visualization.DataTable(jsonData);
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById(
'chart_hbase'));
chart.draw(data, {width: 400, height: 240});
}
</script>
This error keeps appearing:
<https://lh3.googleusercontent.com/-tpzoxbQeQig/WbqjTh9VySI/AAAAAAAAGAI/U1jX9iatsOYGZwIij1A_rFBHNGyKHrEhACLcBGAs/s1600/Table_hasnocolumns.png>
Also I have tried to run as it is this example:
https://developers.google.com/chart/interactive/docs/php_example
and it doesnt seem to be working.
Any help is much appreciated.
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-visualization-api/569f04c8-e563-42b3-a8e5-e4be1288cf35%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.