Skip to content

Commit b4dc054

Browse files
committed
Update
1 parent 216cc3d commit b4dc054

File tree

2 files changed

+40
-10
lines changed

2 files changed

+40
-10
lines changed

src/echart.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,15 @@
22
import { useECharts } from './use-echarts'
33

44
// Types
5+
import type { EChartsEventProp } from './events'
56
import type { UseEChartsOptions } from './use-echarts'
67
import type { FC, HTMLAttributes } from 'react'
78

8-
type ContainerProps = Omit<
9-
HTMLAttributes<HTMLDivElement>,
10-
| 'onClick'
11-
| 'onDoubleClick'
12-
| 'onMouseDown'
13-
| 'onMouseMove'
14-
| 'onMouseOut'
15-
| 'onMouseOver'
16-
>
17-
export type EChartProps = ContainerProps & UseEChartsOptions
9+
export type EChartProps = UseEChartsOptions &
10+
Omit<
11+
HTMLAttributes<HTMLDivElement>,
12+
keyof UseEChartsOptions | EChartsEventProp
13+
>
1814

1915
export const EChart: FC<EChartProps> = ({
2016
// Init

src/use-echarts.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,105 +318,139 @@ export function useECharts<T extends HTMLElement>({
318318
if (!echartsInstance) return
319319

320320
if (onAxisAreaSelected) {
321+
echartsInstance.off(ev.onAxisAreaSelected)
321322
echartsInstance.on(ev.onAxisAreaSelected, onAxisAreaSelected)
322323
}
323324
if (onBrush) {
325+
echartsInstance.off(ev.onBrush)
324326
echartsInstance.on(ev.onBrush, onBrush)
325327
}
326328
if (onBrushEnd) {
329+
echartsInstance.off(ev.onBrushEnd)
327330
echartsInstance.on(ev.onBrushEnd, onBrushEnd)
328331
}
329332
if (onBrushSelected) {
333+
echartsInstance.off(ev.onBrushSelected)
330334
echartsInstance.on(ev.onBrushSelected, onBrushSelected)
331335
}
332336
if (onClick) {
337+
echartsInstance.off(ev.onClick)
333338
echartsInstance.on(ev.onClick, onClick)
334339
}
335340
if (onContextMenu) {
341+
echartsInstance.off(ev.onContextMenu)
336342
echartsInstance.on(ev.onContextMenu, onContextMenu)
337343
}
338344
if (onDataRangeSelected) {
345+
echartsInstance.off(ev.onDataRangeSelected)
339346
echartsInstance.on(ev.onDataRangeSelected, onDataRangeSelected)
340347
}
341348
if (onDataViewChanged) {
349+
echartsInstance.off(ev.onDataViewChanged)
342350
echartsInstance.on(ev.onDataViewChanged, onDataViewChanged)
343351
}
344352
if (onDataZoom) {
353+
echartsInstance.off(ev.onDataZoom)
345354
echartsInstance.on(ev.onDataZoom, onDataZoom)
346355
}
347356
if (onDoubleClick) {
357+
echartsInstance.off(ev.onDoubleClick)
348358
echartsInstance.on(ev.onDoubleClick, onDoubleClick)
349359
}
350360
if (onDownplay) {
361+
echartsInstance.off(ev.onDownplay)
351362
echartsInstance.on(ev.onDownplay, onDownplay)
352363
}
353364
if (onFinished) {
365+
echartsInstance.off(ev.onFinished)
354366
echartsInstance.on(ev.onFinished, onFinished)
355367
}
356368
if (onGeoSelectChanged) {
369+
echartsInstance.off(ev.onGeoSelectChanged)
357370
echartsInstance.on(ev.onGeoSelectChanged, onGeoSelectChanged)
358371
}
359372
if (onGeoSelected) {
373+
echartsInstance.off(ev.onGeoSelected)
360374
echartsInstance.on(ev.onGeoSelected, onGeoSelected)
361375
}
362376
if (onGeoUnselected) {
377+
echartsInstance.off(ev.onGeoUnselected)
363378
echartsInstance.on(ev.onGeoUnselected, onGeoUnselected)
364379
}
365380
if (onGlobalCursorTaken) {
381+
echartsInstance.off(ev.onGlobalCursorTaken)
366382
echartsInstance.on(ev.onGlobalCursorTaken, onGlobalCursorTaken)
367383
}
368384
if (onGlobalOut) {
385+
echartsInstance.off(ev.onGlobalOut)
369386
echartsInstance.on(ev.onGlobalOut, onGlobalOut)
370387
}
371388
if (onHighlight) {
389+
echartsInstance.off(ev.onHighlight)
372390
echartsInstance.on(ev.onHighlight, onHighlight)
373391
}
374392
if (onLegendInverseSelect) {
393+
echartsInstance.off(ev.onLegendInverseSelect)
375394
echartsInstance.on(ev.onLegendInverseSelect, onLegendInverseSelect)
376395
}
377396
if (onLegendScroll) {
397+
echartsInstance.off(ev.onLegendScroll)
378398
echartsInstance.on(ev.onLegendScroll, onLegendScroll)
379399
}
380400
if (onLegendScroll) {
401+
echartsInstance.off(ev.onLegendScroll)
381402
echartsInstance.on(ev.onLegendScroll, onLegendScroll)
382403
}
383404
if (onLegendSelectChanged) {
405+
echartsInstance.off(ev.onLegendSelectChanged)
384406
echartsInstance.on(ev.onLegendSelectChanged, onLegendSelectChanged)
385407
}
386408
if (onLegendSelected) {
409+
echartsInstance.off(ev.onLegendSelected)
387410
echartsInstance.on(ev.onLegendSelected, onLegendSelected)
388411
}
389412
if (onLegendUnselected) {
413+
echartsInstance.off(ev.onLegendUnselected)
390414
echartsInstance.on(ev.onLegendUnselected, onLegendUnselected)
391415
}
392416
if (onMagicTypeChanged) {
417+
echartsInstance.off(ev.onMagicTypeChanged)
393418
echartsInstance.on(ev.onMagicTypeChanged, onMagicTypeChanged)
394419
}
395420
if (onMouseDown) {
421+
echartsInstance.off(ev.onMouseDown)
396422
echartsInstance.on(ev.onMouseDown, onMouseDown)
397423
}
398424
if (onMouseMove) {
425+
echartsInstance.off(ev.onMouseMove)
399426
echartsInstance.on(ev.onMouseMove, onMouseMove)
400427
}
401428
if (onMouseOut) {
429+
echartsInstance.off(ev.onMouseOut)
402430
echartsInstance.on(ev.onMouseOut, onMouseOut)
403431
}
404432
if (onMouseOver) {
433+
echartsInstance.off(ev.onMouseOver)
405434
echartsInstance.on(ev.onMouseOver, onMouseOver)
406435
}
407436
if (onRendered) {
437+
echartsInstance.off(ev.onRendered)
408438
echartsInstance.on(ev.onRendered, onRendered)
409439
}
410440
if (onRestore) {
441+
echartsInstance.off(ev.onRestore)
411442
echartsInstance.on(ev.onRestore, onRestore)
412443
}
413444
if (onSelectChanged) {
445+
echartsInstance.off(ev.onSelectChanged)
414446
echartsInstance.on(ev.onSelectChanged, onSelectChanged)
415447
}
416448
if (onTimelineChanged) {
449+
echartsInstance.off(ev.onTimelineChanged)
417450
echartsInstance.on(ev.onTimelineChanged, onTimelineChanged)
418451
}
419452
if (onTimelinePlayChanged) {
453+
echartsInstance.off(ev.onTimelinePlayChanged)
420454
echartsInstance.on(ev.onTimelinePlayChanged, onTimelinePlayChanged)
421455
}
422456
}, [

0 commit comments

Comments
 (0)