Fix monthly trend chart — rolling 12-month average with LY comparison
Replace raw monthly totals with a proper rolling 12-month average trend. Fetches 36 months of data; the 12 display points each show the average of the 12 months ending on that point (TY) and the same window shifted back a year (LY), producing a smooth upward trend vs last year. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
b97358e9fb
commit
8da7e46d72
3 changed files with 33 additions and 22 deletions
|
|
@ -349,7 +349,7 @@ function MonthProgressSection({
|
|||
</div>
|
||||
|
||||
<div className="wa-chart-card">
|
||||
<h4>Monthly Average Turnover — Last 12 Months</h4>
|
||||
<h4>Rolling 12-Month Avg Turnover — Trend</h4>
|
||||
<ResponsiveContainer width="100%" height={220}>
|
||||
<LineChart data={trend} margin={{ top: 8, right: 8, left: 8, bottom: 0 }}>
|
||||
<CartesianGrid strokeDasharray="3 3" stroke="#e5e7eb" />
|
||||
|
|
@ -357,9 +357,8 @@ function MonthProgressSection({
|
|||
<YAxis tickFormatter={v => `£${(v/1000).toFixed(0)}k`} tick={{ fontSize: 10 }} width={52} />
|
||||
<Tooltip formatter={fmtChartCcy} />
|
||||
<Legend iconSize={10} wrapperStyle={{ fontSize: 11 }} />
|
||||
<Line type="monotone" dataKey="rooms" stroke={CHART_COLORS.rooms} strokeWidth={2} dot={false} name="Rooms" />
|
||||
<Line type="monotone" dataKey="dry" stroke={CHART_COLORS.dry} strokeWidth={2} dot={false} name="Dry" />
|
||||
<Line type="monotone" dataKey="wet" stroke={CHART_COLORS.wet} strokeWidth={2} dot={false} name="Wet" />
|
||||
<Line type="monotone" dataKey="this_year_avg" stroke={CHART_COLORS.thisWeek} strokeWidth={2.5} dot={false} name="This Year" />
|
||||
<Line type="monotone" dataKey="last_year_avg" stroke={CHART_COLORS.budget} strokeWidth={2} dot={false} name="Last Year" strokeDasharray="5 3" />
|
||||
</LineChart>
|
||||
</ResponsiveContainer>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -101,11 +101,9 @@ export interface MonthProgress {
|
|||
}
|
||||
|
||||
export interface MonthTrend {
|
||||
label: string
|
||||
rooms: number
|
||||
dry: number
|
||||
wet: number
|
||||
total: number
|
||||
label: string
|
||||
this_year_avg: number
|
||||
last_year_avg: number
|
||||
}
|
||||
|
||||
export interface WeeklyActualData {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue