public function buildChart($oAnalytics) {
		
			require_once 'lib/google_chart.php'; // By Andrey Savchenko (Rarst), http://www.rarst.net/script/google-chart/
			
			
			// Generating visit arrays for the date range.
			 $visit_report = $oAnalytics->getData(
			 	array('dimensions'=>urlencode('ga:date'),
			 	'metrics'=>urlencode('ga:visits'),
			 ));
			 
			 
			 $visits = array();
			 foreach($visit_report as $dimensions => $metric) {
			 	array_push($visits, $metric);
			 }
			 
			 // Generating visit arrays for the date range.
			  $views_report = $oAnalytics->getData(
			  	array('dimensions'=>urlencode('ga:date'),
			  	'metrics'=>urlencode('ga:pageviews'),
			  ));
			  
			  
			  $page_views = array();
			  foreach($views_report as $dimensions => $metric) {
			  	array_push($page_views, $metric);
			  }
			
			// Extract various dates from the report array keys in order to use them as variables for x-axis labels
			$days = array_keys($views_report);
			list($d0, $d1, $d2, $d3, $d4, $d5, $d6, $d7, $d8, $d9, $d10, $d11, $d12, $d13,
			$d14, $d15, $d16, $d17, $d18, $d19, $d20, $d21,$d22,$d23,$d24,$d25,$d26,$d27,$d28, $d29, $d30) = $days;
			
			
			// Get the keys for max. values of page views and visits
			if( !function_exists('max_key') ){
			 function max_key($array) {
			  foreach ($array as $key => $val) {
			   if ($val == max($array)) return $key;
			  }
			 }
			}
			$array = $page_views;
			$precord = max_key($array);
			$array = $visits;
			$vrecord = max_key($array);
			
			// Always use max. value recorded in array for y-axis
			$ymax = 1*(ceil(max($page_views)));
			// Devide it by six and round up to nearest whole number to set appropriate y-axis ticks
			$ytick = ceil((max($page_views))/6);
			
			// Chart settings
			$traffic = new GoogleChart;
			$traffic->type='lc';
			$traffic->SetImageSize(700,200);
			$traffic->SetChartMargins(20,20,20,20);
			$traffic->SetEncode('simple');
			$traffic->AddData($visits);
			$traffic->AddData($page_views);
			
			$traffic->AddChartColor('FF9900');
			$traffic->AddChartColor('0077CC');
			
			$traffic->AddLineStyle(3);
			$traffic->AddLineStyle(3);

			
			$traffic->AddFillArea('B','FF99007F',0);
			$traffic->AddFillArea('b','E6F2FA7F',0,1);
			
			$traffic->AddShapeMarker('o','FFFFFF',0,-1,9);
			$traffic->AddShapeMarker('o','FF9900',0,-1,7);
			$traffic->AddShapeMarker('o','FFFFFF',1,-1,9);
			$traffic->AddShapeMarker('o','0077CC',1,-1,7);

			
			$traffic->AddAxis('y,x');
			$traffic->AddAxisRange(0,round($ymax,-3),round($ytick, -3));
			$traffic->AddAxisLabel(extension_dashboard_analytics::formatDates(array($d0,$d10,$d20,$d30)),1);

			$traffic->SetGrid(round(100/30,2),round(100/6,2),1,3);
			
			
			$traffic->SetTitle('Visits and Page Views of last 30 days');
			$traffic->AddLegend('visits');
			$traffic->AddLegend('page views');
			$traffic->SetLegendPosition('b');
			
			

			// Generate chart URL
	
			
			$graph = new XMLElement('div', $traffic->GetImg());
			$graph->setAttribute('class', 'graph');
			return $graph;
		
		}