Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle charts api after ajax call
    primarykey
    data
    text
    <p>I've got a problem with the visualization of data with google's charts api after an ajax call.</p> <p>First I made an ajax call and fetched a json object. After that I want to extract some data out of the json and draw a gauge chart. Getting the json and extracting the data works fine, but when I try to load the chart, the body gets removed and I get a blank/white screen. Does anyone knows what I am doing wrong? I also tried to hard code values for the chart instead of taking the json values (but kept the ajax call before loading the chart), but it didn't work neither.</p> <pre><code>function loadStats(){ var http = getRequestObject(); var city = "berlin"; http.open("GET", "getTwitterSentiments.php?city="+city, true); http.onreadystatechange=function() { getStatistic(http) }; http.send(null); } function getStatistic(request) { if ((request.readyState == 4) &amp;&amp; (request.status == 200)) { var data = request.responseText; var JSONStats = eval("(" + data + ")"); loadGauge(JSONStats.sentiment_index); } function loadGauge(sentiment){ google.load('visualization', '1', {packages:['gauge']}); google.setOnLoadCallback(drawGauge); function drawGauge() { var data = google.visualization.arrayToDataTable([ ['Label', 'Value'], ['Test', sentiment] ]); var options = { width: 100, height: 100, redFrom: 0, redTo: 45, yellowFrom: 45, yellowTo: 55, greenFrom: 55, greenTo: 100, minorTicks: 10 }; var chart = new google.visualization.Gauge(document.getElementById('testgchart')); chart.draw(data, options); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload