From e36148772f4a9cda08696f04b4e635bd8322db50 Mon Sep 17 00:00:00 2001 From: glitch4347 Date: Mon, 27 May 2024 17:52:30 +0200 Subject: [PATCH] mouse over event type and it's calling --- src/VueChartwerkPodMixin.ts | 12 +++++++++--- src/index.ts | 2 +- src/models/options.ts | 6 ++++++ src/types.ts | 1 + 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/VueChartwerkPodMixin.ts b/src/VueChartwerkPodMixin.ts index 4d0e75b..2519361 100644 --- a/src/VueChartwerkPodMixin.ts +++ b/src/VueChartwerkPodMixin.ts @@ -39,9 +39,9 @@ export default { }, methods: { // it's "abstract" method. "children" components should override it - render() { }, - renderSharedCrosshair(values: { x?: number, y?: number }) { }, - hideSharedCrosshair() { }, + render() {}, + renderSharedCrosshair(values: { x?: number, y?: number }) {}, + hideSharedCrosshair() {}, onPanningRescale(event) { this.pod.rescaleMetricAndAxis(event); }, @@ -63,6 +63,9 @@ export default { if(has(this.$listeners, 'zoomOut')) { 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')) { this.options.events.mouseMove = this.mouseMove.bind(this); } @@ -97,6 +100,9 @@ export default { zoomOut(centers) { this.$emit('zoomOut', centers); }, + mouseOver() { + this.$emit('mouseOver'); + }, mouseMove(evt) { this.$emit('mouseMove', evt); }, diff --git a/src/index.ts b/src/index.ts index 5264707..567d0c1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -155,7 +155,7 @@ class ChartwerkPod { protected onMouseOver(): void {} protected onMouseOut(): void {} protected onMouseMove(): void {} - protected onMouseClick(): void { } + protected onMouseClick(): void {} public renderSharedCrosshair(values: { x?: number, y?: number }): void {} public hideSharedCrosshair(): void {} diff --git a/src/models/options.ts b/src/models/options.ts index 47814e4..e0af714 100644 --- a/src/models/options.ts +++ b/src/models/options.ts @@ -226,6 +226,12 @@ export class CoreOptions { } } + callbackMouseOver(): void { + if(has(this._options.events, 'mouseOver')) { + this._options.events.mouseOver(); + } + } + callbackMouseMove(event): void { if(has(this._options.events, 'mouseMove')) { this._options.events.mouseMove(event); diff --git a/src/types.ts b/src/types.ts index 193e500..fdecf55 100644 --- a/src/types.ts +++ b/src/types.ts @@ -20,6 +20,7 @@ export type Events = { panning?: (event: { ranges: AxisRange[], d3Event: any }) => void, panningEnd?: (range: AxisRange[]) => void, zoomOut?: (centers: {x: number, y: number}) => void, + mouseOver?: () => void, mouseMove?: (evt: any) => void, mouseClick?: (evt: any) => void, mouseOut?: () => void,