highcharts 未知属性- yii\base\UnknownPropertyException正在设置未知属性:多萨米戈斯\高排行榜\高排行榜::脚本

0ejtzxu1  于 2022-11-10  发布在  Highcharts
关注(0)|答案(1)|浏览(165)

我在尝试使用highcharts小工具时遇到此错误:

Unknown Property – yii\base\UnknownPropertyException
Setting unknown property: dosamigos\highcharts\HighCharts::scripts

这是我的代码:
检视

<?php
    foreach($ventasPormes as $values){
                        $mes[] = ($values['mes']);
                        $cantidad[] = ($values['cantidad']);
                    }
                    echo
                 \dosamigos\highcharts\HighCharts::widget([
                        'scripts' => ['modules'],
                        'options' => [
                            'chart' => ['type' => 'column'],
                            'title' => ['text' => 'Ventas'],
                            'xAxis' => ['categories' => $mes],
                            'yAxis' => ['title' => ['text' => 'Cantidad']],
                            'series' => [
                                [
                                   'name' => 'Mes',
                                   'color' => '#004139',
                                   'colorByPoint' => false,
                                ],
                            ],
                        ],
                    ]);
?>

现场控制器

public function ventasPormes(){
        $expresion = new Expression("select COUNT(*) as cantidad, elt(MONTH(fecha),'Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre') as mes, year(fecha) as year from compras group by mes, year order by fecha desc limit 12");
        $query = Yii::$app->db->createCommand($expresion)->queryAll();
        return $query;
    }
2guxujil

2guxujil1#

看起来静态方法“widget”不支持属性“scripts”。请查看repo readme -https://github.com/2amigos/yii2-highcharts-widget中给出的示例
还可以查看显示它接受哪些属性的类-https://github.com/2amigos/yii2-highcharts-widget/blob/master/src/HighCharts.php

\dosamigos\highcharts\HighCharts::widget([
    'clientOptions' => [
        'chart' => [
                'type' => 'bar'
        ],
        'title' => [
             'text' => 'Fruit Consumption'
             ],
        'xAxis' => [
            'categories' => [
                'Apples',
                'Bananas',
                'Oranges'
            ]
        ],
        'yAxis' => [
            'title' => [
                'text' => 'Fruit eaten'
            ]
        ],
        'series' => [
            ['name' => 'Jane', 'data' => [1, 0, 4]],
            ['name' => 'John', 'data' => [5, 7, 3]]
        ]
    ]
]);

相关问题