funarbe/yii2-widget-apexcharts

Yii2 图表小部件 - ApexCharts.js 的包装器

安装: 0

依赖者: 0

建议者: 0

安全性: 0

星标: 0

关注者: 0

分支: 11

类型:yii2-extension

v1.0.9 2021-09-09 14:51 UTC

README

Yii2 图表小部件 - ApexCharts.js 的包装器。

Latest Stable Version Total Downloads Monthly Downloads License

fluent fluent

更多示例请参阅 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
]);

fluent