Shaheer Kochai 8d6731c7ba
feat: Centralize and Standardize Date/Time Format Handling (#6925)
* feat: change the format of uplot x axis to 24 hours

* feat: centralize date/time formats

* refactor: use the centralized 24 hour date/time formatting across components

* refactor: centralize uPlot x-axis values formatting

* feat: make the x axis of alert history in 24 hour format
2025-01-27 11:58:54 +00:00

46 lines
978 B
TypeScript

// Define type annotations for style and interp
export const drawStyles = {
line: 'line',
bars: 'bars',
barsLeft: 'barsLeft',
barsRight: 'barsRight',
points: 'points',
};
export const lineInterpolations = {
linear: 'linear',
stepAfter: 'stepAfter',
stepBefore: 'stepBefore',
spline: 'spline',
};
export const uPlotXAxisValuesFormat = [
[3600 * 24 * 365, '{YYYY}', null, null, null, null, null, null, 1],
[3600 * 24 * 28, '{MMM}', '\n{YYYY}', null, null, null, null, null, 1],
[3600 * 24, '{M}/{D}', '\n{YYYY}', null, null, null, null, null, 1],
[3600, '{HH}:{mm}', '\n{M}/{D}/{YY}', null, '\n{M}/{D}', null, null, null, 1],
[60, '{HH}:{mm}', '\n{M}/{D}/{YY}', null, '\n{M}/{D}', null, null, null, 1],
[
1,
':{ss}',
'\n{M}/{D}/{YY} {HH}:{mm}',
null,
'\n{M}/{D} {HH}:{mm}',
null,
'\n{HH}:{mm}',
null,
1,
],
[
0.001,
':{ss}.{fff}',
'\n{M}/{D}/{YY} {HH}:{mm}',
null,
'\n{M}/{D} {HH}:{mm}',
null,
'\n{HH}:{mm}',
null,
1,
],
];