Skip to content

Commit 622e0b6

Browse files
fix(ui): chart display
1 parent c6102b9 commit 622e0b6

File tree

1 file changed

+27
-15
lines changed

1 file changed

+27
-15
lines changed

datahub-web-react/src/app/analyticsDashboard/components/TimeSeriesChart.tsx

+27-15
Original file line numberDiff line numberDiff line change
@@ -87,21 +87,33 @@ export function computeLines(chartData: TimeSeriesChartType, insertBlankPoints:
8787
const formatAxisDate = (value: number, chartData: TimeSeriesChartType) => {
8888
const date = new Date(value);
8989

90-
// force UTC
91-
const utcDate = new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()));
92-
93-
return chartData.interval === 'MONTH'
94-
? utcDate.toLocaleDateString('en-US', {
95-
month: 'short',
96-
year: 'numeric',
97-
timeZone: 'UTC',
98-
})
99-
: utcDate.toLocaleDateString('en-US', {
100-
year: 'numeric',
101-
month: 'short',
102-
day: 'numeric',
103-
timeZone: 'UTC',
104-
});
90+
switch (chartData.interval) {
91+
case 'MONTH':
92+
return date.toLocaleDateString('en-US', {
93+
month: 'short',
94+
year: 'numeric',
95+
timeZone: 'UTC',
96+
});
97+
case 'WEEK':
98+
return date.toLocaleDateString('en-US', {
99+
month: 'short',
100+
day: 'numeric',
101+
timeZone: 'UTC',
102+
});
103+
case 'DAY':
104+
return date.toLocaleDateString('en-US', {
105+
weekday: 'short',
106+
day: 'numeric',
107+
timeZone: 'UTC',
108+
});
109+
default:
110+
return date.toLocaleDateString('en-US', {
111+
month: 'short',
112+
day: 'numeric',
113+
year: 'numeric',
114+
timeZone: 'UTC',
115+
});
116+
}
105117
};
106118

107119
export const TimeSeriesChart = ({

0 commit comments

Comments
 (0)