Highcarts.Chart 面临问题

Facing issues with Highcarts.Chart

我正在使用 Highcharts 7.2.2 版本在我的应用程序上显示图表。我正在使用下面的代码。代码 运行s 并在我的本地机器上成功编译。但是,当我尝试使用 CI CD 过程部署它时,它一直给我错误。下面是我正在使用的代码,它 运行 在我的本地机器上完美运行。

displayGraph(results: any, key: string) {
  var self = this;
  var faultCountData: number[][] = [];
  var faultDurationData: number[][] = [];
  for (var i = 0; i < results[key].length; i++) {
    var timeArr = results[key][i].duration.split(":");
    var ms =
      Number(timeArr[0]) * 160 * 2 60 * 21000 +
      Number(timeArr[1]) * 160 * 11000;
    faultCountData.push([
      results[key][i].latestOccuranceTime,
      results[key][i].faultCount,
    ]);
    faultDurationData.push([results[key][i].latestOccuranceTime, ms]);
  }
  Highcharts.chart({
    chart: {
      renderTo: "dailyFault",
    },
    credits: { enabled: false },
    title: { text: "" },
    xAxis: {
      type: "datetime",
      labels: {
        format: "{value:%e/%m/%Y}",
      },
    },
    yAxis: [
      {
        labels: {
          format: "{value}",
          style: {
            color: Highcharts.getOptions().colors[0],
          },
        },
        title: {
          text: this.translation.translate(
            "FAULT_COUNT",
            undefined,
            this.locale.getCurrentLanguage()
          ),
          style: {
            color: Highcharts.getOptions().colors[0],
          },
        },
      },
      {
        // Secondary yAxis
        title: {
          text: this.translation.translate(
            "FAULT_DURATION_HRS",
            undefined,
            this.locale.getCurrentLanguage()
          ),
          style: {
            color: "#ffb0ad",
          },
        },
        type: "datetime",
        labels: {
          style: {
            color: "#ffb0ad",
          },
          formatter: function () {
            var time = this.value;
            var hours1 = parseInt((time / 3600000).toString());
            var mins1 = parseInt(
              (parseInt((time % 3600000).toString()) / 60000).toString()
            );
            return (
              (hours1 < 10 ? "0" + hours1 : hours1) +
              ":" +
              (mins1 < 10 ? "0" + mins1 : mins1)
            );
          },
        },
        opposite: true,
      },
    ],
    tooltip: {
      enabled: true,
      pointFormatter: function () {
        var time = this.y;
        var hours1 = parseInt((time / 3600000).toString());
        var mins1 = parseInt(
          (parseInt((time % 3600000).toString()) / 60000).toString()
        );
        if (this.series.name == "Fault Count")
          return `<span style="color:${this.color}">\u25CF</span> ${this.series.name}: <b>${this.y}</b><br/>`;
        else
          return `<span style="color:${this.color}">\u25CF</span> ${
            this.series.name
          }: <b>${
            (hours1 < 10 ? "0" + hours1 : hours1) +
            ":" +
            (mins1 < 10 ? "0" + mins1 : mins1)
          }(${self.translation.translate(
            "RUNTIME.MAINTENANCE_ADVISOR.DAILY_FAULT.HRS",
            undefined,
            self.locale.getCurrentLanguage()
          )})</b><br/>`;
      },
      shared: true,
    },
    series: [
      {
        name: this.translation.translate(
          "FAULT_DURATION",
          undefined,
          this.locale.getCurrentLanguage()
        ),
        data: [faultDurationData],
        type: "column",
        yAxis: 1,
        color: "#ffb0ad",
      },
      {
        name: this.translation.translate(
          "FAULT_COUNT",
          undefined,
          this.locale.getCurrentLanguage()
        ),
        type: "spline",
        data: [faultCountData],
      },
    ],
  });
};

上面的代码运行在我本地完美。但是在部署时出现以下错误:

error TS2345: Argument of type '{ chart: { renderTo: string; }; credits: { enabled: false; }; 
title: { text: string; }; xAxis: { ...' is not assignable to parameter of type 'Options'.
Types of property 'series' are incompatible.
Type '({ name: any; data: number[][]; type: "column"; yAxis: number; color: string; } | { 
name: any; ty...' is not assignable to type '(SeriesAbandsOptions | SeriesAdOptions | 
SeriesAoOptions | SeriesApoOptions | SeriesAreaOptions |...'.
Type '{ name: any; data: number[][]; type: "column"; yAxis: number; color: string; } | { name: 
any; typ...' is not assignable to type 'SeriesAbandsOptions | SeriesAdOptions | 
SeriesAoOptions | SeriesApoOptions | SeriesAreaOptions | ...'.
Type '{ name: any; data: number[][]; type: "column"; yAxis: number; color: string; }' is not 
assignable to type 'SeriesAbandsOptions | SeriesAdOptions | SeriesAoOptions | SeriesApoOptions 
| SeriesAreaOptions | ...'.
Type '{ name: any; data: number[][]; type: "column"; yAxis: number; color: string; }' is not 
assignable to type 'SeriesColumnOptions'.
Types of property 'data' are incompatible.
Type 'number[][]' is not assignable to type '(number | [string | number, number] | 
SeriesColumnDataOptions)[]'.
Type 'number[]' is not assignable to type 'number | [string | number, number] | 
SeriesColumnDataOptions'.
Type 'number[]' has no properties in common with type 'SeriesColumnDataOptions'.

有没有人认为我做错了什么?

也许 this 可以提供帮助。

使用:

import * as Highcharts from 'highcharts';
...

var options = {
    chart: {
       renderTo:'dailyFault'
    },
    credits: { enabled: false },
    ...
}
Highcharts.chart(options as Highcharts.Options);