Hide xaxis label overlapping - Show current day/month/year below the chart for self better self containing overview

This commit is contained in:
nymkappa
2021-12-13 14:27:05 +09:00
parent aee319ed51
commit cf0af20947
3 changed files with 53 additions and 12 deletions

View File

@@ -25,4 +25,26 @@ export const formatterXAxis = (
case '3y':
return date.toLocaleDateString(locale, { year: 'numeric', month: 'short', day: 'numeric' });
}
};
export const formatterXAxisLabel = (
locale: string,
windowPreference: string,
) => {
const date = new Date();
switch (windowPreference) {
case '2h':
case '24h':
return date.toLocaleDateString(locale, { year: 'numeric', month: 'short', day: 'numeric' });
case '1w':
return date.toLocaleDateString(locale, { year: 'numeric', month: 'long' });
case '1m':
case '3m':
case '6m':
return date.toLocaleDateString(locale, { year: 'numeric' });
case '1y':
case '2y':
case '3y':
return null;
}
};