Home > Database > Mysql Tutorial > mysql-HighCharts MySql数据库数据绑定

mysql-HighCharts MySql数据库数据绑定

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 09:35:02
Original
1485 people have browsed it

mysqlhighcharts

前提:已经确定从数据库读出的数据转换为Json格式,测试了下,结果为:
factor Value: {"rows":[{"cur_val":0.1150,"pow_val":26.2913,"consum":76.3807,"voltage":228.6632,"opt_time":"2015-05-26 20:37"},{"cur_val":0.1181,"pow_val":27.0956,"consum":76.3807,"voltage":229.4428,"opt_time":"2015-05-26 20:53"},```]} 数据量有些多 大概有1000多条

Controller:
@ResponseBody
@RequestMapping(value="/factor",method ={RequestMethod.GET,RequestMethod.POST})
public String getFactor(HttpServletRequest request,HttpServletResponse response)throws SgccException{
String factor=null;
System.out.println(request.getParameter("eqid"));
try {
factor=elcDataService.queryData(request.getParameter("acid"), request.getParameter("eqid"));
System.out.print("factor Value: ");
System.out.print(factor);
} catch (Exception e) {
e.printStackTrace();
}
return factor;
}
页面:(大概把相关的贴下)

<code> <button type="button" align="left" onclick="line()">查 询</button> <div id="container" style="width:850px;height:370px; float:left;"></div> <script type="text/javascript">function line() {     if($("#account").val()==""){         Dialog,alert("请填写用户名!");        }    else{          var x=[];          var y=[];        $.ajax({            type:"get",            url:"<%=path%>/factor",            data:{"eqid":$.trim($("#eid option:selected").val()),                  "acid":$.trim($("#account").val())},            dataType:"json",            async:false,            success:function(msg) {                var returnValue = eval("("+msg+")");                for(var key in returnValue.rows){                    returnValue.rows[key].y=returnValue.rows[key].consum;                    xtext=returnValue.rows[key].opt_time;                }                chart.series[0].setData(returnValue.rows.consum);            },            error:function() {                Dialog.alert("没有数据,请重新查询!");                return;            }        });      var chart=new Highcharts.Chart({        chart:{            renderto:'container',            type:'spline'        },        title:{text:'变化趋势'},        xAxis:{categories:xtext},        yAxis:{title:{text:变化趋势},},        series:[{name:"consum"}]      });      };};</script></code>
Copy after login

页面显示:图片说明

但是一直显示不出对应的图表,能否帮看下什么原因?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template