Refactor tooltip formatting into common file and switch to native js localization
This commit is contained in:
1 parent
b924725ea2
commit
be4c80b489
4 files changed
+34
-58
No files matched your search
@@ -0,0 +1,28 @@
|
||||
export const formatterXAxis = (
|
||||
locale: string,
|
||||
windowPreference: string,
|
||||
value: string
|
||||
) => {
|
||||
|
||||
if(value.length === 0){
|
||||
return null;
|
||||
}
|
||||
|
||||
const date = new Date(value);
|
||||
switch (windowPreference) {
|
||||
case '2h':
|
||||
return date.toLocaleTimeString(locale, { hour: 'numeric', minute: 'numeric' });
|
||||
case '24h':
|
||||
return date.toLocaleTimeString(locale, { weekday: 'short', hour: 'numeric', minute: 'numeric' });
|
||||
case '1w':
|
||||
return date.toLocaleTimeString(locale, { month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric' });
|
||||
case '1m':
|
||||
case '3m':
|
||||
case '6m':
|
||||
return date.toLocaleTimeString(locale, { month: 'short', day: 'numeric', hour: 'numeric' });
|
||||
case '1y':
|
||||
case '2y':
|
||||
case '3y':
|
||||
return date.toLocaleDateString(locale, { year: 'numeric', month: 'short', day: 'numeric' });
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user