Note that there are some explanatory texts on larger screens.

plurals
  1. POChart is not displaying using google chart
    primarykey
    data
    text
    <p>Hi I am using google charts to display a chart but it is not displaying a chart. I can see the json printed as well in the firbug console but still chart is not displaying. Below is my code</p> <pre><code>function drawChart() { $.ajax({ url: ipaddress+'/getSpecificFields', dataType: "json", success: function (jsonData) { alert('success'); if (!$.browser.msie) { console.log(jsonData); } // Create our data table out of JSON data loaded from server. var data = new google.visualization.DataTable(jsonData); data.addColumn("string", "abc"); data.addColumn("string", "cde"); data.addColumn("string", "fgh"); data.addRows(jsonData.length); var i = 0; $.each(jsonData, function () { data.setValue(i, 0, this.abc); data.setValue(i, 1, this.cde); data.setValue(i, 2, this.fgh); i++; }); // Instantiate and draw our chart, passing in some options. var chart = new google.visualization.PieChart(document.getElementById('chart_div')); chart.draw(data, { width: 400, height: 240 }); }, error: function (jqXHR, textStatus, errorThrown) { alert(textStatus + '\n' + errorThrown); if (!$.browser.msie) { console.log(jqXHR); } } }); }} </code></pre> <p>json which is returning from the server</p> <pre><code>[Object { abc="leave, cde="80%", fgh="52b83880a36dcda423000001"}, Object { abc="Meeting", cde="60%", fgh="52b83880a36dcda423000002"}, Object { abc="Work", cde="70%", fgh="52b83880a36dcda423000003"}] </code></pre> <p>from browser e.g localhost:3000/something</p> <pre><code>[ { "abc": "Work", "cde": "50%", "ghe": "1", }, { "cde": "50%", "abc": "Sick", "ghe": "2" }, { "abc": "Some", "cde": "50%", "ghe": "3", } ] </code></pre> <p>and server side code in node js</p> <pre><code>var jsonString = []; var jsonParse; test.find({abc:1,cde:1,ghe:1},function (err, list, count) { if (err) throw(err); list.forEach(function(listLoop){ jsonParse = JSON.parse(JSON.stringify(listLoop)); console.log("jsonParse " + JSON.stringify(listLoop)); jsonString.push(jsonParse); }); res.json(jsonString); }); </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.
    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