用后台控制highchars曲线图
<script> //左侧Javascript代码<br />
$(function () {<br />
var id=$("#dtid").val();<br />
$.ajax({<br />
datatype:"json",<br />
type:"POST",<br />
url:"{:U('change')}",<br />
data:{id:id},<br />
success:function(msg) {<br />
$('#container').highcharts({<br />
title: {<br />
text: '瑞币空间',<br />
x: -20 //center<br />
},<br />
subtitle: {<br />
text: msg[2],<br />
x: -20<br />
},<br />
xAxis: {<br />
categories: msg[0]<br />
},<br />
yAxis: {<br />
title: {<br />
text: '份额初始价 (元)'<br />
},<br />
plotLines: [{<br />
value: 0,<br />
width: 1,<br />
color: '#808080'<br />
}]<br />
},<br />
tooltip: {<br />
valueSuffix: '元'<br />
},<br />
legend: {<br />
layout: 'vertical',<br />
align: 'right',<br />
verticalAlign: 'middle',<br />
borderWidth: 0<br />
},<br />
series: msg[1]<br />
});<br />
}<br />
<br />
});<br />
});<br />
<br />
</script>
//控制器里
public function change(){
$time=date("H",time());
$findnum=intval($time-9);
$list=M('xaxis')->select();
$newlist=array();
$num=0;
foreach($list as $key =>$val){
$newlist[$num].=$val['name'];
$num++;
}
if(isset($_REQUEST['id'])){
$map['id']=$_REQUEST['id'];
}
$list1=M('congregation')->where($map)->select();
$num1=0;
$new=array();
foreach($list1 as $key =>$val){
$new[$num1]['name']=$val['name'];
$yname=M('yaxis')->where(array('pid'=>$val['id'],'xid'=>array('elt',$findnum)))->select();
$num2=0;
foreach($yname as $key =>$valy) {
$new[$num1]['data'][$num2] = floatval($valy['num']);
$num2++;
}
$num1++;
}
$new_array = array();
$new_array[] = $newlist;
$new_array[] = $new;
$new_array[] = date('Y-m-d',time());
$this->ajaxReturn($new_array);
}
AD:真正免费,域名+虚机+企业邮箱=0元