Skip to content

Commit 5524709

Browse files
feat: added switch to hide/show data on map chart
1 parent 079d070 commit 5524709

File tree

4 files changed

+39
-20
lines changed

4 files changed

+39
-20
lines changed

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,13 @@ ChartTmpComp = withViewFn(ChartTmpComp, (comp) => {
141141
}, [mode, apiKey, option])
142142

143143
useEffect(() => {
144-
if(mode === 'map') {
145-
onMapEvent('centerPositionChange')
146-
}
144+
if(mode !== 'map') return;
145+
onMapEvent('centerPositionChange');
147146
}, [mode, mapCenterPosition.lat, mapCenterPosition.lng])
148147

149148
useEffect(() => {
150-
if(mode === 'map') {
151-
onMapEvent('zoomLevelChange')
152-
}
149+
if(mode !== 'map') return;
150+
onMapEvent('zoomLevelChange');
153151
}, [mode, mapZoomlevel])
154152

155153
return (
@@ -333,10 +331,10 @@ ChartComp = withMethodExposing(ChartComp, [
333331
name: "getMapCenterPosition",
334332
},
335333
execute: (comp) => {
336-
return {
334+
return Promise.resolve({
337335
lng: comp.children.mapCenterLng.getView(),
338336
lat: comp.children.mapCenterLat.getView(),
339-
};
337+
});
340338
}
341339
},
342340
])

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

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
1-
import { jsonControl, JSONObject, stateComp, toJSONObjectArray, toObject } from "lowcoder-sdk";
2-
import { withDefault, BooleanControl, StringControl, NumberControl, JSONObjectControl, FunctionControl } from "lowcoder-sdk";
3-
import { dropdownControl } from "lowcoder-sdk";
4-
import { eventHandlerControl } from "lowcoder-sdk";
5-
import { valueComp, withType } from "lowcoder-sdk";
6-
import { ValueFromOption } from "lowcoder-sdk";
7-
import { uiChildren } from "lowcoder-sdk";
1+
import {
2+
jsonControl,
3+
JSONObject,
4+
stateComp,
5+
toJSONObjectArray,
6+
toObject,
7+
BoolControl,
8+
withDefault,
9+
StringControl,
10+
NumberControl,
11+
FunctionControl,
12+
dropdownControl,
13+
eventHandlerControl,
14+
valueComp,
15+
withType,
16+
ValueFromOption,
17+
uiChildren,
18+
} from "lowcoder-sdk";
819
import { RecordConstructorToComp, RecordConstructorToView } from "lowcoder-core";
920
import { BarChartConfig } from "./chartConfigs/barChartConfig";
1021
import { XAxisConfig, YAxisConfig } from "./chartConfigs/cartesianAxisConfig";
@@ -251,6 +262,7 @@ const chartMapModeChildren = {
251262
mapCenterLat: withDefault(NumberControl, 50.942063),
252263
mapOptions: jsonControl(toObject, i18nObjs.defaultMapJsonOption),
253264
onMapEvent: eventHandlerControl(MapEventOptions),
265+
showCharts: withDefault(BoolControl, true),
254266
}
255267

256268
export const chartChildrenMap = {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ export function chartPropertyView(
168168
{children.mapCenterLat.propertyView({
169169
label: "Latitude"
170170
})}
171+
{children.showCharts.propertyView({
172+
label: "Show Charts"
173+
})}
171174
</Section>
172175
<Section name={'Map Data'}>
173176
{children.mapOptions.propertyView({

client/packages/lowcoder-comps/src/comps/chartComp/chartUtils.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ export function transformData(
5252
}
5353

5454
const notAxisChartSet: Set<CharOptionCompType> = new Set(["pie"] as const);
55-
export const echartsConfigOmitChildren = ["hidden", "selectedPoints", "onEvent", "mapInstance"] as const;
55+
export const echartsConfigOmitChildren = [
56+
"hidden",
57+
"selectedPoints",
58+
"onUIEvent",
59+
"mapInstance"
60+
] as const;
5661
type EchartsConfigProps = Omit<ChartCompPropsType, typeof echartsConfigOmitChildren[number]>;
5762

5863
export function isAxisChart(type: CharOptionCompType) {
@@ -132,16 +137,17 @@ export function getEchartsConfig(props: EchartsConfigProps, chartSize?: ChartSiz
132137
mapZoomLevel,
133138
mapCenterLat,
134139
mapCenterLng,
135-
mapOptions,
140+
mapOptions,
141+
showCharts,
136142
} = props;
137-
138-
const echartsOption = mapOptions ? mapOptions : {};
143+
144+
const echartsOption = mapOptions && showCharts ? mapOptions : {};
139145
return {
140146
gmap: {
141147
center: [mapCenterLng, mapCenterLat],
142148
zoom: mapZoomLevel,
143149
renderOnMoving: true,
144-
echartsLayerZIndex: 2019,
150+
echartsLayerZIndex: showCharts ? 2019 : 0,
145151
roam: true
146152
},
147153
...echartsOption,

0 commit comments

Comments
 (0)