Skip to content

Commit eb882b0

Browse files
committed
removed unused code
1 parent f7e3a07 commit eb882b0

File tree

4 files changed

+16
-237
lines changed

4 files changed

+16
-237
lines changed

client/packages/lowcoder-comps/src/comps/chartComp/chartComp.tsx

Lines changed: 6 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ import {
1616
childrenToProps,
1717
depsConfig,
1818
genRandomKey,
19-
JSONObject,
20-
JSONValue,
2119
NameConfig,
22-
ToViewReturn,
2320
UICompBuilder,
2421
withDefault,
2522
withExposingConfigs,
@@ -36,7 +33,6 @@ import {
3633
echartsConfigOmitChildren,
3734
getEchartsConfig,
3835
getSelectedPoints,
39-
loadGoogleMapsScript,
4036
} from "comps/chartComp/chartUtils";
4137
import 'echarts-extension-gmap';
4238
import log from "loglevel";
@@ -57,20 +53,12 @@ let ChartTmpComp = (function () {
5753
})();
5854

5955
ChartTmpComp = withViewFn(ChartTmpComp, (comp) => {
60-
const apiKey = comp.children.mapApiKey.getView();
6156
const mode = comp.children.mode.getView();
62-
const mapCenterPosition = {
63-
lng: comp.children.mapCenterLng.getView(),
64-
lat: comp.children.mapCenterLat.getView(),
65-
}
66-
const mapZoomlevel = comp.children.mapZoomLevel.getView();
6757
const onUIEvent = comp.children.onUIEvent.getView();
68-
const onMapEvent = comp.children.onMapEvent.getView();
6958
const onEvent = comp.children.onEvent.getView();
7059

7160
const echartsCompRef = useRef<ReactECharts | null>();
7261
const [chartSize, setChartSize] = useState<ChartSize>();
73-
const [mapScriptLoaded, setMapScriptLoaded] = useState(false);
7462
const firstResize = useRef(true);
7563
const theme = useContext(ThemeContext);
7664
const defaultChartTheme = {
@@ -95,45 +83,13 @@ ChartTmpComp = withViewFn(ChartTmpComp, (comp) => {
9583
}
9684

9785
useEffect(() => {
98-
// click events for JSON/Map mode
99-
if (mode === 'ui') return;
100-
101-
const echartsCompInstance = echartsCompRef?.current?.getEchartsInstance();
102-
if (!echartsCompInstance) {
103-
return _.noop;
104-
}
105-
echartsCompInstance?.on("click", (param: any) => {
106-
document.dispatchEvent(new CustomEvent("clickEvent", {
107-
bubbles: true,
108-
detail: {
109-
action: 'click',
110-
data: param.data,
111-
}
112-
}));
113-
triggerClickEvent(
114-
comp.dispatch,
115-
changeChildAction("lastInteractionData", param.data, false)
116-
);
117-
});
118-
return () => {
119-
echartsCompInstance?.off("click");
120-
document.removeEventListener('clickEvent', clickEventCallback)
121-
};
122-
}, [mode, mapScriptLoaded]);
123-
124-
useEffect(() => {
125-
// click events for UI mode
126-
if(mode !== 'ui') return;
127-
12886
// bind events
12987
const echartsCompInstance = echartsCompRef?.current?.getEchartsInstance();
13088
if (!echartsCompInstance) {
13189
return _.noop;
13290
}
13391
echartsCompInstance?.on("selectchanged", (param: any) => {
13492
const option: any = echartsCompInstance?.getOption();
135-
//log.log("chart select change", param);
136-
// trigger click event listener
13793

13894
document.dispatchEvent(new CustomEvent("clickEvent", {
13995
bubbles: true,
@@ -161,7 +117,7 @@ ChartTmpComp = withViewFn(ChartTmpComp, (comp) => {
161117
echartsCompInstance?.off("selectchanged");
162118
document.removeEventListener('clickEvent', clickEventCallback)
163119
};
164-
}, [mode, onUIEvent]);
120+
}, [onUIEvent]);
165121

166122
const echartsConfigChildren = _.omit(comp.children, echartsConfigOmitChildren);
167123
const option = useMemo(() => {
@@ -171,55 +127,9 @@ ChartTmpComp = withViewFn(ChartTmpComp, (comp) => {
171127
);
172128
}, [chartSize, ...Object.values(echartsConfigChildren)]);
173129

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-
useEffect(() => {
196-
if( mode !== 'map') {
197-
comp.children.mapInstance.dispatch(changeValueAction(null, false))
198-
return;
199-
}
200-
201-
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-
219130
useEffect(() => {
220-
if(mode !== 'map') return;
221-
onMapEvent('zoomLevelChange');
222-
}, [mode, mapZoomlevel])
131+
comp.children.mapInstance.dispatch(changeValueAction(null, false))
132+
}, [option])
223133

224134
return (
225135
<ReactResizeDetector
@@ -235,18 +145,16 @@ ChartTmpComp = withViewFn(ChartTmpComp, (comp) => {
235145
}
236146
}}
237147
>
238-
{(mode !== 'map' || (mode === 'map' && isMapScriptLoaded)) && (
239-
<ReactECharts
148+
<ReactECharts
240149
ref={(e) => (echartsCompRef.current = e)}
241150
style={{ height: "100%" }}
242151
notMerge
243152
lazyUpdate
244153
opts={{ locale: getEchartsLocale() }}
245154
option={option}
246-
theme={mode !== 'map' ? themeConfig : undefined}
155+
theme={themeConfig}
247156
mode={mode}
248157
/>
249-
)}
250158
</ReactResizeDetector>
251159
);
252160
});
@@ -365,74 +273,11 @@ let ChartComp = withExposingConfigs(ChartTmpComp, [
365273
name: "data",
366274
desc: trans("chart.dataDesc"),
367275
depKeys: ["data", "mode"],
368-
func: (input) => {
369-
if (input.mode === "ui") {
370-
return input.data;
371-
} else {
372-
// no data in json mode
373-
return [];
374-
}
375-
},
276+
func: (input) => input.data,
376277
}),
377278
new NameConfig("title", trans("chart.titleDesc")),
378279
]);
379280

380-
ChartComp = withMethodExposing(ChartComp, [
381-
{
382-
method: {
383-
name: "getMapInstance",
384-
},
385-
execute: (comp) => {
386-
return new Promise(resolve => {
387-
let intervalCount = 0;
388-
const mapInstanceInterval = setInterval(() => {
389-
const instance = comp.children.mapInstance.getView();
390-
const mapInstance = instance?.getModel()?.getComponent("gmap")?.getGoogleMap()
391-
if(mapInstance || intervalCount === 10) {
392-
clearInterval(mapInstanceInterval)
393-
resolve(mapInstance)
394-
}
395-
intervalCount++;
396-
}, 1000);
397-
})
398-
}
399-
},
400-
{
401-
method: {
402-
name: "getMapZoomLevel",
403-
},
404-
execute: (comp) => {
405-
return comp.children.mapZoomLevel.getView();
406-
}
407-
},
408-
{
409-
method: {
410-
name: "getMapCenterPosition",
411-
},
412-
execute: (comp) => {
413-
return Promise.resolve({
414-
lng: comp.children.mapCenterLng.getView(),
415-
lat: comp.children.mapCenterLat.getView(),
416-
});
417-
}
418-
},
419-
{
420-
method: {
421-
name: "onClick",
422-
params: [
423-
{
424-
name: "callback",
425-
type: "function",
426-
},
427-
],
428-
},
429-
execute: (comp, params) => {
430-
clickEventCallback = params[0];
431-
document.addEventListener('clickEvent', clickEventCallback);
432-
}
433-
},
434-
])
435-
436281
export const ChartCompWithDefault = withDefault(ChartComp, {
437282
xAxisKey: "date",
438283
series: [

client/packages/lowcoder-comps/src/comps/chartComp/chartPropertyView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,12 @@ export function chartPropertyView(
223223
}
224224
return (
225225
<>
226-
<Section name={trans("chart.mode")}>
226+
{/* <Section name={trans("chart.mode")}>
227227
{children.mode.propertyView({
228228
label: "",
229229
radioButton: true,
230230
})}
231-
</Section>
231+
</Section> */}
232232
{getChatConfigByMode(children.mode.getView())}
233233
</>
234234
);

client/packages/lowcoder-comps/src/comps/eChartsComp/echartsComp.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,7 @@ EChartsTmpComp = withViewFn(EChartsTmpComp, (comp) => {
235235
}
236236
}}
237237
>
238-
{(mode !== 'map' || (mode === 'map' && isMapScriptLoaded)) && (
239-
<ReactECharts
238+
<ReactECharts
240239
ref={(e) => (echartsCompRef.current = e)}
241240
style={{ height: "100%" }}
242241
notMerge
@@ -246,7 +245,6 @@ EChartsTmpComp = withViewFn(EChartsTmpComp, (comp) => {
246245
theme={mode !== 'map' ? themeConfig : undefined}
247246
mode={mode}
248247
/>
249-
)}
250248
</ReactResizeDetector>
251249
);
252250
});

0 commit comments

Comments
 (0)