in src/TornadoChartScrolling.ts [85:140]
public renderY(data: TornadoChartDataView, onScroll: () => {}): void {
this.isYScrollBarVisible = this.isScrollable
&& this.getPrefferedHeight() > this.viewport.height
&& this.viewport.height > 0
&& this.viewport.width > 0;
this.brushGraphicsContextY = this.createOrRemoveScrollbar(this.isYScrollBarVisible, this.brushGraphicsContextY, "y brush");
if (!this.isYScrollBarVisible) {
onScroll.call(this, jQuery.extend(true, {}, data), 0, 1);
return;
}
let scrollSpaceLength: number = this.viewport.height;
let extentData: any = this.getExtentData(this.getPrefferedHeight(), scrollSpaceLength);
let getEvent = () => require("d3-selection").event;
let onRender = (selection: any = getEvent() && getEvent().selection, wheelDelta: number = 0) => {
let position = selection || extentData.value;
if (wheelDelta !== 0) {
// Handle mouse wheel manually by moving the scrollbar half of its size
let halfScrollsize: number = (position[1] - position[0]) / 2;
position[0] += (wheelDelta > 0) ? halfScrollsize : -halfScrollsize;
position[1] += (wheelDelta > 0) ? halfScrollsize : -halfScrollsize;
if (position[0] < 0) {
let offset: number = -position[0];
position[0] += offset;
position[1] += offset;
}
if (position[1] > scrollSpaceLength) {
let offset: number = position[1] - scrollSpaceLength;
position[0] -= offset;
position[1] -= offset;
}
// Update the scroll bar accordingly and redraw
this.scrollYBrush.move(this.brushGraphicsContextY, position);
this.brushGraphicsContextY.select(".selection").attr("y", position[0]);
}
let scrollPosition: number[] = extentData.toScrollPosition(position, scrollSpaceLength);
onScroll.call(this, jQuery.extend(true, {}, data), scrollPosition[0], scrollPosition[1]);
};
this.scrollYBrush.extent([[0, 0], [TornadoChart.ScrollBarWidth, this.viewport.height]]);
this.renderScrollbar(
this.scrollYBrush,
this.brushGraphicsContextY,
this.viewport.width,
extentData.value[1],
onRender
);
onRender();
}