mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 01:35:17 +01:00
21 lines
770 B
JavaScript
21 lines
770 B
JavaScript
import { BROWSERS, ISO_COUNTRIES, DEVICES } from './constants';
|
|
|
|
export const browserFilter = data =>
|
|
data.map(({ x, ...props }) => ({ x: BROWSERS[x] || x, ...props }));
|
|
|
|
export const urlFilter = data => data.filter(({ x }) => x !== '' && !x.startsWith('#'));
|
|
|
|
export const refFilter = data =>
|
|
data.filter(({ x }) => x !== '' && !x.startsWith('/') && !x.startsWith('#'));
|
|
|
|
export const deviceFilter = data =>
|
|
data.map(({ x, ...props }) => ({ x: DEVICES[x] || x, ...props }));
|
|
|
|
export const countryFilter = data =>
|
|
data.map(({ x, ...props }) => ({ x: ISO_COUNTRIES[x] || x, ...props }));
|
|
|
|
export const percentFilter = data => {
|
|
const total = data.reduce((n, { y }) => n + y, 0);
|
|
return data.map(({ x, y }) => ({ x, y, z: total ? (y / total) * 100 : 0 }));
|
|
};
|