当我使用highstocks“Stockcharts”类型来显示具有正值和负值的时间序列时,系列存在但不可见。 API中有很多选项,我没有得到哪个可以显示正值和负值...有没有人遇到过同样的问题?
这是工作的基础:
<html>
<head>
// importing jquery, underscore.js, highstocks.js, moment.js
<script>
$(function(){
dates = _.map([1,2,3,4,5,6], function(x){return moment().subtract(x, 'days').toDate();});
values = [-1,1,0.1,0.2,-0.5,0.7]
data = _.zip(dates, values);
console.log(data);
$('#graph').highcharts('StockChart',{
title: {text: ''},
series:[{
name: 'data',
data: data
}]
});
})
</script>
</head>
<body>
<div id='graph'></div>
</body>
</html>
修改
console.log(data);
# with moment().subtract(x, 'days').toDate().valueOf();
# or moment().subtract(x, 'days').valueOf();
Array[2], Array[2], Array[2], Array[2], Array[2], Array[2]]
0: Array[2]
0: 1446978478855
1: -1
length: 2
__proto__: Array[0]
1: Array[2]
0: 1446892078856
1: 1
length: 2
# moment().subtract(x, 'days').toDate();
[Array[2], Array[2], Array[2], Array[2], Array[2], Array[2]]
0: Array[2]
0: Sun Nov 08 2015 11:32:52 GMT+0100 (W. Europe Standard Time)
1: -1
length: 2
__proto__: Array[0]
1: Array[2]
0: Sat Nov 07 2015 11:32:52 GMT+0100 (W. Europe Standard Time)
1: 1
length: 2
__proto__: Array[0]