2013-06-28 30 views
0

我有一些数据我想连接到我的高楼。将数据连接到高地图javascript

到目前为止,我在我的z3s.js获取数据

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; 
    }); 
    }; 

我的数据是这样的: 系列:[{ 名 : “从Z3 ZB - 总和”, 数据:[[“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],[”10/04/2013 08:00“,5 ],[“2013年4月11日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“,5],[”16/04/2013 08:00“,5],[”17/04/2013 08 :00“,5],[”18/04/2013 08:00“,5]]

如何将它们添加到我的系列中? 数据: 值[I]:名称[I],数据[I]

数据[我]:时间[J],价值[J]

感谢

+0

链接到我的小提琴:http://jsfiddle.net/vbsvbs/dLgCb/ – Caveman

回答

0

我找到了答案:

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++; 
    } 

然后将它们添加到我的highchart系列:

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] 
     } 
    ], 

我现在的问题是解决了,但是我想我有可能缩小我的代码在一个较小的一个系列。无论如何,现在的作品,我有另一callestangs在highcharts :)

0

你的数据应该是时间戳换句话说,以毫秒为单位的时间。因此,而不是这个

["04/04/2013 08:00", 5], 

应该

[Date.UTC(2014,3,4,8), 5], 

它返回corret格式。

+0

嗨,感谢您的答复。我的日期是一个字符串。我的问题是我需要将数据推送到我的highchart中的xaxis和yaxis。我只能得到我图表中的最后数据。我如何推送所有数据? – Caveman