onmotion/

yii2-widget-apexcharts

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

安装数量: 45,015

依赖项: 1

建议者: 0

安全: 0

星标: 18

关注者: 2

分支: 11

开放问题: 15

类型:yii2-extension


README

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

Latest Stable Version Total Downloads Monthly Downloads License

fluent fluent

更多示例请参考ApexCharts.js演示

安装

只需运行

composer require onmotion/yii2-widget-apexcharts

或在您的composer.json文件的require部分添加

"onmotion/yii2-widget-apexcharts": "*"

用法

在视图文件中添加echo \onmotion\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 \onmotion\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