标签:art series pac chart 数据 int json格式 生成 ssl
定义series中的数据发现是json格式,name: 'cdn',
data: [<?php echo $type['cdn']?> ]
那么我们可以在后端生成一个数组在js里打印
[ {"name":"cdn","data":[0]},{"name":"domain","data":[0]},{"name":"ssl","data":[0]} ]
从数据库中循环查询并生成name data键的数组
$types = $this->model->selectQcloudtype();
foreach ($types as $key => $type){
$montharr[$key]['name'] = $type['oProductCode'];
for ($month= 1;$month<=$maxmonth; $month++){
if($month<10){
$month=sprintf("%02d",$month);
} //位数不足前补零
$result= $this->model->selectQcloudCostcount($syear,$type['oProductCode'],$month);
$num = $result['0']['oTotalAmount'] ? $result['0']['oTotalAmount'] : 0;
$num = intval ($num)/100; //转换格式、单位
$montharr[$key]['data'][$month]=$num;
}
注意data中要去掉键
$montharr[$key]['data']=array_values($montharr[$key]['data']);
注意data里的值为int型
$num = intval ($num)
标签:art series pac chart 数据 int json格式 生成 ssl
原文地址:http://blog.51cto.com/q2012/2059453