Highcharts test tool

by Black Label

HTML

<script src="https://github.highcharts.com/master/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>

<div id="container"></div>

CSS

#container {
    min-width: 300px;
    max-width: 800px;
    height: 300px;
    margin: 1em auto;
}

JavaScript

(function(H) {
  const {
    pick,
    defined,
    isObject
  } = H;
  H.Chart.prototype.zoom = function(event) {
    const chart = this,
      pointer = chart.pointer;
    let displayButton = false,
      hasZoomed;
    // If zoom is called with no arguments, reset the axes
    if (!event || event.resetSelection) {
      chart.axes.forEach(function(axis) {
        hasZoomed = axis.zoom();
      });
      pointer.initiated = false; // #6804
    } else { // else, zoom in on all axes
      event.xAxis.concat(event.yAxis).forEach(function(axisData) {
        const axis = axisData.axis,
          isXAxis = axis.isXAxis;
        // don't zoom more than minRange
        if (pointer[isXAxis ? 'zoomX' : 'zoomY'] &&
          (defined(pointer.mouseDownX) &&
            defined(pointer.mouseDownY) &&
            chart.isInsidePlot(pointer.mouseDownX - chart.plotLeft, pointer.mouseDownY - chart.plotTop, {
              axis,
              ignoreX: pointer.hasPinched,
              ignoreY: pointer.hasPinched
            })) || !defined(chart.inverted ? pointer.mouseDownX : pointer.mouseDownY)) {
          hasZoomed = axis.zoom(axisData.min, axisData.max);
          if (axis.displayBtn) {
            displayButton = true;
          }
        }
      });
    }
    // Show or hide the Reset zoom button
    const resetZoomButton = chart.resetZoomButton;
    if (displayButton && !resetZoomButton) {
      chart.showResetZoom();
    } else if (!displayButton && isObject(resetZoomButton)) {
      chart.resetZoomButton = resetZoomButton.destroy();
    }
    // Redraw
    if (hasZoomed) {
      chart.redraw(pick(chart.options.chart.animation, event && event.animation, chart.pointCount < 100));
    }
  }
})(Highcharts);

Highcharts.chart('container', {
  chart: {
    zooming: {
      type: "x"
    },
  },
  series: [{
    data: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
    type: 'line'
  }]
});