exocet/yii2-chart-widget

适用于yii2框架的chartist图表实现

安装次数: 108

依赖项: 0

建议者: 0

安全: 0

星星: 0

关注者: 1

分支: 0

开放问题: 0

类型:yii2-extension

1.0.0 2018-08-21 22:37 UTC

This package is auto-updated.

Last update: 2024-09-07 18:34:37 UTC


README

CHARTIST.JS库的包装器 CHARTIST.JS

资源

安装

安装此扩展的首选方式是通过 composer

运行

$ php composer.phar require --prefer-dist "exocet/yii2-chart-widget"

或添加

{
	"require": {
  		"exocet/yii2-chart-widget": "~1.0"
	}
}

到你的 composer.json 文件的 require 部分

示例用法

<?php
/* @var $this yii\web\View */

use exocet\yii2\chart\Chart;
use yii\web\JsExpression;

$this->title = 'my example';
$this->params['breadcrumbs'][] = $this->title;

?>
<?php
echo Chart::widget([
           'type'              => Chart::TYPE_LINE,
           'disableCss'        => true, //disable chartist css
           'label'             => true, //enable labels plugin
           'labels'            => [1, 2, 3, 4],
           'series'            => [[100, 120, 180, 200]],
           'clientOptions'     => [
               'showLine' => false,
               'axisX'    => [
                   'labelInterpolationFnc' => new JsExpression('function(value, index) {
                       return index % 13 === 0 ? \'W\' + value : null;
                   }')
               ]
           ],
           'responsiveOptions' => [
               'screen and (min-width: 640px)' => [
                   'axisX' => [
                       'labelInterpolationFnc' => new JsExpression('function(value, index) {
                           return index % 4 === 0 ? \'W\' + value : null;
                       }')
                   ]
               ]
           ]
      ]);
?>

Ajax 示例用法

<?php
/* @var $this yii\web\View */

use exocet\yii2\chart\Chart;
use yii\web\JsExpression;
use yii\helpers\Url;

$this->title = 'my example';
$this->params['breadcrumbs'][] = $this->title;

?>
<?php
echo Chart::widget([
           'type'              => Chart::TYPE_LINE,
           'ajax'              => Url::to(['ajax-data']),
      ]);
?>

许可证

yii2-chart-widget 采用MIT许可证发布。有关详细信息,请参阅打包的 LICENSE