peterziv/yii2-echarts

Chart widgets for Yii2

Installs: 115

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 1

Open Issues: 0

Type:yii2-extension

dev-master 2017-06-15 18:42 UTC

This package is not auto-updated.

Last update: 2024-06-08 18:27:20 UTC


README

This is the Yii2 widgets for echarts. You can use this widget to implement the all charts supported by echarts. Some quick class for Line,Pie and map implement. Echarts

You can get detail of echarts from echarts official website :)

安装 (Installation):

$ composer require "peterziv/yii2-echarts:dev-master"

示例 (Demo):

Pie Chart

$pieData = ['n1' => ['value' => 11.1], 'n2' => ['value' => 22.2]];
echo Pie::widget([
    'title'=>'Pie Chart Test',
    'responsive' => true,
    'htmlOptions' => ['style' => 'height: 300px;'],
    'visualMap' => [
    	"show" => false,
    	"min" => 80,
    	"max" => 600
    ],
	'data' => $pieData
]);

Line Chart

$lineData = ['serie1' => ['value' => [1, 2, 3], 'averageLine' => true, 'maxPoint' => true, 'minPoint' => true], 'serie2' => ['averageLine' => true, 'value' => [3, 6, 9]]];
echo Line::widget([
	'responsive' => true,
	'htmlOptions' => ['style' => 'height: 300px;'],
    'title' => 'Line Chart Test',
    'unit'=>'度',
    'axis'=>['小','中','大'],
    'data'=>$lineData
]);

Zero data support

$zero =[];
echo Line::widget([
  'htmlOptions' => ['style' => 'height: 300px;'],
  'responsive' => true,
  'title' => 'No Data Test',
  'unit' => '度',
  'axis' => ['小', '中', '大'],
  'data' => $zero
]);

Also Support json and custom

$theOptions =  '{
	"title": {
		"text": "Json data Support"
	},
	"legend": {
		"data": ["bar1", "bar2"],
		"align": "left"
	},
	"toolbox": {
		"feature": {
			"magicType": {
				"type": ["stack", "tiled"]
			}
		}
	},
    "yAxis":[{"name":"SCORE","type":"value"}],
	"xAxis": {
		"data": ["测试1", "测试2", "测试3", "测试4"],
		"silent": false,
		"splitLine": {
			"show": false
		}
	},
	"series": [{
		"name": "bar1",
		"type": "bar",
		"data": [1, 2, 5, 8]
	}, {
		"name": "bar2",
		"type": "bar",
		"data": [9, 6, 5, 8]
	}]
}';
echo Echarts::widget([
  'options'=>$theOptions,
  'htmlOptions' => ['style' => 'height: 300px;'],
]);