2013-06-28 84 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