Skip to content

Echarts map events #495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: added switch to hide/show data on map chart
  • Loading branch information
raheeliftikhar5 committed Nov 13, 2023
commit 55247097e3d04b22200a1e47781ab6943e2d57b5
14 changes: 6 additions & 8 deletions client/packages/lowcoder-comps/src/comps/chartComp/chartComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,13 @@ ChartTmpComp = withViewFn(ChartTmpComp, (comp) => {
}, [mode, apiKey, option])

useEffect(() => {
if(mode === 'map') {
onMapEvent('centerPositionChange')
}
if(mode !== 'map') return;
onMapEvent('centerPositionChange');
}, [mode, mapCenterPosition.lat, mapCenterPosition.lng])

useEffect(() => {
if(mode === 'map') {
onMapEvent('zoomLevelChange')
}
if(mode !== 'map') return;
onMapEvent('zoomLevelChange');
}, [mode, mapZoomlevel])

return (
Expand Down Expand Up @@ -333,10 +331,10 @@ ChartComp = withMethodExposing(ChartComp, [
name: "getMapCenterPosition",
},
execute: (comp) => {
return {
return Promise.resolve({
lng: comp.children.mapCenterLng.getView(),
lat: comp.children.mapCenterLat.getView(),
};
});
}
},
])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
import { jsonControl, JSONObject, stateComp, toJSONObjectArray, toObject } from "lowcoder-sdk";
import { withDefault, BooleanControl, StringControl, NumberControl, JSONObjectControl, FunctionControl } from "lowcoder-sdk";
import { dropdownControl } from "lowcoder-sdk";
import { eventHandlerControl } from "lowcoder-sdk";
import { valueComp, withType } from "lowcoder-sdk";
import { ValueFromOption } from "lowcoder-sdk";
import { uiChildren } from "lowcoder-sdk";
import {
jsonControl,
JSONObject,
stateComp,
toJSONObjectArray,
toObject,
BoolControl,
withDefault,
StringControl,
NumberControl,
FunctionControl,
dropdownControl,
eventHandlerControl,
valueComp,
withType,
ValueFromOption,
uiChildren,
} from "lowcoder-sdk";
import { RecordConstructorToComp, RecordConstructorToView } from "lowcoder-core";
import { BarChartConfig } from "./chartConfigs/barChartConfig";
import { XAxisConfig, YAxisConfig } from "./chartConfigs/cartesianAxisConfig";
Expand Down Expand Up @@ -251,6 +262,7 @@ const chartMapModeChildren = {
mapCenterLat: withDefault(NumberControl, 50.942063),
mapOptions: jsonControl(toObject, i18nObjs.defaultMapJsonOption),
onMapEvent: eventHandlerControl(MapEventOptions),
showCharts: withDefault(BoolControl, true),
}

export const chartChildrenMap = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ export function chartPropertyView(
{children.mapCenterLat.propertyView({
label: "Latitude"
})}
{children.showCharts.propertyView({
label: "Show Charts"
})}
</Section>
<Section name={'Map Data'}>
{children.mapOptions.propertyView({
Expand Down
16 changes: 11 additions & 5 deletions client/packages/lowcoder-comps/src/comps/chartComp/chartUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ export function transformData(
}

const notAxisChartSet: Set<CharOptionCompType> = new Set(["pie"] as const);
export const echartsConfigOmitChildren = ["hidden", "selectedPoints", "onEvent", "mapInstance"] as const;
export const echartsConfigOmitChildren = [
"hidden",
"selectedPoints",
"onUIEvent",
"mapInstance"
] as const;
type EchartsConfigProps = Omit<ChartCompPropsType, typeof echartsConfigOmitChildren[number]>;

export function isAxisChart(type: CharOptionCompType) {
Expand Down Expand Up @@ -132,16 +137,17 @@ export function getEchartsConfig(props: EchartsConfigProps, chartSize?: ChartSiz
mapZoomLevel,
mapCenterLat,
mapCenterLng,
mapOptions,
mapOptions,
showCharts,
} = props;
const echartsOption = mapOptions ? mapOptions : {};

const echartsOption = mapOptions && showCharts ? mapOptions : {};
return {
gmap: {
center: [mapCenterLng, mapCenterLat],
zoom: mapZoomLevel,
renderOnMoving: true,
echartsLayerZIndex: 2019,
echartsLayerZIndex: showCharts ? 2019 : 0,
roam: true
},
...echartsOption,
Expand Down