Skip to content

Keep the dashboard temperature tooltip inside the chart - #1039

Open
kaysond wants to merge 1 commit into
masterfrom
temperature_chart_bounds
Open

Keep the dashboard temperature tooltip inside the chart#1039
kaysond wants to merge 1 commit into
masterfrom
temperature_chart_bounds

Conversation

@kaysond

@kaysond kaysond commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Closes #950

What was happening

The dashboard temperature chart runs in sparkline mode, which forces legend.show = false, so the
only way to tell which line is which drive is the shared tooltip. That tooltip grows one row per
device, and two things then conspire against it:

  1. ApexCharts only keeps the top half of the tooltip inside the chart. Position.moveTooltip()
    clamps with if (tooltipRect.ttHeight / 2 + y > gridHeight), so the bottom of the tooltip can
    sit up to ttHeight / 2 below the chart.
  2. The card wrapping the chart is rounded overflow-hidden, so whatever hangs below gets clipped.

Measured on a 1280×900 viewport with 7 drives, hovering the series the way the reporter's screenshot
shows: the tooltip is 266px tall and 119px of it is cut off.

The fix

  • pin the tooltip with tooltip.fixed = { enabled: true, position: 'topLeft' }. That skips
    moveTooltip() entirely (if (!ttCtx.fixedTooltip) this.moveTooltip(...)) and anchors the tooltip
    to the top-left of the chart, so it is laid out downwards from a known point instead of around the
    cursor.
  • drop overflow-hidden from the chart card. For a large number of drives the tooltip is simply
    taller than the chart, and clipping it is what made it unreadable. The temperature card is the last
    block on the dashboard, so a tall tooltip just extends into empty page space.

Both are needed: fixed alone still clips from 8 drives up, because the tooltip becomes taller than
the 275px chart.

Measurements

Driven with headless Chromium against a production ng serve, hovering the chart and measuring the
tooltip against the clipping ancestor. "clipped" is how many pixels of the tooltip were cut off:

drives tooltip height before fixed only this PR
7 266px 119px clipped 0 0
8 299px clipped 12px clipped 0
12 431px clipped 144px clipped 0
16 563px clipped 276px clipped 0

Also checked at a 414×896 viewport (7 drives): tooltip fits, nothing clipped.

Not fixed here

The palette in _prepareChartData() has only 6 colours, and ApexCharts recycles them, so from 7
drives up two lines share a colour. That is a separate (and more debatable) change — the tooltip
markers have the same problem, and fixing it properly probably means generating colours rather than
listing them.

AI disclosure

Per AI_POLICY.md: this change was written by Claude Code (Opus 5). It reproduced
the bug, produced the numbers above, and made the change. Everything ran in a node:24-trixie
container driving headless Chromium via puppeteer against ng serve --configuration production, with
the API responses stubbed at the network layer so the drive count could be varied; nothing was
installed on the host.

Automated verification performed:

  • reproduced the clipping at 7 drives and confirmed it is gone after the change, at 7/8/12/16 drives
    and at a phone-sized viewport
  • npm run build:prod and npx ng test --watch=false --browsers=ChromeHeadless --code-coverage
    (87/87)

No unit test was added: the change is chart configuration, and a test asserting the option is set
would only restate the diff. The behaviour that matters is geometric and was checked in a browser.

That is the extent of the verification behind this PR as opened.

The chart runs in sparkline mode, which hides the legend, so the shared tooltip
is the only way to tell the lines apart. It grows a row per device, and
apexcharts only keeps the top half of it inside the chart, so the rest was
clipped by the card's overflow-hidden. With 7 drives 119px of a 266px tooltip
was cut off.

Pin the tooltip to the top left corner so it is laid out from a known point, and
stop the card clipping it, which matters once there are more drives than fit in
the chart's height.

Closes #950
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Styling issue: Temperatures out of graph container bounds

1 participant