I'm trying to make it possible for my users to add a max plotLine to a chart and have it change the background color of the chart if a plot goes above that line. I can't seem to get a method to update the plotlines. I've tried:
chart.yAxis[0].update({
    plotLines: [{
        id: 'limit-max',
        color: 'blue',
        dashStyle: 'LongDashDot',
        width: 1,
        value: 45000,
        zIndex: 0
    }]
});
but I get the error:
TypeError: a is undefined
...dBands,function(a){a.render()});n(this.series,function(a){a.isDirty=!0})},setCat...
highcharts.js (line 136)
You can only destroy and create new plotLins, because update() function is not available.
just add this code and then you can use the plotline.update method
    //Add support for update method
    Highcharts.PlotLineOrBand.prototype.update = function (newOptions){
        var plotBand = this;
        Highcharts.extend(plotBand.options, newOptions);
        if (plotBand.svgElem) {
            plotBand.svgElem.destroy();
            plotBand.svgElem = undefined;
            plotBand.render();
        }
    }
Here's what worked for me http://jsfiddle.net/tx1kt0bj/2/
var plotBand = tempAxis.plotLinesAndBands[0];
$.extend(plotBand.options, {
    color: '#000',
    to: 10,
    from: 2
});
plotBand.svgElem.destroy();
plotBand.svgElem = undefined;
plotBand.render();
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With