Skip to content

Commit 35c9e4e

Browse files
sarg3ntclaude
andcommitted
fix(#103): chart canvases overflowing GridStack tiles
The chart-aspect-container's padding-bottom: 72% trick sizes the inner canvas from the parent's width — which worked under the old flex grid (every card was the same shape, height matched width naturally) but breaks under GridStack: the tile's height is gs-h × cellHeight (320px on a default tile), independent of the tile's width. Where width × 72% > 320px, the canvas overflowed the tile. Visible result on a typical viewport: legends + time-axis labels bleeding out of every chart card into the rows below them (screenshot in the PR thread). Fix: scope `.chart-aspect-container` so it behaves as a flex-fill container inside the GridStack grid: - #charts-grid .grid-stack-item-content → display: flex, flex-direction: column, height: 100%, overflow: hidden so the chart container can flex to the GridStack-set height and stragglers can't escape during resize transitions. - #charts-grid .chart-aspect-container → flex: 1 1 auto, min-height: 0, padding-bottom: 0. min-height: 0 is the flex-child idiom that lets the container shrink below its content's intrinsic size — without it, the chart refused to render below ~432px. - The original aspect-ratio rule stays in place for usages outside the metrics grid (drill-down drawer, etc.). The canvas absolute-fill rule (width/height: 100% !important) was already correct; it just needed a parent with a real flex- computed height to fill. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent fc023d7 commit 35c9e4e

1 file changed

Lines changed: 28 additions & 4 deletions

File tree

gearbox/internal/framework/templates/pages/metrics.templ

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,12 +448,36 @@ templ Metrics(user *models.User, servers []models.BoxConfig) {
448448
outline-offset: -4px;
449449
cursor: move;
450450
}
451+
/* Make each tile a flex column so the chart container can
452+
flex to fill the GridStack-controlled height instead of
453+
computing its own from the chart-aspect-container's
454+
padding-bottom trick (which was sized to viewport width
455+
and overflowed the tile). overflow:hidden clips any
456+
stragglers (legends, axis labels) that briefly extend past
457+
the bounds during GridStack resize transitions. */
451458
#charts-grid .grid-stack-item-content {
452-
/* Inherit the chart-card's own border-radius rather than
453-
the GridStack default (which is rectangular) so the
454-
drag handle visually matches the card. */
455-
overflow: visible;
459+
display: flex;
460+
flex-direction: column;
461+
height: 100%;
462+
overflow: hidden;
463+
}
464+
/* Inside a GridStack tile, drop the percent-of-width
465+
aspect-ratio trick — the tile's height comes from gs-h *
466+
cellHeight, and the canvas should fill what's left after
467+
the header row. min-height: 0 is the flex-child idiom
468+
that lets the container shrink below its content's
469+
intrinsic size (without it, the chart's reported size
470+
refuses to go below ~432px and overflows). */
471+
#charts-grid .chart-aspect-container {
472+
position: relative;
473+
flex: 1 1 auto;
474+
min-height: 0;
475+
width: 100%;
476+
height: auto;
477+
padding-bottom: 0;
456478
}
479+
/* Original aspect-ratio rule preserved for any usages
480+
outside the metrics grid (drill-down drawer, etc.). */
457481
.chart-aspect-container {
458482
position: relative;
459483
width: 100%;

0 commit comments

Comments
 (0)