需要一些帮助。如何使用 js 限制 json 数组的最小值和最大值。
这是我的问题,在高库存上工作,我的日期是 unix 中的第一天,但在数组中我有正确的日期。所以我的导航器和范围刻度不起作用?
我的 json 数组在变量中
var data = <?php echo $data; ?>;
但我想像这样限制它
$.getJSON('https://www.highcharts.com/samples/data/from-sql.php?start=' + Math.round(e.min) +
'&end=' + Math.round(e.max) + '&callback=?', function (data)
这是我的 json 结构
[1233014400000,12.96],
[1233100800000,13.46],
[1233187200000,13.29],
[1233273600000,12.88],
$(function () {
var data = <?php echo $data; ?>; // geting json array [1233014400000,12.96] //
// Create the chart
$('#container_small').highcharts('StockChart', {
rangeSelector : {
selected : 1,
enabled: true
},
title : {
text : 'Tankerska Next Generation d.d.'
},
navigator : {
enabled: true
},
series : [{
name : 'Tankerska Next Generation d.d.',
data : data,
marker : {
enabled : true,
radius : 4
},
shadow : true,
tooltip : {
valueDecimals : 2
}
}]
});
});
谢谢你的帮助
function getMaxOfArray(numArray) {
return Math.max.apply(null, numArray);
}
最小值也是如此。