Skip to content

Commit

Permalink
fix: date display on analytics chart
Browse files Browse the repository at this point in the history
Signed-off-by: David Dal Busco <[email protected]>
  • Loading branch information
peterpeterparker committed Nov 11, 2023
1 parent b41713c commit 140ce03
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
let ticks: string[];
$: ticks = Object.values(chartsData).map(({ [xKey]: a }) => a);
const formatTick = (d: string): string => {
const date = new Date(parseInt(d));
const time = date.getDate();
return time % 2 != 0 ? formatToDay(date) : '';
};
</script>

<div class="chart-container">
Expand All @@ -53,7 +59,7 @@
data={chartsData}
>
<Svg>
<AxisX formatTick={(d) => formatToDay(new Date(parseInt(d)))} {ticks} />
<AxisX {formatTick} {ticks} />
<AxisY ticks={4} />
<Line />
<Area />
Expand Down
3 changes: 1 addition & 2 deletions src/frontend/src/lib/utils/date.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ export const formatToDateNumeric = (nanoseconds: bigint): string => {
export const formatToDay = (date: Date): string => {
const options: Intl.DateTimeFormatOptions = {
month: 'short',
day: 'numeric',
year: 'numeric'
day: 'numeric'
};

return date.toLocaleDateString('en', options);
Expand Down

0 comments on commit 140ce03

Please sign in to comment.