@@ -27,6 +27,7 @@ import {
27
27
withViewFn ,
28
28
ThemeContext ,
29
29
chartColorPalette ,
30
+ getPromiseAfterDispatch ,
30
31
} from "lowcoder-sdk" ;
31
32
import { getEchartsLocale , trans } from "i18n/comps" ;
32
33
import { ItemColorComp } from "comps/chartComp/chartConfigs/lineChartConfig" ;
@@ -57,6 +58,7 @@ ChartTmpComp = withViewFn(ChartTmpComp, (comp) => {
57
58
const mapZoomlevel = comp . children . mapZoomLevel . getView ( ) ;
58
59
const onUIEvent = comp . children . onUIEvent . getView ( ) ;
59
60
const onMapEvent = comp . children . onMapEvent . getView ( ) ;
61
+ const onEvent = comp . children . onEvent . getView ( ) ;
60
62
61
63
const echartsCompRef = useRef < ReactECharts | null > ( ) ;
62
64
const [ chartSize , setChartSize ] = useState < ChartSize > ( ) ;
@@ -75,6 +77,15 @@ ChartTmpComp = withViewFn(ChartTmpComp, (comp) => {
75
77
log . error ( 'theme chart error: ' , error ) ;
76
78
}
77
79
80
+ const triggerClickEvent = async ( dispatch : any , action : CompAction < JSONValue > ) => {
81
+ await getPromiseAfterDispatch (
82
+ dispatch ,
83
+ action ,
84
+ { autoHandleAfterReduce : true }
85
+ ) ;
86
+ onEvent ( 'click' ) ;
87
+ }
88
+
78
89
useEffect ( ( ) => {
79
90
// click events for JSON/Map mode
80
91
if ( mode === 'ui' ) return ;
@@ -91,6 +102,10 @@ ChartTmpComp = withViewFn(ChartTmpComp, (comp) => {
91
102
data : param . data ,
92
103
}
93
104
} ) ) ;
105
+ triggerClickEvent (
106
+ comp . dispatch ,
107
+ changeChildAction ( "lastInteractionData" , param . data , false )
108
+ ) ;
94
109
} ) ;
95
110
return ( ) => {
96
111
echartsCompInstance ?. off ( "click" ) ;
@@ -111,21 +126,27 @@ ChartTmpComp = withViewFn(ChartTmpComp, (comp) => {
111
126
const option : any = echartsCompInstance ?. getOption ( ) ;
112
127
//log.log("chart select change", param);
113
128
// trigger click event listener
129
+
114
130
document . dispatchEvent ( new CustomEvent ( "clickEvent" , {
115
131
bubbles : true ,
116
132
detail : {
117
133
action : param . fromAction ,
118
134
data : getSelectedPoints ( param , option )
119
135
}
120
136
} ) ) ;
121
-
137
+
122
138
if ( param . fromAction === "select" ) {
123
- comp . dispatch ( changeChildAction ( "selectedPoints" , getSelectedPoints ( param , option ) ) ) ;
139
+ comp . dispatch ( changeChildAction ( "selectedPoints" , getSelectedPoints ( param , option ) , false ) ) ;
124
140
onUIEvent ( "select" ) ;
125
141
} else if ( param . fromAction === "unselect" ) {
126
- comp . dispatch ( changeChildAction ( "selectedPoints" , getSelectedPoints ( param , option ) ) ) ;
142
+ comp . dispatch ( changeChildAction ( "selectedPoints" , getSelectedPoints ( param , option ) , false ) ) ;
127
143
onUIEvent ( "unselect" ) ;
128
144
}
145
+
146
+ triggerClickEvent (
147
+ comp . dispatch ,
148
+ changeChildAction ( "lastInteractionData" , getSelectedPoints ( param , option ) , false )
149
+ ) ;
129
150
} ) ;
130
151
// unbind
131
152
return ( ) => {
@@ -165,10 +186,12 @@ ChartTmpComp = withViewFn(ChartTmpComp, (comp) => {
165
186
166
187
useEffect ( ( ) => {
167
188
if ( mode !== 'map' ) {
168
- comp . children . mapInstance . dispatch ( changeValueAction ( undefined ) )
189
+ comp . children . mapInstance . dispatch ( changeValueAction ( null , false ) )
169
190
return ;
170
191
}
171
192
193
+ if ( comp . children . mapInstance . value ) return ;
194
+
172
195
const gMapScript = loadGoogleMapsScript ( apiKey ) ;
173
196
if ( isMapScriptLoaded ) {
174
197
handleOnMapScriptLoad ( ) ;
@@ -322,6 +345,14 @@ let ChartComp = withExposingConfigs(ChartTmpComp, [
322
345
return input . selectedPoints ;
323
346
} ,
324
347
} ) ,
348
+ depsConfig ( {
349
+ name : "lastInteractionData" ,
350
+ desc : trans ( "chart.lastInteractionDataDesc" ) ,
351
+ depKeys : [ "lastInteractionData" ] ,
352
+ func : ( input ) => {
353
+ return input . lastInteractionData ;
354
+ } ,
355
+ } ) ,
325
356
depsConfig ( {
326
357
name : "data" ,
327
358
desc : trans ( "chart.dataDesc" ) ,
0 commit comments