storj/web/satellite/src/utils/chart.ts
Vitalii Shpital be10ce84f8 web/satellite: implemented charts UI for new project dashboard
Added bandwidth/storage charts (with test data) to new project dashboard.
Added functional buttons to new project dashboard.
Fixed this issue https://github.com/storj/storj/issues/4262.

Change-Id: Ie87370b8f7b6015bc84022a6086ef1db40e16535
2021-12-01 15:55:20 +00:00

28 lines
732 B
TypeScript

// Copyright (C) 2021 Storj Labs, Inc.
// See LICENSE for copying information.
export class ChartUtils {
/**
* Used to display correct number of days on chart's labels.
*
* @returns daysDisplayed - array of days converted to a string by using the current locale
*/
public static daysDisplayedOnChart(start: Date, end: Date): string[] {
const arr = Array<string>();
if (start === end) {
arr.push(`${start.getMonth() + 1}/${start.getDate()}`);
return arr;
}
const dt = start;
while (dt <= end) {
arr.push(`${dt.getMonth() + 1}/${dt.getDate()}`);
dt.setDate(dt.getDate() + 1)
}
return arr;
}
}