funarbe / yii2-widget-apexcharts
Yii2 图表小部件 - ApexCharts.js 的包装器
v1.0.9
2021-09-09 14:51 UTC
Requires
- php: >=5.5.0
- yiisoft/yii2: >=2.0.1
This package is auto-updated.
Last update: 2024-09-10 02:38:21 UTC
README
Yii2 图表小部件 - ApexCharts.js 的包装器。
更多示例请参阅 ApexCharts.js 示例
安装
只需运行
composer require funarbe/yii2-widget-apexcharts
或在您的 composer.json 文件的 require 部分中添加
"funarbe/yii2-widget-apexcharts": "*"
。
用法
在视图文件中添加 echo \funarbe\apexcharts\ApexchartsWidget::widget([])
,并包含必要的选项。
选项
示例
$series = [ [ 'name' => 'Entity 1', 'data' => [ ['2018-10-04', 4.66], ['2018-10-05', 5.0], ], ], [ 'name' => 'Entity 2', 'data' => [ ['2018-10-04', 3.88], ['2018-10-05', 3.77], ], ], [ 'name' => 'Entity 3', 'data' => [ ['2018-10-04', 4.40], ['2018-10-05', 5.0], ], ], [ 'name' => 'Entity 4', 'data' => [ ['2018-10-04', 4.5], ['2018-10-05', 4.18], ], ], ]; echo \funarbe\apexcharts\ApexchartsWidget::widget([ 'type' => 'bar', // default area 'height' => '400', // default 350 'width' => '500', // default 100% 'chartOptions' => [ 'chart' => [ 'toolbar' => [ 'show' => true, 'autoSelected' => 'zoom' ], ], 'xaxis' => [ 'type' => 'datetime', // 'categories' => $categories, ], 'plotOptions' => [ 'bar' => [ 'horizontal' => false, 'endingShape' => 'rounded' ], ], 'dataLabels' => [ 'enabled' => false ], 'stroke' => [ 'show' => true, 'colors' => ['transparent'] ], 'legend' => [ 'verticalAlign' => 'bottom', 'horizontalAlign' => 'left', ], ], 'series' => $series ]);