Highcharts Demo

author(s): Torstein Hønsi

by Alagar Kamuthurai

HTML

<script src="https://code.highcharts.com/highcharts.js"></script>

<div id="container"></div>
<button id="btn1">Add plotLine</button>
<button id="btn2">Delete plotLine</button>
<button id="btn3">Update yAxis</button>

JavaScript

let plotLines = [],
  chart = Highcharts.chart('container', {

    series: [{
      data: [4, 3, 5, 6, 2, 3]
    }]

  });

btn1.addEventListener('click', () => {
  chart.yAxis[0].addPlotLine({
    value: 4.5,
    color: 'red',
    width: 2,
    id: 'first'
  });
  
});

btn2.addEventListener('click', () => {
  //plotLines[0].destroy();
  console.log(chart.yAxis[0])
  //chart.yAxis[0].removePlotLine('first');
});

btn3.addEventListener('click', () => {
  chart.yAxis[0].update({});
});