javascript - Data not showing up in Google Chart -


i've looked @ every thread find on how json feed google chart, nothing seems working or threads different problem.

update: i'm trying parse json feed show columns. example, feed has actual , goal column. want chart show actual column. need goal column filtering reasons on end, when feed updates database knows records pull.

after following json format google charts , figuring out way add data, i'm still unsuccessful in getting actual data show up. what's weird graph shows up, doesn't have data in it. no errors in console.i've made sure json string valid, is. i've tried logging json feed make sure information being passed correctly , is. columns added, in code, rows won't show up.

i believe in data.addrow line, i'm not traversing correctly, can't seem figure out how correctly down specific cell.

function drawchart() {       $.ajax({       url: "--",       datatype:"json",       success: function (result) {         var data = new google.visualization.datatable();         data.addcolumn('string', 'quarter');          data.addcolumn('number', 'actual');           (var = 0; < result.rows.length; i++) {           data.addrow([result.rows[i], result.rows[i], result.rows[i]]);         } 

here json feed:

{ "cols":[ {"label":"quarter", "type":"string"},{"label": "actual", "type":"number"}, {"label":"goal","type":"number"}], "rows":[ {"c":[{"v":"q1"}, {"v":22}, {"v":30}]},   {"c":[{"v":"q2"}, {"v":24}, {"v":30}]},   {"c":[{"v":"q3"}, {"v":27}, {"v":30}]}  ]}  

you build datatable raw json:

var data = new google.visualization.datatable(json); 

and use dataview filter out "goal" column:

var view = new google.visualization.dataview(data); view.setcolumns([0, 1]); 

draw chart using dataview instead of datatable:

chart.draw(view, options); 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -