将数据连接到highcharts javascript
我有一些数据要连接到我的highcharts 到目前为止,我在z3s.js中获得了数据将数据连接到highcharts javascript,javascript,jquery,visual-studio-2010,highcharts,Javascript,Jquery,Visual Studio 2010,Highcharts,我有一些数据要连接到我的highcharts 到目前为止,我在z3s.js中获得了数据 KpiChartTrendForZxController = function($scope, $http, LocationService) { var GetKpiChartTrendForZx, dates; GetKpiChartTrendForZx = function(containerId) { var serviceUrl; serviceUrl = iSee.Serv
KpiChartTrendForZxController = function($scope, $http, LocationService) {
var GetKpiChartTrendForZx, dates;
GetKpiChartTrendForZx = function(containerId) {
var serviceUrl;
serviceUrl = iSee.ServiceLocator.KpiChartTrendZxForContainer(containerId);
return $http.get(serviceUrl).success(function(data) {
return $scope.trendForZx = data;
});
};
我的数据如下所示:
系列:[
{
名称:“ZB-Sum中的Z3”,
数据:[“04/04/2013 08:00”,5],“05/04/2013 08:00”,5],“06/04/2013 08:00”,5],“07/04/2013 08:00”,5],“08/04/2013 08:00”,5],“09/04/2013 08:00”,5],“11/04/2013 08:00”,5],“12/04/2013 08:00”,5],“13/04/2013 08:00”,5],“14/04/2013 08:00”,5],“15/04/2013 08:00],“16:00,5][“2013年4月17日08:00”,5],“2013年4月18日08:00”,5]]
如何将它们添加到我的系列中?
数据:
值[i]:名称[i],数据[i]
数据[i]:时间[j],值[j]
谢谢您的数据应该是时间戳,换句话说,时间以毫秒为单位。因此,请不要这样做
["04/04/2013 08:00", 5],
应该是
[Date.UTC(2014,3,4,8), 5],
返回正确的格式。我找到了答案:
var dateEndLabel, dateStartLabel, i, j, lastDate, seriesData, x, y;
i = 0;
seriesData = new Array();
lastDate = data[i].Values.length - 1;
dateStartLabel = data[i].Values[0].Time;
dateEndLabel = data[i].Values[lastDate].Time;
while (i < data.length) {
seriesData[i] = [];
j = 0;
x = [];
y = [];
while (j < data[i].Values.length) {
x = data[i].Values[j].Time;
y = data[i].Values[j].Value;
seriesData[i].push([x, y]);
j++;
}
i++;
}
我的问题现在解决了,但我想我可以把我的代码压缩成一个更小的系列。无论如何,它现在可以工作了,我在highcharts中还有另一个调用:)链接到我的小提琴:嗨,谢谢你的回复。我的日期是一个字符串。我的问题是我需要将数据推送到highchart中的xaxis和yaxis。我只得到图表中的最后一个数据。我如何推送all数据?
series: [
{
name: data[0].Name,
data: seriesData[0]
}, {
name: data[1].Name,
data: seriesData[1]
}, {
name: data[2].Name,
data: seriesData[2]
}, {
name: data[3].Name,
data: seriesData[3]
}, {
name: data[4].Name,
data: seriesData[4]
}, {
name: data[5].Name,
data: seriesData[5]
}
],