问题
I have added the extension (a wraper for google chart) "scotthuangzl/yii2-google-chart": "dev-master" to the require section of my composer.json file. However when I call that extension on views\site\myPage.php I have this error: Class 'scotthuangzl\googlechart\GoogleChart' not found. What I am doing wrong? Thanks.
This is the code where I call the google chart:
<?php
use scotthuangzl\googlechart\GoogleChart;
echo GoogleChart::widget(array('visualization' => 'BarChart',
'data' => array(
array('Type', 'Value'),
array('Var1', $model->avg1),
.............
),
'options' => array('title' => 'Variable - avg1')));
?>
回答1:
I have solved the issue by using another wraper (https://github.com/miloschuman/yii2-highcharts). (1) I put the following lines in the require section of the composer.json file: "yiisoft/yii2-jui": "*", "miloschuman/yii2-highcharts-widget": "dev-master" (2) And then run in the console the command: composer update
来源:https://stackoverflow.com/questions/33483961/how-to-add-google-chart-correctly-in-yii2