Repository navigation
fix(cli): make stacked bar legends match what is drawn - #3385
jordan-simonovski wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
🦋 Changeset detectedLatest commit: 767ef75 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
🟡 Tier 3 — StandardIntroduces new logic, modifies core functionality, or touches areas with non-trivial risk. Why this tier:
Review process: Full human review — logic, architecture, edge cases. Stats
|
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
PR Review
3 finding(s): 🔴 0 critical · 🟠 1 major · 🔵 2 minor 2 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. |
[Medium impact] This PR appears safe to merge; no actionable issues remain. SummaryUpdates
Both earlier, unnumbered findings are fixed in this PR: the legend fits its hidden count into the reserved space, and partial cells use the largest overlap. No new actionable issues were found. Reviews (3) · Last reviewed commit: "fix(cli): keep the stacked bar legend wi..." · Reviewed by Greptile |
Deep Review✅ No critical issues found. This PR is a well-scoped, well-tested CLI rendering change. The two prior greptile findings (legend exceeding chart width; a smaller series winning a partial top cell) are both genuinely resolved in the current code, each with a dedicated regression test. No correctness, security, or data-integrity issues surfaced. Remaining items are maintainability/test-coverage polish. 🟡 P2 — recommended
🔵 P3 nitpicks (4)
Reviewers (7): correctness*, adversarial*, kieran-typescript, maintainability, testing, previous-comments, project-standards. (*The correctness and adversarial reviewers did not return before synthesis; their lanes were covered by an independent orchestrator pass over the legend height-reservation, Testing gaps:
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 |
E2E Test Results✅ All tests passed • 440 passed • 1 skipped • 1379s
Tests ran across 4 shards in parallel. |
|
Replies to the review findings outside the changed lines, all addressed in 971b042f7:
Added the 1000/13/11/6 case, which fails under both the old sampling and the midpoint rule. Cells are now assigned by largest overlap.
The label is now "+N not shown", which is true for both causes: a series too thin to fill a cell, or one whose buckets were merged away to fit the width. |
| } | ||
|
|
||
| // Sized for every series; the drawn legend lists only those that show up. | ||
| const fullLegend = showLegend ? renderLegend(series, width) : ''; |
There was a problem hiding this comment.
🟠 major — Legend rows are reserved without room for the +N not shown tail, so visible series get dropped from the legend
Here is a case that fails. At width 60 there are two large series whose labels are 26 chars each, plus one tiny undrawn series x. The full legend fits on one line (26+2+26+2+3 = 59), so maxLines becomes 1. The legend that is actually drawn needs 26+2+26+2+12 = 68 chars, so renderLegend pops B, a full-height visible band, and prints ● A +2 not shown. That is the mismatch this PR is meant to remove. Fix: when sizing the plot, reserve legend rows for the labels plus a worst-case tail. Alternatively, work out the drawn set before fixing plotHeight (for example with a first pass at the tentative height). Either way, renderLegend should never have to evict a drawn series to fit the count.
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 shownSeries = series.filter(s => drawn.has(s.dataKey)); | ||
| const legendLines = showLegend | ||
| ? renderLegend( | ||
| shownSeries, |
There was a problem hiding this comment.
🔵 minor — The chart can come out shorter than height when the drawn legend needs fewer rows than the full one
plotHeight is sized from fullLegend, which lists every series. The drawn legend is often much shorter. For example, with 12 series and 2 drawn, the full legend takes 2 rows but shownSeries plus the tail fits on 1. The output is then one line shorter than the requested height, leaving a blank row under the tile in the dashboard grid. Fix: pad the legend to the reserved row count, or size plotHeight from the legend that is actually rendered.
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
With more than 8 series the palette repeated, so a large band could share its colour with series too small to draw, and the legend listed all of them in arrival order. Series are now ranked by peak like the web, the legend lists only series that are visible (with a count of the rest), a partial top cell takes the series filling most of it, and wide bars get a gap column. The stacked bar renderer moves to its own file.
Address review feedback on #3385: - The hidden-series count is now laid out by renderLegend, which reserves room for it (and for its own "+K more") instead of appending past the width; it takes a spare legend row when one is free. - Undrawn series are counted as "+N not shown", since merged buckets can leave large series undrawn, not only small ones. - A partial cell goes to the series overlapping most of its filled part. - The peak-ranking comment no longer claims to match the web.
971b042 to
767ef75
Compare
Summary
hdxstacked bar charts now let you tell the series apart. With more than eight series the palette repeated, so a large band could share its colour with series too small to draw, and the legend listed every series in arrival order whether it was visible or not.termchart/stackedBar.ts, sincetimeseries.tswas over 300 lines.How to reproduce
Starting point: a log or metric source with ten or more values of a group-by column, one of which dominates.
On this branch:
yarn cli:dev chart --source <source> --display stacked_bar --group-by ServiceNameOn
mainthe same command lists every service, with colours repeating after the eighth.How to test on Vercel preview
N/A, non-UI change.
References