mirror of
https://github.com/umami-software/umami.git
synced 2026-02-14 17:45:38 +01:00
Updated components build.
This commit is contained in:
parent
5f27ba149b
commit
56af91950a
53 changed files with 942 additions and 333 deletions
|
|
@ -1,51 +1,3 @@
|
|||
export const urlFilter = (data: any[]) => {
|
||||
const map = data.reduce((obj, { x, y }) => {
|
||||
if (x) {
|
||||
if (!obj[x]) {
|
||||
obj[x] = y;
|
||||
} else {
|
||||
obj[x] += y;
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}, {});
|
||||
|
||||
return Object.keys(map).map(key => ({ x: key, y: map[key] }));
|
||||
};
|
||||
|
||||
export const refFilter = (data: any[]) => {
|
||||
const links = {};
|
||||
|
||||
const map = data.reduce((obj, { x, y }) => {
|
||||
let id;
|
||||
|
||||
try {
|
||||
const url = new URL(x);
|
||||
|
||||
id = url.hostname.replace(/www\./, '') || url.href;
|
||||
} catch {
|
||||
id = '';
|
||||
}
|
||||
|
||||
links[id] = x;
|
||||
|
||||
if (!obj[id]) {
|
||||
obj[id] = y;
|
||||
} else {
|
||||
obj[id] += y;
|
||||
}
|
||||
|
||||
return obj;
|
||||
}, {});
|
||||
|
||||
return Object.keys(map).map(key => ({ x: key, y: map[key], w: links[key] }));
|
||||
};
|
||||
|
||||
export const emptyFilter = (data: any[]) => {
|
||||
return data.map(item => (item.x ? item : null)).filter(n => n);
|
||||
};
|
||||
|
||||
export const percentFilter = (data: any[]) => {
|
||||
if (!data) return [];
|
||||
const total = data.reduce((n, { y }) => n + y, 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue