我必须绘制来自 ajax 请求的时间和价值图,我需要知道如何将数据显示到 highcharts,请找到以下代码:
获取数据的 JSP:
<%@ page import = "com.qdx.eqc.vo.*, com.qdx.eqc.proxy.EQCProxyClient, java.util.*" %>
<%
System.out.println("Inside landingAjax.jsp");
String productionID = request.getParameter("productionID");
System.out.println("productionID = "+productionID);
String instrumentID = request.getParameter("instrumentID");
System.out.println("instrumentID = "+instrumentID);
String testId = request.getParameter("testId");
System.out.println("testId = "+testId);
String instrType = request.getParameter("instrType");
System.out.println("instrType = "+instrType);
String testInstrTypeId = request.getParameter("testInstrTypeId");
System.out.println("testInstrTypeId = "+testInstrTypeId);
String departmentId = request.getParameter("departmentId");
System.out.println("departmentId = "+departmentId);
EQCProxyClient client = new EQCProxyClient();
ResponseVO responseVO = null;
//Graph data for patinetbias START
responseVO = client.getPatientBiasData(productionID,instrumentID,testId,instrType,testInstrTypeId,"7.0",departmentId);
ArrayList xAxis = new ArrayList();
ArrayList lines = new ArrayList();
ArrayList dateTime = new ArrayList();
ArrayList doubleValue = new ArrayList();
Date duration = new Date();
Iterator itt=responseVO.getResponse().iterator();
while(itt.hasNext()){
PatientBiasDataVO po = (PatientBiasDataVO)itt.next();
xAxis = po.getPatientBiasData();
Iterator biasItr = xAxis.iterator();
while(biasItr.hasNext())
{
BiasDataVO biasData = (BiasDataVO)biasItr.next();
if(biasData.getStrDateTime()!=null)
{
dateTime.add(biasData.getStrDateTime());
}
doubleValue.add(biasData.getValue());
}
lines = po.getVerticalLines();
duration = po.getDateTime();
System.out.println(" xAxis "+ xAxis + " lines " + lines + "duration" + duration );
}
out.print(doubleValue.toString()+','+dateTime.toString()); /// THESE IS THE GRAPH DATA as VALUE AND TIME
%>
用于 AJAX 和 HIGHCHARTS 的 JAVASCRIPT:
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function(){alert('came in');
var options = {
chart: {
renderTo: 'right1',
type: 'spline',
marginRight: 10,
},
credits: {
enabled: false
},
title: {
text: 'Patient Bias Display'
},
xAxis: {
type: 'datetime',
tickPixelInterval: 150
},
yAxis: {
title: {
text: 'Bias'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) +'<br/>'+
Highcharts.numberFormat(this.y, 2);
}
},
legend: {
enabled: false
},
exporting: {
enabled: false
},
plotOptions: {
color: '#F3F70E'
},
series: []
};
var productionID = document.getElementById('productionID').value;
var instrumentID = document.getElementById('instrumentID').value;
var testId = document.getElementById('testId').value
var instrType = document.getElementById('instrType').value;
var testInstrTypeId = document.getElementById('testInstrTypeId').value;
var departmentId = document.getElementById('departmentId').value;
var url = "landingAjax.jsp";
url = url+"?productionID="+productionID+"&instrumentID="+instrumentID+"&testId="+testId+"&instrType="+instrType+"&testInstrTypeId="+testInstrTypeId+"&departmentId="+departmentId;
alert(url);
$('#highCharts').click(function() {alert('clicked'); // CLICKED is alerted
$.getJSON(url, function(data) {alert(url); //THis alert doesnt work
如何在 X 轴和 Y 轴中填充数据?
变种系列= {数据:[]};
options.series.push(series);
var chart = new Highcharts.Chart(options);
});
});
});
</script>
我需要知道如何在 x 和 y 轴上累积数据来绘制图表,请参阅我上面的评论。
帮帮我,伙计们..如果有什么不明白的;请在评论中......谢谢!