monkeytooth Posted May 14, 2011 Share Posted May 14, 2011 Im trying to create a pie chart on the fly with data retrieved from a xls spreadsheet. The spread sheet data I have pulling and forming inside of a JSON string currently and that works fine. My issue is somewhere with attempting to dynamicly form the data for the piechart to draw with. If I add the data staticly it works fine, if I do it through the loop I will show below it fails.. data.addColumn('string', 'Name'); data.addColumn('number', 'Count'); var myRows = '' for(x=0;x<displayJSON.totalRows;x++) { if(x != displayJSON.totalRows && x != 0){myRows +=",";} myRows += "['"+displayJSON['figures'][x][1]+"', "+displayJSON['figures'][x][0]+"]"; } data.addRows([myRows]); var chart = new google.visualization.PieChart(document.getElementById('chart_div')); chart.draw(data, {width: 750, height: 750, title: displayTitle}); I'm not sure where the snag is per say.. heres where my little rendition is.. http://mtpdev.com/dev/xls-reader/ heres the google chart reference I am attempting to follow.. http://code.google.com/apis/chart/interactive/docs/quick_start.html in concept everything is forming properly I have confirmed that, just something specific to data.addRows([myRows]); is not liked when its all rendered. Quote Link to comment https://forums.phpfreaks.com/topic/236417-google-piechart/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.