Skip to content

Commit 93e1076

Browse files
committed
fix: conditionally use of specific props to avoid ECharts error print when using the prop use
1 parent ae6bd50 commit 93e1076

File tree

2 files changed

+67
-46
lines changed

2 files changed

+67
-46
lines changed

example/src/App.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
import { useState } from 'react'
22
import { EChart } from '@kbox-labs/react-echarts'
33

4+
import { LineChart } from 'echarts/charts'
5+
import { LabelLayout } from 'echarts/features'
6+
import { CanvasRenderer } from 'echarts/renderers'
7+
import {
8+
TitleComponent,
9+
TooltipComponent,
10+
GridComponent
11+
} from 'echarts/components'
12+
413
function MyChart2() {
514
return (
615
<EChart
16+
use={[
17+
LineChart,
18+
TitleComponent,
19+
TooltipComponent,
20+
GridComponent,
21+
CanvasRenderer
22+
]}
723
group='group1'
824
// animation={false}
925
style={{

src/use-echarts.ts

Lines changed: 51 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -171,59 +171,63 @@ export function useECharts<T extends HTMLElement>({
171171
if (!echartsInstance) return
172172

173173
if (group) echartsInstance.group = group
174-
}, [group, started])
174+
}, [group, started, echartsInstance])
175175

176176
useEffect(() => {
177177
if (!echartsInstance) return
178178

179179
echartsInstance.clear()
180180
echartsInstance.setOption(
181181
{
182-
angleAxis,
183-
animation,
184-
animationDelay,
185-
animationDelayUpdate,
186-
animationDuration,
187-
animationDurationUpdate,
188-
animationEasing,
189-
animationEasingUpdate,
190-
animationThreshold,
191-
aria,
192-
axisPointer,
193-
backgroundColor,
194-
blendMode,
195-
brush,
196-
calendar,
197-
color,
198-
darkMode,
199-
dataset,
200-
dataZoom,
201-
geo,
202-
graphic,
203-
grid,
204-
hoverLayerThreshold,
205-
legend,
206-
media,
207-
options,
208-
parallel,
209-
parallelAxis,
210-
polar,
211-
progressive,
212-
progressiveThreshold,
213-
radar,
214-
radiusAxis,
215182
series,
216-
singleAxis,
217-
stateAnimation,
218-
textStyle,
219-
timeline,
220-
title,
221-
toolbox,
222-
tooltip,
223183
useUTC,
224-
visualMap,
225184
xAxis,
226-
yAxis
185+
yAxis,
186+
progressive,
187+
blendMode,
188+
hoverLayerThreshold,
189+
progressiveThreshold,
190+
...(angleAxis && { angleAxis }),
191+
...(animation && { animation }),
192+
...(animationDelay && { animationDelay }),
193+
...(animationDelayUpdate && { animationDelayUpdate }),
194+
...(animationDuration && { animationDuration }),
195+
...(animationDurationUpdate && { animationDurationUpdate }),
196+
...(animationEasing && { animationEasing }),
197+
...(animationEasingUpdate && { animationEasingUpdate }),
198+
...(animationThreshold && { animationThreshold }),
199+
...(aria && { aria }),
200+
...(axisPointer && { axisPointer }),
201+
...(backgroundColor && { backgroundColor }),
202+
...(brush && { brush }),
203+
...(calendar && { calendar }),
204+
...(color && { color }),
205+
...(darkMode && { darkMode }),
206+
...(dataset && { dataset }),
207+
...(dataZoom && { dataZoom }),
208+
...(geo && { geo }),
209+
...(graphic && { graphic }),
210+
...(grid && { grid }),
211+
...(legend && { legend }),
212+
...(media && { media }),
213+
...(options && { options }),
214+
...(parallel && { parallel }),
215+
...(parallelAxis && { parallelAxis }),
216+
...(polar && { polar }),
217+
...(radar && { radar }),
218+
...(radiusAxis && { radiusAxis }),
219+
...(series && { series }),
220+
...(singleAxis && { singleAxis }),
221+
...(stateAnimation && { stateAnimation }),
222+
...(textStyle && { textStyle }),
223+
...(timeline && { timeline }),
224+
...(title && { title }),
225+
...(toolbox && { toolbox }),
226+
...(tooltip && { tooltip }),
227+
...(useUTC && { useUTC }),
228+
...(visualMap && { visualMap }),
229+
...(xAxis && { xAxis }),
230+
...(yAxis && { yAxis })
227231
},
228232
{
229233
lazyUpdate,
@@ -288,7 +292,8 @@ export function useECharts<T extends HTMLElement>({
288292
transition,
289293

290294
//
291-
started
295+
started,
296+
echartsInstance
292297
])
293298

294299
useEffect(() => {
@@ -431,8 +436,8 @@ export function useECharts<T extends HTMLElement>({
431436
onTimelineChanged,
432437
onTimelinePlayChanged,
433438

434-
//
435-
started
439+
started,
440+
echartsInstance
436441
])
437442

438443
return [setContainerRef, echartsRef.current]

0 commit comments

Comments
 (0)