Highcharts动态添加/更改yAxis plotLines

jbo*_*nos 7 javascript highcharts

我试图让我的用户可以将最大plotLine添加到图表中,如果图表超过该行,则可以更改图表的背景颜色.我似乎无法获得更新情节线的方法.我试过了:

chart.yAxis[0].update({
    plotLines: [{
        id: 'limit-max',
        color: 'blue',
        dashStyle: 'LongDashDot',
        width: 1,
        value: 45000,
        zIndex: 0
    }]
});
Run Code Online (Sandbox Code Playgroud)

但我得到错误:

TypeError:a未定义

... dBands,函数(){a.render()}); N(this.series,函数的(a){!a.isDirty = 0})},... setCat

highcharts.js(第136行)

Seb*_*han 5

您只能销毁和创建新的plotLins,因为update()函数不可用.

  • 您可以使用addPlotLine函数来执行此操作.http://api.highcharts.com/highcharts#Axis.addPlotLine() (5认同)