angular - Highcharts Angular-“SeriesAbandsOptions”类型上不存在属性“数据”
问题描述
我正在尝试使用 REST API 设置图表的数据,但出现以下错误:“SeriesAbandsOptions”类型上不存在属性“数据”
ngOnInit(): void {
this.chartService.getMostFrequentUpdateData().subscribe(
(data: ChartData[]) => {
if(this.chartOptions.series){
this.chartOptions.series[0].data = data;
}
}
);
}
我得到错误.data
。为清楚起见,这是我的图表:
chartOptions: Options = {
title: {
text: 'CDF of the most frequent update frequency',
style: {
color: 'whitesmoke'
}
},
chart: {
type: 'line',
zoomType: 'x',
backgroundColor: '#323232',
},
...
series: [
{
name: 'Frequency of the most frequent update in the sequence (upd/min)',
type: 'line',
data: [],
color: '#009879',
}
],
}
解决方案
似乎缺少一些 TS 定义。你有两个选择:
- 把一切都扔到
any
-相当残酷。 SeriesAbandsOptions
创建附加接口以扩展缺少data
类型的现有接口。
简单演示:https ://stackblitz.com/edit/highcharts-angular-property-xxx-doesnt-exist-on-type-yyy
推荐阅读
- python - Tkinter 画布:在不实际移动光标的情况下移动鼠标(想想 Photoshop 调整画笔大小)
- java - LocalDateTime 未在程序内更新
- sql - SQL::Maker 如何向字段添加函数
- python - 使用python从excel中读取数据
- jquery - 如何检查 td:nth-child(3) 是否大于或等于百分比?
- ios - 选择具有两个按钮的表视图时更新数组时出错
- javascript - 获取 JSON 中的最后一个索引值
- javascript - 无效的钩子调用警告链接一个 react-app 和一个本地 npm 包
- c - 链表程序运行不正常
- reactjs - 如何避免在仪表板中刷新页面后返回登录菜单或主页