我有来自服务的欧姆数据,每分钟都有时间变化,我使用高价来绘制分钟烛台,但它只显示最后一根蜡烛,之前的蜡烛正在消失。如果我使用当前时间(以毫秒为单位)作为ohlc的属性但我想使用来自服务器的分钟时间
this.options = {
chart: {
width: 1200 ,
height:800,
type: 'candlestick'
},
title: { text : 'dynamic data example'},
xAxis: {
type: 'datetime',
dateTimeLabelFormats : {
hour: '%I %p',
minute: '%I:%M %p'
}
},
yAxis: {
title: {
text: 'Value'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
plotOptions: {
line: {
dataLabels: {
enabled: true
},
enableMouseTracking: false
}
},
rangeSelector: {
selected: 1
},
dataGrouping: {
units: [
['minute', [1]], [
'hour', [1, 2, 3, 4, 6]]
]
},
series: [{
name: 'Random data',
type: 'candlestick',
data: (function() {
// generate an array of random data
var data:any = [],
time = (new Date()).getTime(),
i:any;
for (i = -5; i <= 0; i++) {
data.push([
time + i * 60000,
Math.random()*100,
Math.random()*100,
Math.random()*100,
Math.random()*100
]);
}
return data;
})()}
]
};
this.connection = this.socketService.getMessages().subscribe(data => {
this.data = data;
this.chart.series[0].addPoint([
this.data.time,
this.data.open,
this.data.high,
this.data.low,
this.data.close,
], true, true);
})
答案 0 :(得分:0)
删除true选项解决了这个问题。
this.chart.series [0] .addPoint([this.data.time,this.data.open,this.data.high,this.data.low,this.data.close,],true,true );