java - no data in google charts line chart -


ajaxpost(action, "getdata", params, function(data) { var response = toobject(data).response; var chartdata = new google.visualization.datatable();  var array = [];      for(var = 0; < response.occdata.length; i++){         var data = [];          for(var j = 1; j < 32; j++){             array.push(response.occdata[i].daylist[j]);         }         chartdata.addcolumn("string",array);     }      new google.visualization.linechart(document.getelementbyid('chart_div')).         draw(chartdata, {vaxes:[         {title: 'title 1', titletextstyle: {color: '#ff0000'}}, // left axis         {title: 'title 2', titletextstyle: {color: '#ff0000'}} // right axis         ],series:[             {targetaxisindex:1},             {targetaxisindex:0}         ],curvetype: "function",width: 700, height: 240});             $("#" + "chart_div").fadein(2000); 

});

i'm using above code draw line chart! chart not drawn , states no data. i'm using ajax response , data passed too. no firebug errors , following response.! please me!

{"response": {"status":true , "occdata":[{"daylist":{1:9.0,2:6.0,3:4.0,4:4.0,5:3.0,6:3.0,7:3.0,8:3.0,9:3.0,10:7.0,11:7.0,12:6.0,13:4.0,14:4.0,15:4.0,16:4.0,17:3.0,18:3.0,19:4.0,20:6.0,21:7.0,22:6.0,23:7.0,24:6.0,25:5.0,26:8.0,27:9.0,28:7.0,29:8.0,30:8.0,31:5.0},"hotelcode":"bbh","month":"may","monthstartdate":"may-2012","orderseq":11,"reservationrowtype":"rev_occ_per","total":5.4,"year":"2012"},{"daylist":{1:52368.0,2:87239.0,3:126683.0,4:126683.0,5:147851.0,6:147851.0,7:147851.0,8:147851.0,9:147851.0,10:72566.0,11:66706.0,12:87915.0,13:110090.0,14:110090.0,15:110090.0,16:110090.0,17:147851.0,18:147851.0,19:126729.0,20:104461.0,21:95655.0,22:104562.0,23:88476.0,24:100402.0,25:111558.0,26:65367.0,27:61136.0,28:75780.0,29:70367.0,30:70367.0,31:111558.0},"hotelcode":"bbh","month":"may","monthstartdate":"may-2012","orderseq":13,"reservationrowtype":"arr","total":96370.0,"year":"2012"}]}} 

you not creating datatable object, creating array.

you need create datatable object following code first:

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

after you've created datatable, assuming array contains format able parsed google visualization, need pass in using 1 of following:

  1. a for loop data.addcolumn , data.addrow
  2. a for loop data.setvalue
  3. google.visualization.arraytodatatable()

currently doing none of these, google has no datatable pass chart.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -