chore: commit chybějících souborů
This commit is contained in:
1 parent
f1ce3ff297
commit
9e72f431a1
7 files changed
+890
No files matched your search
@@ -0,0 +1,32 @@
|
||||
import { StatsRange } from "../enums";
|
||||
import { formatDateString, getHumanMonth } from "../Utils";
|
||||
|
||||
/** Vzhled bubliny s hodnotou — recharts ji kreslí inline stylem, ne přes CSS třídu. */
|
||||
export const TOOLTIP_STYLE = {
|
||||
background: 'var(--ft-bg-card)',
|
||||
border: '1px solid var(--ft-border)',
|
||||
borderRadius: 'var(--ft-radius-sm)',
|
||||
color: 'var(--ft-text)',
|
||||
};
|
||||
|
||||
/** Hranice zvoleného období statistik, YYYY-MM-DD včetně. */
|
||||
export type StatsBounds = { from: string, to: string };
|
||||
|
||||
/**
|
||||
* Popisek období na ose grafu — den u měsíce, měsíc u roku, rok u celého přehledu.
|
||||
*
|
||||
* @param period označení období ze serveru (YYYY-MM-DD, YYYY-MM nebo YYYY)
|
||||
* @param mode zvolený rozsah statistik
|
||||
*/
|
||||
export function formatPeriodLabel(period: string, mode: StatsRange): string {
|
||||
if (mode === StatsRange.MESIC) return formatDateString(period).slice(0, 5);
|
||||
if (mode === StatsRange.ROK) return getHumanMonth(period).split(' ')[0];
|
||||
return period;
|
||||
}
|
||||
|
||||
/** Vybere řadu součtů podle rozsahu — dny u měsíce, měsíce u roku, roky u celého přehledu. */
|
||||
export function pickPeriods<T>(stats: { byDay: T[], byMonth: T[], byYear: T[] }, mode: StatsRange): T[] {
|
||||
if (mode === StatsRange.MESIC) return stats.byDay;
|
||||
if (mode === StatsRange.ROK) return stats.byMonth;
|
||||
return stats.byYear;
|
||||
}
|
||||
Reference in new issue
Block a user