diff --git a/frontend/src/pages/Bookability.tsx b/frontend/src/pages/Bookability.tsx index 5366474..17efe3f 100644 --- a/frontend/src/pages/Bookability.tsx +++ b/frontend/src/pages/Bookability.tsx @@ -1207,6 +1207,16 @@ function OccHistoryModal({ target, onClose }: { target: HistoryTarget; onClose: } }, [occData]) + const xRange = useMemo(() => { + const ts: string[] = [ + ...(rateData?.history ?? []).map(h => h.valid_from), + ...(occData?.snapshots ?? []).map(s => s.valid_from), + ] + if (!ts.length) return undefined + const sorted = [...ts].sort() + return [sorted[0], sorted[sorted.length - 1]] as [string, string] + }, [rateData, occData]) + const isLoading = rateLoading || occLoading return ( @@ -1248,6 +1258,7 @@ function OccHistoryModal({ target, onClose }: { target: HistoryTarget; onClose: height: 240, showlegend: true, legend: { orientation: 'h' as const, y: -0.35, font: { size: 11 } }, + xaxis: { ...PLOT_BASE.xaxis, ...(xRange ? { range: xRange } : {}) }, yaxis: { ...PLOT_BASE.yaxis, tickprefix: '£', title: { text: '£ / night' } }, }} config={{ displayModeBar: false, responsive: true }} @@ -1277,6 +1288,7 @@ function OccHistoryModal({ target, onClose }: { target: HistoryTarget; onClose: ...PLOT_BASE, height: 180, showlegend: false, + xaxis: { ...PLOT_BASE.xaxis, ...(xRange ? { range: xRange } : {}) }, yaxis: { ...PLOT_BASE.yaxis, range: [0, 100], ticksuffix: '%', title: { text: 'Occ %' } }, }} config={{ displayModeBar: false, responsive: true }}