fix: 小时维度图Y轴改用预计算固定最大值,正确显示24万+账单峰值
This commit is contained in:
@@ -69,6 +69,11 @@ export function TimePage() {
|
||||
? hourlyRows.reduce((best: any, r: any) => Number(r.bill_count || 0) > Number(best?.bill_count || 0) ? r : best, null)
|
||||
: null
|
||||
|
||||
const maxBillCount = hourlyRows.length > 0 ? Math.max(...hourlyRows.map((r: any) => Number(r.bill_count || 0))) : 0
|
||||
const maxReceived = hourlyRows.length > 0 ? Math.max(...hourlyRows.map((r: any) => Number(r.received || 0))) : 0
|
||||
const yLeftMax = Math.ceil(maxReceived * 1.15 / 10000) * 10000
|
||||
const yRightMax = Math.ceil(maxBillCount * 1.15 / 10000) * 10000
|
||||
|
||||
const channelTotals = channelRows.length > 0
|
||||
? Object.keys(channelRows[0]).filter(k => k !== 'business_date' && k !== 'meituan_commission' && k !== 'taobao_commission' && k !== 'jd_commission')
|
||||
.map(k => ({
|
||||
@@ -123,8 +128,8 @@ export function TimePage() {
|
||||
<AreaChart data={hourlyRows} margin={{ top: 20, right: 20, bottom: 20, left: 20 }}>
|
||||
<CartesianGrid strokeDasharray="3 3" />
|
||||
<XAxis dataKey="closing_hour" tickFormatter={(v) => `${v}:00`} tick={{ fontSize: 10 }} />
|
||||
<YAxis yAxisId="left" tickFormatter={(v) => v >= 10000 ? `${(v / 10000).toFixed(0)}万` : v} tick={{ fontSize: 10 }} domain={[0, (max: number) => Math.ceil(max * 1.15 / 10000) * 10000]} />
|
||||
<YAxis yAxisId="right" orientation="right" tickFormatter={(v) => v >= 10000 ? `${(v / 10000).toFixed(0)}万` : v} tick={{ fontSize: 10 }} domain={[0, (max: number) => Math.ceil(max * 1.15 / 10000) * 10000]} />
|
||||
<YAxis yAxisId="left" tickFormatter={(v) => v >= 10000 ? `${(v / 10000).toFixed(0)}万` : v} tick={{ fontSize: 10 }} domain={[0, yLeftMax]} />
|
||||
<YAxis yAxisId="right" orientation="right" tickFormatter={(v) => v >= 10000 ? `${(v / 10000).toFixed(0)}万` : v} tick={{ fontSize: 10 }} domain={[0, yRightMax]} />
|
||||
<Tooltip labelFormatter={(v) => `${v}:00`} formatter={(v: any, name: any) => name === '实收' ? formatCurrency(v) : formatNumber(v)} />
|
||||
<Legend />
|
||||
<Area yAxisId="left" type="monotone" dataKey="received" stroke="#3b82f6" fill="#3b82f680" name="实收" />
|
||||
|
||||
Reference in New Issue
Block a user