Angular 高度图表角度-高度图表错误#12
我试图在一个折线图中显示数据,其中x轴上有“date”值,y轴上有“announces”值。我得到的数据没有显示在图表上。我对series.data属性的结构如下:Angular 高度图表角度-高度图表错误#12,angular,typescript,api,highcharts,data-binding,Angular,Typescript,Api,Highcharts,Data Binding,我试图在一个折线图中显示数据,其中x轴上有“date”值,y轴上有“announces”值。我得到的数据没有显示在图表上。我对series.data属性的结构如下:[[date,announces],[date,announces],…]。这是我的密码: dataChart: SequenceChartData[] = []; bucketAnnouncements: Array<[Date, number]> = []; ngOnInit(): void { this.c
[[date,announces],[date,announces],…]
。这是我的密码:
dataChart: SequenceChartData[] = [];
bucketAnnouncements: Array<[Date, number]> = [];
ngOnInit(): void {
this.chartService.getSequenceChartData(this.data.peerAS, this.data.peerIPAddress, this.data.prefix)
.subscribe((data: SequenceChartData[]) => {
this.dataChart = data;
this.update = true;
this.show = true;
let firstDay = Infinity;
let lastDay = -Infinity;
for (const val of this.dataChart){
const date = moment.utc(val.date).unix();
if (firstDay > date) {
firstDay = date;
}
if (lastDay < date) {
lastDay = date;
}
}
for (let n = firstDay; n <= lastDay; n += 300) {
this.bucketAnnouncements[n] = [
new Date(n * 1000),
0
];
}
for (const val of this.dataChart) {
const date = val.date;
this.bucketAnnouncements[moment.utc(date).unix()][1] = val.announces;
}
this.chartOptions.series = [
{
name: 'ao',
type: 'line',
data: this.bucketAnnouncements,
color: '#009879',
}
];
});
}
我还根据错误建议将turboTreshold
设置为更高的数字,但它仍然无法工作(仍然发出警告):
为了更全面地理解我的代码,这里有一个(无法解决合并冲突)请注意
日期格式
例如,2019年1月1日星期二01:00:00 GMT+0100(中欧标准时间)
)不是高图表的数字。这只是一根绳子
为了解决这个问题,请使用毫秒格式的时间戳
在那里,您可能会找到一些方法将其从一种格式转换为另一种格式
MDN:
1546300800: (2) [Tue Jan 01 2019 01:00:00 GMT+0100 (Central European Standard Time), 31]
1546301100: (2) [Tue Jan 01 2019 01:05:00 GMT+0100 (Central European Standard Time), 30]
1546301400: (2) [Tue Jan 01 2019 01:10:00 GMT+0100 (Central European Standard Time), 30]
1546301700: (2) [Tue Jan 01 2019 01:15:00 GMT+0100 (Central European Standard Time), 30]
1546302000: (2) [Tue Jan 01 2019 01:20:00 GMT+0100 (Central European Standard Time), 30]
1546302300: (2) [Tue Jan 01 2019 01:25:00 GMT+0100 (Central European Standard Time), 30]
1546302600: (2) [Tue Jan 01 2019 01:30:00 GMT+0100 (Central European Standard Time), 30]
...
plotOptions: {
series: {
turboThreshold: 500000,
...
}
}