Jump to content

Google PieChart


monkeytooth

Recommended Posts

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.

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/236417-google-piechart/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.