Google Chart - Csqldataprovider


I am looking for a simple way to output data from my controller and populate the data in a Google chart.

I can pass the data and output the results into a test echo in my view but I am unsure how to output this inside the <script> tags?

Any help would be most appreciated.


class TheLeagueController extends Controller



	public function actionVenue()


	  $sql='SELECT * FROM player_card WHERE player_id = 1 AND season_key = 7022014 ';	  


	  $dataProvider=new CSqlDataProvider($sql,array());


	  $this->render('venue', array('dataProvider' => $dataProvider,));




<script type="text/javascript" src=""></script>

    <script type="text/javascript">

      google.load("visualization", "1", {packages:["corechart"]});



      function drawChart() {        


        var data = google.visualization.arrayToDataTable([

            ['Week', 'Points'],  

            ['Week 1', 10],			// NEED TO OUTPUT AND REPLACE DATA HERE !!!!

            ['Week 2', 14],			// NEED TO OUTPUT AND REPLACE DATA HERE !!!!

            ['Week 3', 16],			// NEED TO OUTPUT AND REPLACE DATA HERE !!!!



        var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));

        chart.draw(data, options);



<div id="chart_div" style="width: 100%;"></div>

Working Test View

<?php foreach($dataProvider->data as $card):?>


  	<?php echo $card['week_1_points']?> 

  	<?php echo $card['week_2_points']?> 

  	<?php echo $card['week_3_points']?>


<?php endforeach?>

10 14 16

Once again, any help would be most appreciated.

Many thanks


This may be way too late for you, but in case you still need help you can have a look here