Highchart - 预期类型来自属性“dashStyle”,该属性在此处声明为“XAxisPlotLinesOptions”类型

问题描述

我在高图中的 xAxis添加了以下代码

plotLines: [
    {
      color: 'grey',width: 2,dashStyle: 'line'
    }
],

我得到了下面的图表,之前我在其他工作中使用了 dashStyle,这里只有我得到了以下问题。

error TS2769: No overload matches this call.
      Overload 1 of 2,'(options: Options,callback?: ChartCallbackFunction): Chart',gave the following error.
        Type '"trgt-testcntrl"' has no properties in common with type 'Options'.
      Overload 2 of 2,'(renderTo: string | HTMLElement,options: Options,gave the following error.
        Type '"line"' is not assignable to type 'DashStyleValue'.

node_modules/highcharts/highcharts.d.ts:115249:5
        115249     dashStyle?: DashStyleValue;
                   ~~~~~~~~~
        The expected type comes from property 'dashStyle' which is declared here on type 'XAxisPlotLinesOptions'

在这里做错了什么?

解决方法

没有像 line 这样可能的破折号样式。
在 API 参考中,您可能会找到可用的。

API:https://api.highcharts.com/class-reference/Highcharts#.DashStyleValue
演示:https://stackblitz.com/edit/highcharts-angular-basic-line-dztepl