Upgrade charts to ChartJS 3 and improve UI for them

This commit is contained in:
DaneEveritt 2022-06-25 20:49:25 -04:00
parent 980f828edd
commit 182507ff0e
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
8 changed files with 269 additions and 179 deletions

View file

@ -1,8 +1,8 @@
export const megabytesToBytes = (mb: number) => Math.floor(mb * 1024 * 1024);
export function bytesToHuman (bytes: number): string {
if (bytes === 0) {
return '0 kB';
if (bytes < 1) {
return '0 Bytes';
}
const i = Math.floor(Math.log(bytes) / Math.log(1024));
@ -75,3 +75,9 @@ export const isEmptyObject = (o: {}): boolean =>
// eslint-disable-next-line @typescript-eslint/ban-types
export const getObjectKeys = <T extends {}> (o: T): (keyof T)[] => Object.keys(o) as (keyof typeof o)[];
export const toRGBA = (hex: string, alpha = 1): string => {
const [ r, g, b ] = hex.match(/\w\w/g)!.map(v => parseInt(v, 16));
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
};