我有highcharts:
data: (function () {
$.ajax({
type: "GET",
url: "http://localhost:8080/flkLive/ws/root/success",
success: function(values){
getAllDataValues(values);
}
});
}())
}]
});
});
function getAllDataValues(values){
var array_keys = [];
var array_values = [];
var data = [];
for (var key in values) {
if (values.hasOwnProperty(key)) {
array_keys.push(key);
array_values.push(values[key]);
}
}
array_keys.sort();
array_values.sort();
for (var i = 0; i < array_keys.length; i++){
data.push(Date.parse(array_keys[i] + " UTC"), parseFloat(array_values[i]))
}
alert(data);
return data;
}
但图表中没有值......
警报正确显示值!
谢谢!
答案 0 :(得分:0)
尝试这样的事情:
$(function() {
$(document).ready(function() {
$.getJSON('http://localhost:8080/flkLive/ws/root/success', function(data) {
$('#container').highcharts({
series: [{
data: getAllDataValues(data)
}]
});
});
});
function getAllDataValues(values) {
var array_keys = [];
var array_values = [];
var data = [];
for (var key in values) {
if (values.hasOwnProperty(key)) {
array_keys.push(key);
array_values.push(values[key]);
}
}
array_keys.sort();
array_values.sort();
for (var i = 0; i < array_keys.length; i++) {
data.push(Date.parse(array_keys[i] + " UTC"), parseFloat(array_values[i]))
}
alert(data);
return data;
}
});