首页 > 解决方案 > Highchart - 预期的类型来自属性 'dashStyle',它在类型 'XAxisPlotLinesOptions' 上声明

问题描述

xAxis在 highchart 中添加了以下代码。

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, callback?: ChartCallbackFunction): Chart', 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'

我在这里做错了什么?

标签: angularhighchartsangular2-highcharts

解决方案


没有像line.
在 API 参考中,您可能会找到可用的。

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


推荐阅读