heightchart插件实现数据可视化 [ 2.0 版本 ]
//在yii框架里面使用heiahtchart插件,实现数据可视化显示
http://www.yiiframework.com/extension/yii2-highcharts-widget/
//将下面的代码添加到composer.json中require项中 如下:
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": "~2.0.5",
"yiisoft/yii2-bootstrap": "~2.0.0",
"yiisoft/yii2-swiftmailer": "~2.0.0",
"kartik-v/yii2-widget-datetimepicker": "*",
"kartik-v/yii2-widget-datepicker": "@dev",
"miloschuman/yii2-highcharts-widget": "*"
},
然后需要在命令行中执行 conposer update 组件会自动下载到yii的verdor目录下
//具体代码如下
<?php
use miloschuman\highcharts\Highcharts;
foreach($model as $myda):
$time[] = $myda['time'];
$allorder[] = intval($myda['allorder']);
$number[] = intval($myda['number']);
$money[] = intval($myda['money']);
endforeach;
//var_dump($money);die();
echo Highcharts::widget([
'options' => [
'title' => ['text' => 'Fruit Consumption'],
//如果需要的是柱状图则加上下面这个代码
'chart' => ['type' => 'column'],
'xAxis' => [
'categories' => [date('Y-m-d',$time['0']), date('Y-m-d',$time['1']), date('Y-m-d',$time['2']),date('Y-m-d',$time['3']),date('Y-m-d',$time['4'])]
],
'yAxis' => [
'title' => ['text' => 'Fruit eaten']
],
'series' => [
['name' => '订单总量', 'data' => $allorder],
['name' => '支付用户', 'data' => $number],
['name' => '支付金额', 'data' => $money],
]
]
]);
?>
成长型歌神
注册时间:2018-02-09
最后登录:2018-03-05
在线时长:1小时30分
最后登录:2018-03-05
在线时长:1小时30分
- 粉丝0
- 金钱20
- 威望20
- 积分230
共 0 条评论