【问题标题】:Highcharts Angular - Property 'data' does not exist on type 'SeriesAbandsOptions'Highcharts Angular-“SeriesAbandsOptions”类型上不存在属性“数据”
【发布时间】:2021-04-23 10:12:28
【问题描述】:

我正在尝试使用 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',
        }
    ],
}

【问题讨论】:

  • SeriesAbandsOptions 是什么?
  • @JosephBudin 我不知道
  • 你能在 stackblitz 上重现这个问题吗
  • @OwenKelvin 这是链接,不幸的是我在导入时遇到了一些错误,它们似乎没有意义stackblitz.com/edit/…
  • 你能分享一个公共回购我试图重现这个问题吗?

标签: angular typescript highcharts data-binding


【解决方案1】:

似乎缺少一些 TS 定义。 你有两个选择:

  1. 将所有内容都投给any - 相当残酷。
  2. 创建附加接口,使用缺少的data 类型扩展现有的SeriesAbandsOptions

简单演示:https://stackblitz.com/edit/highcharts-angular-property-xxx-doesnt-exist-on-type-yyy

【讨论】:

    猜你喜欢
    • 2018-07-12
    • 2018-05-01
    • 1970-01-01
    • 2022-07-23
    • 2023-03-18
    • 2018-10-15
    • 2021-04-02
    • 1970-01-01
    • 2021-12-26
    相关资源
    最近更新 更多