Localized country names.

This commit is contained in:
Mike Cao 2020-09-30 16:27:27 -07:00
parent e5cd162b83
commit fd69f0df24
22 changed files with 69 additions and 263 deletions

View file

@ -1,5 +1,5 @@
import firstBy from 'thenby';
import { BROWSERS, ISO_COUNTRIES } from './constants';
import { BROWSERS } from './constants';
import { removeTrailingSlash, removeWWW, getDomainName } from './url';
export const urlFilter = (data, { raw }) => {
@ -125,9 +125,6 @@ export const osFilter = data => data.filter(({ x }) => x);
export const deviceFilter = data => data.filter(({ x }) => x);
export const countryFilter = data =>
data.map(({ x, y }) => ({ x: ISO_COUNTRIES[x] || x, y })).filter(({ x }) => x);
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 }));