Skip to content

Commit 8397a7b

Browse files
committed
opt: opt overlay trigger event display
1 parent 8c64b0f commit 8397a7b

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

src/Event.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,11 @@ export default class Event implements EventHandler {
193193
const consumed = widget.dispatchEvent('mouseMoveEvent', event)
194194
const chartStore = this._chart.getChartStore()
195195
let crosshair: Crosshair | undefined = { x: event.x, y: event.y, paneId: pane?.getId() }
196-
if (consumed && chartStore.getActiveTooltipIcon() !== null) {
196+
if (consumed && !chartStore.isOverlayDrawing()) {
197197
crosshair = undefined
198198
widget.getContainer().style.cursor = 'pointer'
199+
} else {
200+
widget.getContainer().style.cursor = 'crosshair'
199201
}
200202
this._chart.getChartStore().setCrosshair(crosshair)
201203
return consumed
@@ -226,11 +228,14 @@ export default class Event implements EventHandler {
226228
const name = widget.getName()
227229
switch (name) {
228230
case WidgetNameConstants.MAIN: {
231+
// eslint-disable-next-line @typescript-eslint/init-declarations -- ignore
232+
let crosshair: Crosshair | undefined
229233
const consumed = widget.dispatchEvent('pressedMouseMoveEvent', event)
230234
if (!consumed) {
235+
crosshair = { x: event.x, y: event.y, paneId: pane?.getId() }
231236
this._processMainScrollingEvent(widget as Widget<DrawPane<YAxis>>, event)
232237
}
233-
this._chart.getChartStore().setCrosshair({ x: event.x, y: event.y, paneId: pane?.getId() })
238+
this._chart.getChartStore().setCrosshair(crosshair, { forceInvalidate: true })
234239
return consumed
235240
}
236241
case WidgetNameConstants.X_AXIS: {

src/Store.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -901,9 +901,9 @@ export default class StoreImp implements Store {
901901

902902
setCrosshair (
903903
crosshair?: Crosshair,
904-
options?: { notInvalidate?: boolean, notExecuteAction?: boolean }
904+
options?: { notInvalidate?: boolean, notExecuteAction?: boolean, forceInvalidate?: boolean }
905905
): void {
906-
const { notInvalidate, notExecuteAction } = options ?? {}
906+
const { notInvalidate, notExecuteAction, forceInvalidate } = options ?? {}
907907
const cr = crosshair ?? {}
908908
let realDataIndex = 0
909909
let dataIndex = 0
@@ -925,7 +925,10 @@ export default class StoreImp implements Store {
925925
const prevCrosshair = { x: this._crosshair.x, y: this._crosshair.y, paneId: this._crosshair.paneId }
926926
this._crosshair = { ...cr, realX, kLineData, realDataIndex, dataIndex, timestamp: this.dataIndexToTimestamp(realDataIndex) ?? undefined }
927927
if (
928-
prevCrosshair.x !== cr.x || prevCrosshair.y !== cr.y || prevCrosshair.paneId !== cr.paneId
928+
prevCrosshair.x !== cr.x ||
929+
prevCrosshair.y !== cr.y ||
930+
prevCrosshair.paneId !== cr.paneId ||
931+
(forceInvalidate ?? false)
929932
) {
930933
if (isValid(kLineData) && !(notExecuteAction ?? false)) {
931934
this._chart.crosshairChange(this._crosshair)

src/view/OverlayView.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
215215
pane.getChart().getChartStore().setHoverOverlayInfo(
216216
{ paneId: pane.getId(), overlay, figureType, figure, figureIndex }, event
217217
)
218-
return true
218+
return checkOverlayFigureEvent('onMouseEnter', figure)
219219
}
220220
}
221221

@@ -238,7 +238,7 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
238238
const pane = this.getWidget().getPane()
239239
const paneId = pane.getId()
240240
pane.getChart().getChartStore().setClickOverlayInfo({ paneId, overlay, figureType, figureIndex, figure }, event)
241-
return true
241+
return checkOverlayFigureEvent('onClick', figure)
242242
}
243243
}
244244

0 commit comments

Comments
 (0)