Repository navigation
perf(dashboard): limit stacked bar series by bar count - #3898
karl-power wants to merge 2 commits into
Conversation
Stacked bars draw one rect per series per time bucket, so 100 series over 60 buckets renders 6,000 bars and takes ~4x longer than 25 series. The 100-series draw cap also kept the first series alphabetically and dropped the rest with no notice. - By default, draw as many stacked bar series as fit in 1,500 bars (10-100). An explicit seriesLimit or "load all" lifts it to 100. - Keep the highest-peak series when the draw cap trims, preserving lineData order so stacking and colors don't shift. - Count series past the draw cap in the hidden-series notice; only offer "load all" when it would show more. - Describe the stacked bar default in the Series Limit setting.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 8ab5d6c The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 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 |
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
🟡 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
|
| (dateRange[1].getTime() - dateRange[0].getTime()) / | ||
| (convertGranularityToSeconds(granularity) * 1000), | ||
| ); | ||
| return Math.min( |
There was a problem hiding this comment.
🟡 P2 — maxDrawnSeries counts lines, but seriesLimit and the notice's counts are logical groups
Measure the draw cap in groups (or convert it), and make loadAllDrawCount in useChartToolbarItems.tsx use the same unit. Example: 2 value columns × 60 groups gives 120 lines. The notice offers "Draw all 60" because min(HARD_LINES_LIMIT, renderedSeriesCount) = 60 ≥ 60. After the click, only 100 lines (50 groups) are drawn, and the notice then reports 10 hidden groups with no further action. In the same way, an explicit seriesLimit: 40, which the SQL applies to groups, becomes a 40-line cap, so only 20 groups are drawn.
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
There was a problem hiding this comment.
Fixed in 8ab5d6c. The draw cap still bounds lines, but it now keeps or drops whole series, and the notice and "Draw the top N" count series. An explicit Series Limit lifts the stacked bar budget instead of becoming a line cap.
PR Review
3 finding(s): 🔴 0 P0/P1 · 🟡 3 P2 · 🔵 0 P3 2 posted as inline comment(s) on the changed lines. 1 listed below. Findings outside the changed lines
Priority comes from a separate grading pass over the finished review. P3 is folded here instead of posted inline. No finding blocks merge automatically; a maintainer decides. |
Deep Review✅ No critical issues found. This is a client-side chart-rendering/UX change (TypeScript/React, ~230 production lines, no auth/API/DB/persistence). The prior Cursor Bugbot "draw cap splits multi-aggregation groups" concern was independently verified as resolved: 🟡 P2 -- recommended
🔵 P3 nitpicks (6)
Reviewers (10): correctness, adversarial, kieran-typescript, performance, testing, maintainability, project-standards, previous-comments, agent-native, learnings-researcher. Testing gaps:
Note: the touched files ( 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 |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e016889. Configure here.
E2E Test Results✅ All tests passed • 500 passed • 1 skipped • 1112s
Tests ran across 4 shards in parallel. |
The draw cap ranked and counted individual lines, while the notice and seriesLimit count series. On charts with several value columns this split a series' lines, offered "Draw all N" for more series than fit, and turned an explicit seriesLimit into a line cap. - Rank series by peak and keep or drop all of a series' lines together, still bounded by the line cap. - Lift the stacked bar budget for an explicit seriesLimit instead of capping lines to it. - Count drawn and "load all" series in the notice's unit.
|
Review follow-up (8ab5d6c):
|
| @@ -283,8 +290,21 @@ export const MemoChart = memo(function MemoChart({ | |||
| ); | |||
|
|
|||
| const visibleLineData = useMemo( | |||
There was a problem hiding this comment.
🟡 P2 — The visible-line cap now scans every bucket × line on each selection change and runs up to three times per data change
Before this PR, getVisibleLineData was a slice. It now loops over graphResults × selected (up to 5,000 loaded series after "load all" × every bucket). It runs in MemoChart whenever selectedSeriesNames changes, for example on each keystroke in the legend table search. It also runs once or twice more in DBTimeChart's countDrawn (DBTimeChart.tsx:503-522), with the same unselected inputs MemoChart then repeats. The existing scan in ChartUtils.tsx:1002 avoids this by visiting only populated cells. Fix: precompute a peak rank per group once per result, as in the previous finding. The cap then becomes a linear walk, and DBTimeChart can pass the drawn set down instead of recomputing it.
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
| ? `Maximum number of series rendered, keeping those with the largest values. Leave empty for the default (${MAX_RENDERED_TIME_CHART_SERIES}); set 0 for unlimited.` | ||
| : `Maximum number of series fetched for a group-by chart, keeping those with the largest values. Leave empty for the default (${MAX_RENDERED_TIME_CHART_SERIES}); set 0 for unlimited.` | ||
| ? `Maximum number of series rendered, keeping those with the largest values. Leave empty for the default (${seriesLimitDefault}); set 0 for unlimited.` | ||
| : `Maximum number of series fetched for a group-by chart, keeping those with the largest values. Leave empty for the default (${seriesLimitDefault}); set 0 for unlimited.` |
There was a problem hiding this comment.
🟡 P2 — Builder stacked-bar help text says the fetch default is "as many as fit in 1,500 bars", but the bar budget only limits drawing
For builder charts the description reads "Maximum number of series fetched… Leave empty for the default (as many as fit in 1,500 bars)". An empty limit still loads up to MAX_RENDERED_TIME_CHART_SERIES (250). The bar budget only limits what is drawn (DBTimeChart maxDrawnLines). Any explicit value, even 250, switches the draw limit back to 100. Fix: keep the fetch default as 250 in this sentence and add a separate clause that stacked bars draw only as many series as fit in 1,500 bars unless a limit is set.
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
Caps stacked bar time charts by the number of bars drawn, so high-cardinality group-bys stay responsive, and makes the hidden-series notice account for every series the chart doesn't draw.
Screenshots or video
Screenshots not captured yet; to be added before review.
How to reproduce
On
main:/chart) and select the traces source.concat('pod-', toString(cityHash64(TraceId) % 122)), select the stacked bar display, and click Run.On this branch:
Note
Medium Risk
Changes core chart draw/cap logic and user-facing toolbar warnings across all time charts, but behavior is heavily unit-tested and scoped to rendering limits rather than data or auth.
Overview
Stacked bar charts now default to drawing only as many series as fit a 1,500-bar budget (
getStackedBarSeriesCapfrom time range / granularity), instead of always using the 100-line draw cap.DBTimeChartpassesmaxDrawnLinesandgroupKeyByDataKeyintoMemoChart; explicit Series Limit, Series Limit 0, or “load all” still use the normal 100-line cap.Over the draw limit,
getVisibleLineDatano longer keeps the first N lines in color order. It ranks whole series groups (value columns and previous-period lines stay together) by largest peak ingraphResults, with an optional custommaxLines.The hidden-series warning now includes series that are loaded but not drawn (
undrawnSeriesCount). Copy and actions distinguish Load all vs Draw the top N when everything is already materialized. Display settings describe stacked bars as Default (auto) / “as many as fit in 1,500 bars.”Reviewed by Cursor Bugbot for commit 8ab5d6c. Bugbot is set up for automated code reviews on this repo. Configure here.