@@ -63,14 +63,11 @@ EChartsTmpComp = withViewFn(EChartsTmpComp, (comp) => {
63
63
lng : comp . children . mapCenterLng . getView ( ) ,
64
64
lat : comp . children . mapCenterLat . getView ( ) ,
65
65
}
66
- const mapZoomlevel = comp . children . mapZoomLevel . getView ( ) ;
67
66
const onUIEvent = comp . children . onUIEvent . getView ( ) ;
68
- const onMapEvent = comp . children . onMapEvent . getView ( ) ;
69
67
const onEvent = comp . children . onEvent . getView ( ) ;
70
68
71
69
const echartsCompRef = useRef < ReactECharts | null > ( ) ;
72
70
const [ chartSize , setChartSize ] = useState < ChartSize > ( ) ;
73
- const [ mapScriptLoaded , setMapScriptLoaded ] = useState ( false ) ;
74
71
const firstResize = useRef ( true ) ;
75
72
const theme = useContext ( ThemeContext ) ;
76
73
const defaultChartTheme = {
@@ -95,9 +92,6 @@ EChartsTmpComp = withViewFn(EChartsTmpComp, (comp) => {
95
92
}
96
93
97
94
useEffect ( ( ) => {
98
- // click events for JSON/Map mode
99
- if ( mode === 'ui' ) return ;
100
-
101
95
const echartsCompInstance = echartsCompRef ?. current ?. getEchartsInstance ( ) ;
102
96
if ( ! echartsCompInstance ) {
103
97
return _ . noop ;
@@ -119,12 +113,9 @@ EChartsTmpComp = withViewFn(EChartsTmpComp, (comp) => {
119
113
echartsCompInstance ?. off ( "click" ) ;
120
114
document . removeEventListener ( 'clickEvent' , clickEventCallback )
121
115
} ;
122
- } , [ mode , mapScriptLoaded ] ) ;
116
+ } , [ ] ) ;
123
117
124
118
useEffect ( ( ) => {
125
- // click events for UI mode
126
- if ( mode !== 'ui' ) return ;
127
-
128
119
// bind events
129
120
const echartsCompInstance = echartsCompRef ?. current ?. getEchartsInstance ( ) ;
130
121
if ( ! echartsCompInstance ) {
@@ -161,7 +152,7 @@ EChartsTmpComp = withViewFn(EChartsTmpComp, (comp) => {
161
152
echartsCompInstance ?. off ( "selectchanged" ) ;
162
153
document . removeEventListener ( 'clickEvent' , clickEventCallback )
163
154
} ;
164
- } , [ mode , onUIEvent ] ) ;
155
+ } , [ onUIEvent ] ) ;
165
156
166
157
const echartsConfigChildren = _ . omit ( comp . children , echartsConfigOmitChildren ) ;
167
158
const option = useMemo ( ( ) => {
@@ -171,55 +162,10 @@ EChartsTmpComp = withViewFn(EChartsTmpComp, (comp) => {
171
162
) ;
172
163
} , [ chartSize , ...Object . values ( echartsConfigChildren ) ] ) ;
173
164
174
- const isMapScriptLoaded = useMemo ( ( ) => {
175
- return mapScriptLoaded || window ?. google ;
176
- } , [ mapScriptLoaded ] )
177
-
178
- const loadGoogleMapData = ( ) => {
179
- const echartsCompInstance = echartsCompRef ?. current ?. getEchartsInstance ( ) ;
180
- if ( ! echartsCompInstance ) {
181
- return _ . noop ;
182
- }
183
-
184
- comp . children . mapInstance . dispatch ( changeValueAction ( echartsCompInstance ) )
185
- onMapEvent ( 'mapReady' )
186
- }
187
-
188
- const handleOnMapScriptLoad = ( ) => {
189
- setMapScriptLoaded ( true ) ;
190
- setTimeout ( ( ) => {
191
- loadGoogleMapData ( ) ;
192
- } )
193
- }
194
-
195
165
useEffect ( ( ) => {
196
- if ( mode !== 'map' ) {
197
- comp . children . mapInstance . dispatch ( changeValueAction ( null , false ) )
198
- return ;
199
- }
200
-
166
+ comp . children . mapInstance . dispatch ( changeValueAction ( null , false ) )
201
167
if ( comp . children . mapInstance . value ) return ;
202
-
203
- const gMapScript = loadGoogleMapsScript ( apiKey ) ;
204
- if ( isMapScriptLoaded ) {
205
- handleOnMapScriptLoad ( ) ;
206
- return ;
207
- }
208
- gMapScript . addEventListener ( 'load' , handleOnMapScriptLoad ) ;
209
- return ( ) => {
210
- gMapScript . removeEventListener ( 'load' , handleOnMapScriptLoad ) ;
211
- }
212
- } , [ mode , apiKey , option ] )
213
-
214
- useEffect ( ( ) => {
215
- if ( mode !== 'map' ) return ;
216
- onMapEvent ( 'centerPositionChange' ) ;
217
- } , [ mode , mapCenterPosition . lat , mapCenterPosition . lng ] )
218
-
219
- useEffect ( ( ) => {
220
- if ( mode !== 'map' ) return ;
221
- onMapEvent ( 'zoomLevelChange' ) ;
222
- } , [ mode , mapZoomlevel ] )
168
+ } , [ option ] )
223
169
224
170
return (
225
171
< ReactResizeDetector
@@ -375,61 +321,6 @@ let EChartsComp = withExposingConfigs(EChartsTmpComp, [
375
321
new NameConfig ( "title" , trans ( "chart.titleDesc" ) ) ,
376
322
] ) ;
377
323
378
- EChartsComp = withMethodExposing ( EChartsComp , [
379
- {
380
- method : {
381
- name : "getMapInstance" ,
382
- } ,
383
- execute : ( comp ) => {
384
- return new Promise ( resolve => {
385
- let intervalCount = 0 ;
386
- const mapInstanceInterval = setInterval ( ( ) => {
387
- const instance = comp . children . mapInstance . getView ( ) ;
388
- const mapInstance = instance ?. getModel ( ) ?. getComponent ( "gmap" ) ?. getGoogleMap ( )
389
- if ( mapInstance || intervalCount === 10 ) {
390
- clearInterval ( mapInstanceInterval )
391
- resolve ( mapInstance )
392
- }
393
- intervalCount ++ ;
394
- } , 1000 ) ;
395
- } )
396
- }
397
- } ,
398
- {
399
- method : {
400
- name : "getMapZoomLevel" ,
401
- } ,
402
- execute : ( comp ) => {
403
- return comp . children . mapZoomLevel . getView ( ) ;
404
- }
405
- } ,
406
- {
407
- method : {
408
- name : "getMapCenterPosition" ,
409
- } ,
410
- execute : ( comp ) => {
411
- return Promise . resolve ( {
412
- lng : comp . children . mapCenterLng . getView ( ) ,
413
- lat : comp . children . mapCenterLat . getView ( ) ,
414
- } ) ;
415
- }
416
- } ,
417
- {
418
- method : {
419
- name : "onClick" ,
420
- params : [
421
- {
422
- name : "callback" ,
423
- type : "function" ,
424
- } ,
425
- ] ,
426
- } ,
427
- execute : ( comp , params ) => {
428
- clickEventCallback = params [ 0 ] ;
429
- document . addEventListener ( 'clickEvent' , clickEventCallback ) ;
430
- }
431
- } ,
432
- ] )
433
324
434
325
export const EChartsCompWithDefault = withDefault ( EChartsComp , {
435
326
xAxisKey : "date" ,
0 commit comments