Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit362249b

Browse files
updated logic to count user by region
1 parent6a67c4e commit362249b

File tree

1 file changed

+34
-22
lines changed

1 file changed

+34
-22
lines changed

‎client/packages/lowcoder/src/pages/setting/appUsage/charts/userEngagementByRegion.tsx‎

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,42 +63,52 @@ const UserEngagementByRegionChart = ({ data }: Props) => {
6363
}
6464
},[])
6565

66+
constgeoPoints=useMemo(()=>{
67+
returndata.reduce((acc,log)=>{
68+
constregion=log?.geolocationDataJsonb?.city?.names?.en||'Unknown';// assuming `region` is added to each event
69+
letregionData={
70+
latitude:log?.geolocationDataJsonb?.location?.latitude??55,
71+
longitude:log?.geolocationDataJsonb?.location?.longitude??15,
72+
count:0,
73+
};
74+
if(acc[region]){
75+
acc[region]={
76+
...acc[region],
77+
count:acc[region].count+1,
78+
}
79+
}else{
80+
acc[region]=regionData;
81+
}
82+
returnacc;
83+
},{}asRecord<string,number>);
84+
},[data]);
85+
6686
constseries=useMemo(()=>{
6787
return[
6888
{
69-
"name":"Company Size",
89+
"name":"Users/Region",
7090
"type":"scatter",
7191
"coordinateSystem":"gmap",
7292
"itemStyle":{
7393
"color":"#ff00ff"
7494
},
75-
"data":data
76-
// .filter(item => {
77-
// if (!item.geolocationDataJsonb) return false;
78-
// return item.geolocationDataJsonb.longitude !== null &&
79-
// item.geolocationDataJsonb.latitude !== null
80-
// })
81-
.map(item=>({
82-
name:item.details?.applicationName,
83-
value:[
84-
...getRandomLatLng(35,72,25,65),
85-
1,
86-
]
87-
// value: [
88-
// geoLocation.location.longitude, // item.longitude,
89-
// geoLocation.location.latitude, // item.latitude,
90-
// 1
91-
// ]
92-
}))
93-
,
95+
"data":Object.keys(geoPoints).map(key=>({
96+
name:key,
97+
value:[
98+
geoPoints[key].longitude,
99+
geoPoints[key].latitude,
100+
geoPoints[key].count,
101+
]
102+
})),
103+
"symbolSize":(val:number[])=>{return8+((Math.log(val[2])-Math.log(2))/(Math.log(40)-Math.log(2)))*(40-8)},
94104
"encode":{
95105
"value":2,
96106
"lng":0,
97107
"lat":1
98108
}
99109
}
100110
]
101-
},[data]);
111+
},[geoPoints]);
102112

103113
return(
104114
<>
@@ -115,7 +125,9 @@ const UserEngagementByRegionChart = ({ data }: Props) => {
115125
},
116126
tooltip:{
117127
trigger:"item",
118-
formatter:"{b}"
128+
formatter:(params:{data:{name:string;value:any[];};})=>{
129+
return`${params.data.name}:${params.data.value[2]}`;
130+
}
119131
},
120132
animation:true,
121133
series:series,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp