mouse over event type and it's calling #44

Merged
glitch4347 merged 1 commits from onmouseover-event-callback-#42 into main 6 months ago
  1. 12
      src/VueChartwerkPodMixin.ts
  2. 2
      src/index.ts
  3. 6
      src/models/options.ts
  4. 1
      src/types.ts

12
src/VueChartwerkPodMixin.ts

@ -39,9 +39,9 @@ export default {
}, },
methods: { methods: {
// it's "abstract" method. "children" components should override it // it's "abstract" method. "children" components should override it
render() { }, render() {},
renderSharedCrosshair(values: { x?: number, y?: number }) { }, renderSharedCrosshair(values: { x?: number, y?: number }) {},
hideSharedCrosshair() { }, hideSharedCrosshair() {},
onPanningRescale(event) { onPanningRescale(event) {
this.pod.rescaleMetricAndAxis(event); this.pod.rescaleMetricAndAxis(event);
}, },
@ -63,6 +63,9 @@ export default {
if(has(this.$listeners, 'zoomOut')) { if(has(this.$listeners, 'zoomOut')) {
this.options.events.zoomOut = this.zoomOut.bind(this); this.options.events.zoomOut = this.zoomOut.bind(this);
} }
if(has(this.$listeners, 'mouseOver')) {
this.options.events.mouseOver = this.mouseOver.bind(this);
}
if(has(this.$listeners, 'mouseMove')) { if(has(this.$listeners, 'mouseMove')) {
this.options.events.mouseMove = this.mouseMove.bind(this); this.options.events.mouseMove = this.mouseMove.bind(this);
} }
@ -97,6 +100,9 @@ export default {
zoomOut(centers) { zoomOut(centers) {
this.$emit('zoomOut', centers); this.$emit('zoomOut', centers);
}, },
mouseOver() {
this.$emit('mouseOver');
},
mouseMove(evt) { mouseMove(evt) {
this.$emit('mouseMove', evt); this.$emit('mouseMove', evt);
}, },

2
src/index.ts

@ -155,7 +155,7 @@ class ChartwerkPod<T extends Serie, O extends Options> {
protected onMouseOver(): void {} protected onMouseOver(): void {}
protected onMouseOut(): void {} protected onMouseOut(): void {}
protected onMouseMove(): void {} protected onMouseMove(): void {}
protected onMouseClick(): void { } protected onMouseClick(): void {}
public renderSharedCrosshair(values: { x?: number, y?: number }): void {} public renderSharedCrosshair(values: { x?: number, y?: number }): void {}
public hideSharedCrosshair(): void {} public hideSharedCrosshair(): void {}

6
src/models/options.ts

@ -226,6 +226,12 @@ export class CoreOptions<O extends Options> {
} }
} }
callbackMouseOver(): void {
if(has(this._options.events, 'mouseOver')) {
this._options.events.mouseOver();
}
}
callbackMouseMove(event): void { callbackMouseMove(event): void {
if(has(this._options.events, 'mouseMove')) { if(has(this._options.events, 'mouseMove')) {
this._options.events.mouseMove(event); this._options.events.mouseMove(event);

1
src/types.ts

@ -20,6 +20,7 @@ export type Events = {
panning?: (event: { ranges: AxisRange[], d3Event: any }) => void, panning?: (event: { ranges: AxisRange[], d3Event: any }) => void,
panningEnd?: (range: AxisRange[]) => void, panningEnd?: (range: AxisRange[]) => void,
zoomOut?: (centers: {x: number, y: number}) => void, zoomOut?: (centers: {x: number, y: number}) => void,
mouseOver?: () => void,
mouseMove?: (evt: any) => void, mouseMove?: (evt: any) => void,
mouseClick?: (evt: any) => void, mouseClick?: (evt: any) => void,
mouseOut?: () => void, mouseOut?: () => void,

Loading…
Cancel
Save