How to add google-chart correctly in Yii2?

2019-09-02 10:42发布

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')));
?>

标签: yii2
1条回答
Emotional °昔
2楼-- · 2019-09-02 10:57

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

查看更多
登录 后发表回答