Browse Source

ensure overlay existing

pull/2/head
vargburz 2 years ago
parent
commit
96f543d771
  1. 31
      src/index.ts

31
src/index.ts

@ -332,22 +332,9 @@ abstract class ChartwerkPod<T extends Serie, O extends Options> {
this.initBrush(); this.initBrush();
this.initPan(); this.initPan();
} }
this.ensureOverlayExisting();
setTimeout(() => { setTimeout(() => {
this.overlay = this.chartContainer.select('.overlay');
// init cumstom overlay to handle all events
if(isNil(this.overlay)) {
this.overlay = this.chartContainer.append('rect')
.attr('class', 'overlay')
.attr('width', this.width)
.attr('height', this.height)
.attr('x', 0)
.attr('y', 0)
.attr('pointer-events', 'all')
.attr('cursor', 'crosshair')
.attr('fill', 'none');
}
this.overlay this.overlay
.on('mouseover', this.onMouseOver.bind(this)) .on('mouseover', this.onMouseOver.bind(this))
.on('mouseout', this.onMouseOut.bind(this)) .on('mouseout', this.onMouseOut.bind(this))
@ -365,6 +352,22 @@ abstract class ChartwerkPod<T extends Serie, O extends Options> {
}, 0); }, 0);
} }
protected ensureOverlayExisting(): void {
this.overlay = this.chartContainer.select('.overlay');
// init cumstom overlay to handle all events
if(this.overlay.empty()) {
this.overlay = this.chartContainer.append('rect')
.attr('class', 'overlay')
.attr('width', this.width)
.attr('height', this.height)
.attr('x', 0)
.attr('y', 0)
.attr('pointer-events', 'all')
.attr('cursor', 'crosshair')
.attr('fill', 'none');
}
}
protected initBrush(): void { protected initBrush(): void {
const isBrushActive = this.options.mouseZoomEvent.isActive; const isBrushActive = this.options.mouseZoomEvent.isActive;
if(isBrushActive === false) { if(isBrushActive === false) {

Loading…
Cancel
Save