3 Replies - 468 Views - Last Post: 09 July 2013 - 06:57 AM

#1 FireFly91  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 30
  • Joined: 09-November 10

Graph trouble

Posted 09 July 2013 - 06:05 AM

Hey, I'm having a little bit of trouble getting the google chart's graphs working on a webpage. I'm not really sure what I've done wrong or am missing. Basically I want to have multiple charts on the one page. For the moment I have two graphs on the page, but nothing is showing up at all when I load the webpage. Any and all help would be very much appreciated.

Thanks in advance!

The JS:
// Load the Visualization API and the piechart package.
    google.load('visualization', '1', {'packages':['columnchart','piechart']});
    
    // Set a callback to run when the Google Visualization API is loaded.
    
	google.setonloadCallback (createChart);
	
    // Callback that creates and populates a data table, 
    // instantiates the pie chart, passes in the data and
    // draws it.
    function createChart() {

		// Create the data table. Pie Chart
		var dataPie = new google.visualization.DataTable();
		
		dataPie.addColumn('string', 'Activity');
		dataPie.addColumn('number', 'Percentages');
		
		dataPie.addRows([['Onsite', 20], ['Remote - PE Delivery', 34], ['Enterprise Support', 53], ['Backoffice', 43], ['Deployment Room', 21], ['Project/Development/coW', 20], ['TQM', 3], ['Teaching/Mentoring', 5], ['Training', 41], ['Mgmt/Admin', 6], ['Out of Office', 17]]);
		
		//Create data table for column graph
		var dataBar = new google.visualization.DataTable();
		
			dataBar.addColumn('string', 'Year');
			dataBar.addColumn('number', 'Sales');
			dataBar.addColumn('number', 'Expenses');
			
			dataBar.addRows([['2004', 1000, 400], ['2005', 1170, 460], ['2006', 660, 1120], ['2007', 1030, 540]]);

		// Instantiate and draw our chart, passing in some options.
		var chartBar = new google.visualization.ColumnChart(document.getElementById('chart_div2'));
		var chartPie = new google.visualization.PieChart(document.getElementById('chart_div'));
		
		// Set chart options
		var optionsPie = {title:'Weekly Utlization Graph', width:800, height:400};
					 
		var optionsBar = {title: 'Company Performance'};
		
		chartPie.draw(dataPie, optionsPie);
		chartBar.draw(dataBar, optionsBar);
		
		}
	}


Is This A Good Question/Topic? 0
  • +

Replies To: Graph trouble

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6037
  • View blog
  • Posts: 23,432
  • Joined: 23-August 08

Re: Graph trouble

Posted 09 July 2013 - 06:07 AM

Do you receive any errors in the Javascript console?
Was This Post Helpful? 0
  • +
  • -

#3 FireFly91  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 30
  • Joined: 09-November 10

Re: Graph trouble

Posted 09 July 2013 - 06:19 AM

No, no errors form the console.
Was This Post Helpful? 0
  • +
  • -

#4 FireFly91  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 30
  • Joined: 09-November 10

Re: Graph trouble

Posted 09 July 2013 - 06:57 AM

Problem solved. Had an extra '}'. D'oh :whistling: It's been a long day
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1