Repository navigation
feat: Support series mode on builder heatmaps - #3291
Conversation
🦋 Changeset detectedLatest commit: 5b1645f The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🔴 Tier 4 — CriticalTouches authentication, tenancy data models, the public API or shipped database config — or substantially changes the query rendering engine, background tasks, the OTel pipeline, image build, or release CI. Why this tier:
Review process: Deep review from a domain expert. Synchronous walkthrough may be required. Stats
|
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
|
fcc7298 to
a62bc4a
Compare
E2E Test Results✅ All tests passed • 398 passed • 1 skipped • 1310s
Tests ran across 4 shards in parallel. |
PR Review
5 finding(s): 🔴 0 critical · 🟠 1 major · 🔵 4 minor 4 posted as inline comment(s) on the changed lines. 1 listed below. Findings outside the changed lines1 minor
Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides. |
Deep Review✅ No critical (P0/P1) issues found. The feature is backward-compatible (new 🟡 P2 -- recommended
🔵 P3 nitpicks (1)
Reviewers (10): correctness, adversarial, testing, maintainability, kieran-typescript, performance, api-contract, project-standards, previous-comments, frontend-races. Testing gaps: No test covers the GET→PUT round-trip deletion of a series-mode heatmap tile via the external API; no test asserts that authored series config and No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond |
022ca75 to
be75f06
Compare
Yes! I have HDX-5619 to address a few granularity related problems with the heatmap |
| }, | ||
| ], | ||
| }; | ||
| }, [width, height, tickFormatter, scaleType, palette, hasFilter]); | ||
| }, [ | ||
| width, | ||
| height, | ||
| tickFormatter, | ||
| scaleType, | ||
| palette, | ||
| hasFilter, | ||
| seriesLabels, | ||
| cellKind, | ||
| ]); | ||
|
|
||
| const seriesAxisHover = useSeriesAxisHover(uplotRef, seriesLabels); | ||
|
|
||
| const highlightedPercentile = | ||
| const highlightedRow = | ||
| highlightedPoint && rowCount > 0 | ||
| ? bucketPercentiles.get(highlightedPoint.closestIndex % rowCount) | ||
| : undefined; | ||
| ? highlightedPoint.closestIndex % rowCount | ||
| : 0; | ||
| const highlightedCell: HeatmapTooltipCell | undefined = | ||
| highlightedPoint == null | ||
| ? undefined | ||
| : seriesLabels != null | ||
| ? { | ||
| kind: 'series', | ||
| name: seriesLabels[highlightedRow] ?? '', | ||
| formattedValue: formatHeatmapValue( | ||
| highlightedPoint.countVal, |
There was a problem hiding this comment.
Heatmap component exceeds size limit
The new series-axis hover and tooltip logic brings HeatmapPlot.tsx to 371 lines. The repository guide requires components to stay under 300 lines, so please extract the mode-specific plotting logic before merging.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
|
||
| // Series-mode heatmaps have no external schema yet. Emitting them as | ||
| // distribution tiles would corrupt them on a GET -> PUT round-trip. | ||
| if ( |
There was a problem hiding this comment.
🟠 major — External API/MCP GET now drops series-mode heatmap tiles, so a GET → PUT round-trip deletes them
PUT replaces the tile list, and its TileInput doc in v2/dashboards.ts says only tiles whose id matches an existing tile are kept. So any client that reads a dashboard and writes it back silently deletes every series heatmap a user built in the UI. On update, merge back the existing tiles that GET skipped (series heatmaps, and PromQL by the same reasoning), or reject the PUT. The comment saying this avoids corruption is misleading, because the tile ends up deleted instead.
Nothing blocks merge automatically, but a maintainer will expect this fixed if it is a real defect in code this PR changes. If it is about surrounding code, reply and say so instead of patching. Do not widen the PR. How to respond
| const SERIES_LABEL_MAX_LENGTH = 24; | ||
|
|
||
| /** Series-axis ticks, one centered on each row. */ | ||
| function seriesRowSplits(rowCount: number): number[] { |
There was a problem hiding this comment.
🔵 minor — Series axis draws a tick label on every row, so labels overlap once rows are shorter than the font
seriesRowSplits returns one split per row with no thinning, and uPlot draws every split it is given. A 50-series heatmap (the cap) in a ~300px dashboard tile gives about 6px per row, and the 24-character labels pile on top of each other. Thin the splits based on the plot height and the axis font size, for example by keeping every k-th row so labels never overlap. The hover tooltip already shows the full name.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| : seriesLabels != null | ||
| ? { | ||
| kind: 'series', | ||
| name: seriesLabels[highlightedRow] ?? '', |
There was a problem hiding this comment.
🔵 minor — A blank group-by value shows as an empty 'Series:' in the cell tooltip, but as '(blank)' in the axis tooltip
useSeriesAxisHover (SeriesAxisTooltip.tsx) maps '' to '(blank)', but the cell tooltip passes seriesLabels[highlightedRow] through unchanged. Apply the same '(blank)' mapping here, ideally through one shared helper.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| */ | ||
| export function isHeatmapCompatibleSource( | ||
| source: Pick<TSource, 'kind'>, | ||
| mode: HeatmapMode = 'distribution', |
There was a problem hiding this comment.
🔵 minor — New mode parameter on isHeatmapCompatibleSource is never passed by any caller
The only caller is getHeatmapTilesWithIncompatibleSources in api/.../v2/utils/dashboards.ts, and it calls with the source alone. The app uses getHeatmapSourceKinds directly. Drop the parameter until the external API supports series mode, or pass the tile's mode at that call site.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond


Summary
This PR adds a new heatmap "mode" in which the y-axis represents unique series (group-by values), the x-axis represents time, and the color is determined by an aggregate value over that group at that time bucket.
This is analogous to a timeseries chart, where instead of plotting the value of each series on the y-axis, the value is plotted on the color axis. Consequently, the builder interface and resulting query looks very similar to those from the time chart implementation.
When too many (>50) series are selected, a warning is shown, and only the top 50 series are shown (by the same math used for client-side time chart series limits.
Notes:
The y-axis series labels are truncated when necessary, with a tooltip that shows the full results.
Screenshots or video
How to test on Vercel preview
Create some series-mode heatmaps
References