54 $this->htmlOptions[
'id'] = $id;
56 if ($this->containerId == null) {
57 $this->containerId =
'div-chart' . $id;
58 echo
'<div ' . CHtml::renderAttributes($this->htmlOptions) .
'></div>';
60 $this->registerClientScript();
66 public function registerClientScript()
69 $jsData = CJavaScript::jsonEncode($this->data);
70 $jsOptions = CJavaScript::jsonEncode($this->options);
73 google.setOnLoadCallback(drawChart' . $id .
');
75 function drawChart' . $id .
'() {
76 var data = google.visualization.arrayToDataTable(' . $jsData .
');
78 var options = ' . $jsOptions .
';
80 ' . $id .
' = new google.visualization.' . $this->visualization .
'(document.getElementById("' . $this->containerId .
'"));
81 ' . $id .
'.draw(data, options);
85 $cs = Yii::app()->getClientScript();
86 $cs->registerScriptFile(
'https://www.google.com/jsapi');
88 __CLASS__ .
'#' . $id,
89 'google.load("visualization", "1", {packages:["corechart"]});',
90 CClientScript::POS_HEAD
92 $cs->registerScript($id, $script, CClientScript::POS_HEAD);