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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.