onixsib/yii2-chartjs-widget
为Yii2的ChartJs小部件。
2.0.4
2017-03-29 06:12 UTC
Requires
- bower-asset/chartjs: 2.5.0
- yiisoft/yii2: *
Requires (Dev)
- phpunit/phpunit: 4.*
This package is not auto-updated.
Last update: 2024-09-20 19:50:34 UTC
README
渲染ChartJs插件小部件
安装
安装此扩展的首选方式是通过composer。这需要composer-asset-plugin,它也是yii2的依赖项——所以如果您已经安装了yii2,那么您可能已经设置好了。
运行以下命令之一:
composer require 2amigos/yii2-chartjs-widget:~2.0
或添加
"2amigos/yii2-chartjs-widget" : "~2.0"
到您应用程序的composer.json文件的require部分。
使用方法
支持以下类型
- 折线图
- 柱状图
- 雷达图
- 极坐标图
- 饼图
- 环形图
以下示例使用的是Line类型的图表。请查看ChartJs插件文档了解插件支持的不同类型。
use dosamigos\chartjs\ChartJs;
<?= ChartJs::widget([
'type' => 'line',
'options' => [
'height' => 400,
'width' => 400
],
datasets =>
[
[
'label' => "My First dataset",
'backgroundColor' => "rgba(179,181,198,0.2)",
'borderColor' => "rgba(179,181,198,1)",
'pointBackgroundColor' => "rgba(179,181,198,1)",
'pointBorderColor' => "#fff",
'pointHoverBackgroundColor' => "#fff",
'pointHoverBorderColor' => "rgba(179,181,198,1)",
'data' => [65, 59, 90, 81, 56, 55, 40]
],
[
'label' => "My Second dataset",
'backgroundColor' => "rgba(255,99,132,0.2)",
'borderColor' => "rgba(255,99,132,1)",
'pointBackgroundColor' => "rgba(255,99,132,1)",
'pointBorderColor' => "#fff",
'pointHoverBackgroundColor' => "#fff",
'pointHoverBorderColor' => "rgba(255,99,132,1)",
'data' => [28, 48, 40, 19, 96, 27, 100]
]
]
]);
?>
更多信息
ChartJs有很多配置选项。有关更多信息,请访问ChartJs插件网站。
贡献
有关详细信息,请参阅CONTRIBUTING。
致谢
许可证
BSD许可证(BSD)。有关更多信息,请参阅许可证文件。
网页开发从未如此有趣!
www.2amigos.us