Highcharts Series Inactive

author(s): Torstein Hønsi

by nehamahajan

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>

<div id="container" style="height: 400px; width: 800px"></div>
<button id="addSeries">Add Series</button>

JavaScript

$("#addSeries").click(function() {
  var chart = $('#container').highcharts();
  chart.addSeries({
    data: [
      [1642103985193, 0.02483],
      [1642104885194, 0.02464],
      [1642105785235, 0.02495],
      [1642106685203, 0.02523],
      [1642107585218, 0.02563],
      [1642108485231, 0.02568],
      [1642109385288, 0.02538],
      [1642110285241, 0.02606],
      [1642111185268, 0.02428],
      [1642112085279, 0.02528],
      [1642112985311, 0.0255],
      [1642113885280, 0.02599],
      [1642114785284, 0.02547],
      [1642115685289, 1.60466],
      [1642116585330, 0.02603],
      [1642117485304, 0.02552],
      [1642118385313, 0.02603],
      [1642119285316, 0.0253],
      [1642120185333, 0.02569],
      [1642121085324, 0.02552]
    ]
  })
});

Highcharts.chart('container', {
  chart: {
    marginBottom: 80
  },
  plotOptions: {
    series: {
      marker: {
        enabled: false
      },
      states: {
        inactive: {
          enabled: false
        }
      }
    }
  },
  xAxis: {
    type: 'datetime',
    minTickInterval: _.noop,
    minRange: 600000
  },

  yAxis: {
    title: {
      text: null
    },
    minRange: 0.00001,
    lineWidth: 1,
    startOnTick: true,
    min: 0
  },
  tooltip: {
    positioner: function(boxWidth, boxHeight, point) {
      return {
        x: point.plotX < (this.chart.plotWidth * 0.75) ? this.chart.plotWidth - boxWidth + 35 : 50,
        y: 5
      };
    },
    shape: 'rect',
    useHTML: true,
    shadow: false
  },
  series: [{
      data: [
        [1642103985193, 0.024],
        [1642104885194, 0.0244],
        [1642105785235, 0.02375],
        [1642106685203, 0.027],
        [1642107585218, 0.02467],
        [1642108485231, 0.02304],
        [1642109385288, 0.03324],
        [1642110285241, 0.02525],
        [1642111185268, 0.02334],
        [1642112085279, 0.02412],
        [1642112985311, 0.02619],
        [1642113885280, 0.02444],
        [1642114785284, 0.02318],
        [1642115685289, 0.02731],
       ...