File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -122,7 +122,20 @@ export function Chart({
122122 return (
123123 < Column gap = "6" >
124124 < Box { ...props } >
125- < canvas ref = { canvas } />
125+ { /*
126+ Position the canvas absolutely inside a relative-positioned
127+ wrapper. Chart.js writes inline pixel sizes onto the canvas, and
128+ while it lives in the normal flow that pixel width propagates up
129+ as min/max-content through every flex parent into the surrounding
130+ CSS Grid track, pinning the chart's column at its widest measured
131+ size and only resetting on a full page reload. Taking the canvas
132+ out of flow with position: absolute breaks that propagation; the
133+ wrapper sizes purely from its parent (width: 100%, height: 100%)
134+ and Chart.js' ResizeObserver picks up viewport changes.
135+ */ }
136+ < div style = { { position : 'relative' , width : '100%' , height : '100%' , overflow : 'hidden' } } >
137+ < canvas ref = { canvas } style = { { position : 'absolute' , top : 0 , left : 0 } } />
138+ </ div >
126139 </ Box >
127140 < Legend items = { legendItems } onClick = { handleLegendClick } />
128141 </ Column >
You can’t perform that action at this time.
0 commit comments