Merge branch 'dev' into unknown-count

This commit is contained in:
Mike Cao 2021-02-20 02:00:49 -08:00 committed by GitHub
commit 490fc99a8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
41 changed files with 615 additions and 379 deletions

View file

@ -115,6 +115,17 @@ export const refFilter = (data, { domain, domainOnly, raw }) => {
export const browserFilter = data => data.map(({ x, y }) => ({ x: BROWSERS[x] ?? x, y }));
export const eventTypeFilter = (data, types) => {
if (!types || types.length === 0) {
return data;
}
return data.filter(({ x }) => {
const [event] = x.split('\t');
return types.some(type => type === event);
});
};
export const percentFilter = data => {
const total = data.reduce((n, { y }) => n + y, 0);
return data.map(({ x, y, ...props }) => ({ x, y, z: total ? (y / total) * 100 : 0, ...props }));