Highcharts Demo

author(s): Torstein Hønsi

by AlexLvovsky

HTML

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>

<div id="container" style="height: 400px"></div>
<div id="report"></div>

CSS

.testIcon {
  font-family: 'Glyphicons Halflings';
}

.testIcon::before {
  content: '/e015';
}

JavaScript

// create the chart
Highcharts.chart('container', {
  chart: {
    events: {
      selection: function(event) {
        event.preventDefault();
        const axis = event.xAxis[0].axis;
        axis.removePlotBand('selection-plot-band');
        axis.addPlotBand({
          color: Highcharts.Color('#335cad').setOpacity(0.25).get(),
          from: event.xAxis[0].min,
          to: event.xAxis[0].max,
          id: 'selection-plot-band',
          zIndex: 6
        });
        //removeButtons();
        Highcharts.applyzoombutton = this.renderer.button('Apply Zoom', null, null, function() {
            // some action
          }, {
            zIndex: 20
          }, null, null)
          .add()
          .align({
            align: 'left',
            x: calculateXPosition(event, 'apply'),
            y: event.originalEvent.layerY
          }, false, null)
          .attr({
            id: 'applyzoombutton'
          });
        //.addClass( "testIcon" );

        Highcharts.resetzoombutton = this.renderer.button('Reset Zoom', null, null, function() {
            removeButtons();
            axis.removePlotBand('selection-plot-band');
          }, {
            zIndex: 20
          }, null, null)
          .add()
          .align({
            align: 'left',
            x: calculateXPosition(event, 'reset'),
            y: event.originalEvent.layerY
          }, false, null)
          .attr({
            id: 'resetzoombutton'
          });
      }
    },
    zoomType: 'x'
  },
  title: {
    text: 'Chart selection demo'
  },
  subtitle: {
    text: 'Click and drag the plot area to draw a selection'
  },
  series: [{
    type: 'column',
    data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
  }, {
    data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4].reverse()
  }]
});

Highcharts.wrap(Highcharts.Pointer.prototype, 'drag', function(p, e) {
  myCallback(this, e);
  p.call(this,...