Skip to content

Click events for echarts json/map view #809

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
Apr 15, 2024
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
Next Next commit
added click events for echarts json/map mode
  • Loading branch information
raheeliftikhar5 committed Apr 15, 2024
commit e6e6b3a98551c5ebf842d78e7ada35ae5bac8cda
2 changes: 1 addition & 1 deletion client/packages/lowcoder-comps/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lowcoder-comps",
"version": "0.0.29",
"version": "0.0.30",
"type": "module",
"license": "MIT",
"dependencies": {
Expand Down
24 changes: 24 additions & 0 deletions client/packages/lowcoder-comps/src/comps/chartComp/chartComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,30 @@ ChartTmpComp = withViewFn(ChartTmpComp, (comp) => {
}

useEffect(() => {
// click events for JSON/Map mode
if (mode === 'ui') return;

const echartsCompInstance = echartsCompRef?.current?.getEchartsInstance();
if (!echartsCompInstance) {
return _.noop;
}
echartsCompInstance?.on("click", (param: any) => {
document.dispatchEvent(new CustomEvent("clickEvent", {
bubbles: true,
detail: {
action: 'click',
data: param.data,
}
}));
});
return () => {
echartsCompInstance?.off("click");
document.removeEventListener('clickEvent', clickEventCallback)
};
}, [mode, mapScriptLoaded]);

useEffect(() => {
// click events for UI mode
if(mode !== 'ui') return;

// bind events
Expand Down