Skip to content

Commit e6e6b3a

Browse files
added click events for echarts json/map mode
1 parent f33b807 commit e6e6b3a

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

client/packages/lowcoder-comps/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lowcoder-comps",
3-
"version": "0.0.29",
3+
"version": "0.0.30",
44
"type": "module",
55
"license": "MIT",
66
"dependencies": {

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,30 @@ ChartTmpComp = withViewFn(ChartTmpComp, (comp) => {
7676
}
7777

7878
useEffect(() => {
79+
// click events for JSON/Map mode
80+
if (mode === 'ui') return;
81+
82+
const echartsCompInstance = echartsCompRef?.current?.getEchartsInstance();
83+
if (!echartsCompInstance) {
84+
return _.noop;
85+
}
86+
echartsCompInstance?.on("click", (param: any) => {
87+
document.dispatchEvent(new CustomEvent("clickEvent", {
88+
bubbles: true,
89+
detail: {
90+
action: 'click',
91+
data: param.data,
92+
}
93+
}));
94+
});
95+
return () => {
96+
echartsCompInstance?.off("click");
97+
document.removeEventListener('clickEvent', clickEventCallback)
98+
};
99+
}, [mode, mapScriptLoaded]);
100+
101+
useEffect(() => {
102+
// click events for UI mode
79103
if(mode !== 'ui') return;
80104

81105
// bind events

0 commit comments

Comments
 (0)