Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/pages/OverviewPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export function OverviewPage() {
});
const selectedMetricLabel = dailyUserMetricOptions.find((option) => option.value === selectedMetric)?.label ?? "방문자";
const chartData = toChartData(dailyUserMetricsQuery.data?.dailyMetrics, selectedMetric);
const chartMaxValue = resolveChartMaxValue(chartData);

return (
<div className="page-stack">
Expand Down Expand Up @@ -104,7 +105,7 @@ export function OverviewPage() {
yField="value"
height={320}
shapeField="smooth"
scale={{ y: { domainMin: 0, nice: true } }}
scale={{ y: { domain: [0, chartMaxValue] } }}
axis={{ y: { labelFormatter: (value: string) => `${value}명` } }}
interaction={{ tooltip: { marker: false } }}
style={{ lineWidth: 2 }}
Expand All @@ -122,3 +123,8 @@ function toChartData(metrics: AdminDailyUserMetricRes[] = [], metricKey: DailyUs
value: metric[metricKey]
}));
}

function resolveChartMaxValue(data: { value: number }[]) {
const maxValue = Math.max(0, ...data.map((item) => item.value));
return maxValue > 0 ? maxValue : 1;
}
Loading