Save fee rates legend preference - Fix xaxis label

This commit is contained in:
nymkappa
2022-04-15 19:39:27 +09:00
parent b9298233bf
commit ee3b287f65
5 changed files with 61 additions and 15 deletions

View File

@@ -3,7 +3,7 @@ export const formatterXAxis = (
windowPreference: string,
value: string | number
) => {
if (typeof value === 'string' && value.length === 0){
if (typeof value === 'string' && value.length === 0) {
return null;
}
@@ -22,8 +22,9 @@ export const formatterXAxis = (
return date.toLocaleTimeString(locale, { month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric' });
case '2y':
case '3y':
case 'all':
return date.toLocaleDateString(locale, { year: 'numeric', month: 'short', day: 'numeric' });
case 'all':
return date.toLocaleDateString(locale, { year: 'numeric', month: 'short' });
}
};
@@ -36,6 +37,7 @@ export const formatterXAxisLabel = (
case '2h':
case '24h':
return date.toLocaleDateString(locale, { year: 'numeric', month: 'short', day: 'numeric' });
case '3d':
case '1w':
return date.toLocaleDateString(locale, { year: 'numeric', month: 'long' });
case '1m':
@@ -48,3 +50,30 @@ export const formatterXAxisLabel = (
return null;
}
};
export const formatterXAxisTimeCategory = (
locale: string,
windowPreference: string,
value: number
) => {
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' });
case '3d':
case '1w':
return date.toLocaleTimeString(locale, { month: 'short', day: 'numeric', hour: 'numeric' });
case '1m':
case '3m':
return date.toLocaleDateString(locale, { month: 'long', day: 'numeric' });
case '6m':
case '1y':
return date.toLocaleDateString(locale, { year: 'numeric', month: 'short', day: 'numeric' });
case '2y':
case '3y':
case 'all':
return date.toLocaleDateString(locale, { year: 'numeric', month: 'long' });
}
};