首頁  >  文章  >  php教程  >  highchars

highchars

WBOY
WBOY原創
2016-06-07 11:36:071076瀏覽

用后台控制highchars曲线图



<script> //左侧Javascript代码<br /> $(function () {<br /> var id=$("#dtid").val();<br /> $.ajax({<br /> datatype:"json",<br /> type:"POST",<br /> url:"{:U(&#039;change&#039;)}",<br /> data:{id:id},<br /> success:function(msg) {<br /> $(&#039;#container&#039;).highcharts({<br /> title: {<br /> text: &#039;瑞币空间&#039;,<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: &#039;份额初始价 (元)&#039;<br /> },<br /> plotLines: [{<br /> value: 0,<br /> width: 1,<br /> color: &#039;#808080&#039;<br /> }]<br /> },<br /> tooltip: {<br /> valueSuffix: &#039;元&#039;<br /> },<br /> legend: {<br /> layout: &#039;vertical&#039;,<br /> align: &#039;right&#039;,<br /> verticalAlign: &#039;middle&#039;,<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元

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn