Yii Extension for Google Visualization

I could not find any extension for Google Visualization so created a simple one. It works beautifully on my site using PieCharts but I believe I built it in a way that it will work well with the other Core Charts as well.

Simply place in your extensions folder. The rest is explained in the included comments.

3054

GoogleVisualizationCoreChartWidget.php

I hacked this extension to make it work for AreaCharts, but am having trouble passing some of the options to it…

The chart displays fine, but when trying to add any hAxis options nothing seems to work.




<?php

  $this->Widget('ext.GoogleVisualizationAreaChartWidget', array(

        'visualization' => 'AreaChart',

        'options'=>array(

            'data'=>$graphData,

			'options' => array(

				'width'=>'800',

				'height'=>'400',

				'hAxis'=>array(

					'slantedText'=>'true',

					'title'=>'Share of Voice',

					),		

				'legend'=>'none',

			) 

		), 

        'htmlOptions'=>array(

			'style'=>'height: 400px;',

			'class'=>'center'

			)

   ));

?>



And I get no slanted text or title on the horizontal axis.

Here is whats outputted in the view:




<script type="text/javascript">

/*<![CDATA[*/

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


            google.setOnLoadCallback(drawChartyw0);

            function drawChartyw0() {

                var data = google.visualization.arrayToDataTable([["Date","Share of Voice"],["2013-06-05",31.5],["2013-05-31",34],["2013-05-28",34],["2013-05-23",39],["2013-05-23",39],["2013-05-23",39],["2013-05-20",72],["2013-05-07",64.23],["2013-05-01",18.6],["2013-05-01",16.5],["2013-04-07",16.5]]);


                var options = {"width":"800","height":"400","hAxis":{"slantedText":"true","title":"Share of Voice"},"legend":"none"};


                var chart = new google.visualization.AreaChart(document.getElementById("yw0"));

                chart.draw(data, options);

            }

/*]]>*/

</script>



You can see the config options I’m trying to load here (scroll down to hAxis):

https://google-developers.appspot.com/chart/interactive/docs/gallery/areachart#Configuration_Options

Any help or suggestions are appreciated!

I’ve been playing around with this all day with no luck…

Thanks.