fruppel/yii2-googlecharts
最新稳定版本:v1.2.0
Composer 安装命令:
composer require fruppel/yii2-googlecharts
包简介
Google Charts widget for Yii2.
README 文档
README
A wrapper for Google's charts API (see https://developers.google.com/chart/) to use it with Yii2.
Installation
The preferred way to install this extension is through composer.
composer require fruppel/yii2-googlecharts
Usage
Example 1: 3D PieChart with data in DataTable format
<?php
use \fruppel\googlecharts\GoogleCharts;
...
?>
<?= GoogleCharts::widget([
'id' => 'my-id',
'visualization' => 'PieChart',
'data' => [
'cols' => [
[
'id' => 'topping',
'label' => 'Topping',
'type' => 'string'
],
[
'id' => 'slices',
'label' => 'Slices',
'type' => 'number'
]
],
'rows' => [
[
'c' => [
['v' => 'Mushrooms'],
['v' => 3]
],
],
[
'c' => [
['v' => 'Onions'],
['v' => 1]
]
],
[
'c' => [
['v' => 'Olives'],
['v' => 1]
]
],
[
'c' => [
['v' => 'Zucchini'],
['v' => 1]
]
],
[
'c' => [
['v' => 'Pepperoni'],
['v' => 2]
]
],
]
],
'options' => [
'title' => 'How Much Pizza I Ate Last Night',
'width' => 400,
'height' => 300,
'is3D' => true,
],
'responsive' => true,
]) ?>
Example 2: AreaChart with data array (will be converted to DataTable)
<?php
use \fruppel\googlecharts\GoogleCharts;
...
<?= GoogleCharts::widget([
'visualization' => 'AreaChart',
'options' => [
'title' => 'Company Performance',
'hAxis' => [
'title' => 'Year',
'titleTextStyle' => [
'color' => '#333'
]
],
'vAxis' => [
'minValue' => 0
]
],
'dataArray' => [
['Year', 'Sales', 'Expenses'],
['2013', 1000, 400],
['2014', 1170, 460],
['2015', 660, 1120],
['2016', 1030, 540]
]
])
?>
Render charts as png image
Set the $asPng option to true like the example below
<?= GoogleCharts::widget([
'asPng' => true,
...
Note: This works currently only for core charts and geocharts. See the charts documentation for more information: https://developers.google.com/chart/interactive/docs/printing
统计信息
- 总下载量: 71.57k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2014-10-02

