mirror of
https://github.com/umami-software/umami.git
synced 2026-02-12 00:27:11 +01:00
fix: calculate country visitors share relative to total
as opposed to relative to the top-10 countries shown in the breakdown
This commit is contained in:
parent
860e6390f1
commit
cd1ee8461a
3 changed files with 78 additions and 18 deletions
|
|
@ -1,7 +1,7 @@
|
|||
export const percentFilter = (data: any[]) => {
|
||||
export const percentFilter = (data: any[], total?: number) => {
|
||||
if (!Array.isArray(data)) return [];
|
||||
const total = data.reduce((n, { y }) => n + y, 0);
|
||||
return data.map(({ x, y, ...props }) => ({ x, y, z: total ? (y / total) * 100 : 0, ...props }));
|
||||
const sum = total ?? data.reduce((n, { y }) => n + y, 0);
|
||||
return data.map(({ x, y, ...props }) => ({ x, y, z: sum ? (y / sum) * 100 : 0, ...props }));
|
||||
};
|
||||
|
||||
export const paramFilter = (data: any[]) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue