I need to add the mouse wheel in the highcharts vertical scrollbar. I got the code in this fiddle http://jsfiddle.net/d3r8pb7c/ but that code written in jQuery format. When i try to add the code in the typescript in the following way mouse wheel not working.
this.options = {
chart: {
events: {
wheel: function (event) {
var delta, extr, step, newMin, newMax, axis = this.xAxis[0];
var dataMax = this.xAxis[0].dataMax,
dataMin = this.xAxis[0].dataMin,
newExtrMin,
newExtrMax;
e = this.pointer.normalize(event);
delta = e.detail || -(e.deltaY / 120);
delta = delta < 0 ? 1 : -1;
if (this.isInsidePlot(e.chartX - this.plotLeft, e.chartY - this.plotTop)) {
extr = axis.getExtremes();
step = (extr.max - extr.min) / 5 * delta;
if ((extr.min + step) <= dataMin) {
newExtrMin = dataMin;
newExtrMax = extr.max;
} else if ((extr.max + step) >= dataMax) {
newExtrMin = extr.min;
newExtrMax = dataMax;
} else {
newExtrMin = extr.min + step;
newExtrMax = extr.max + step;
}
axis.setExtremes(newExtrMin, newExtrMax, true, false);
}
stopEvent(event); // Issue #5011, returning false from non-jQuery event does not prevent default
return false;
},
}
},
Please help me if anyone add the mouse wheel event in the Highcharts angular2 typescript.
First of all, the code is not dependent on jQuery, so it's not necessary to import it.
I tried to include the code from the attached JSFiddle, by creating new module and importing it in within the component file. Actually, I don't know what you're doing wrong, but my example is working well.
import Stock from 'highcharts/modules/stock';
import Wheel from '../plugins/wheel-event'
Stock(Highcharts)
Wheel(Highcharts)
Live example: https://stackblitz.com/edit/highcharts-cloning-chart-s7kztw