Skip to content

Analytics: keep bars stacked with target lines - #9565

Open
builder-factory wants to merge 5 commits into
mainfrom
ai_main_55c72afa74814809ab4c
Open

builder-factory wants to merge 5 commits into
mainfrom
ai_main_55c72afa74814809ab4c

Conversation

@builder-factory

@builder-factory builder-factory commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Combo charts now honor config.stacked for their bar series. Bars stack while line series, such as a target line, still render on top.

The proof line below proves the mixed-sign chart fix; the original chart-stack proof was locally demonstrated. Chat latency remains independently unresolved: the run span was 55,580 ms and the model span sum was 52,311 ms. Model spans are not necessarily serial, and their sum is not necessarily the time to the first visible answer. No provider attribution or latency fix is claimed.

Root cause

The combo renderer did not propagate stacked to its bar series. This is the likely root cause, but it is not confirmed in production because dashboard access returned 401.

Problem

An analytics dashboard panel that combined stacked bars with a target line rendered the bars grouped side by side instead of stacked. The combo renderer ignored stacked, so users couldn't have stacking and a target line at the same time.

Solution

The stacked flag is passed through to ComboRenderer. Bar series get a stackId, and the chart uses a signed stack offset so positive and negative values stack on opposite sides of zero. Lines are never stacked. Charts that don't set stacked keep the existing grouped-bar behavior.

Key Changes

  • ComboRenderer takes a new stacked prop. It is wired from DashboardPanelChart and the analytics template's SqlChartQuery.
  • ComposedChart gets stackOffset="sign" when stacked.
  • Each Bar gets a stackId. With dual axes, the ID is per axis (stack-<axisId>), so stacks on the left and right axes sit side by side instead of merging.
  • durationAxisProps accepts stackedKeys, so duration axes are sized to the stacked bar totals. Independent lines such as the target are still measured separately.
  • Added specs for these cases:
    • stacked bars with a target line on its own axis, and the default grouped layout;
    • positive and negative stacking;
    • stacks on different axes;
    • duration axis sizing, including legend toggling.
  • The test harness's getBoundingClientRect mock now returns text-based sizes for the Recharts measurement span.
  • Added an analytics changelog entry.

Notes

  • The diff only changes chart rendering. It makes no latency change for the reported slow chat runs, so any latency follow-up is outside this PR.

Edit in Builder  Preview

This PR was created by Factory (sami+factory-service-account@builder.io)

Verified

▶ Watch the interaction

Stacked combo charts with target lines (Combo charts: stacked and grouped)

Stacked combo charts with target lines (Combo charts: stacked and grouped)


To clone this PR locally use the Github CLI with command gh pr checkout 9565

You can tag me at @BuilderIO for anything you want me to fix or change

https://beta.agent-workspace.builder.io/fleet/inbox/3195

Reports

https://builder-internal.slack.com/archives/C0ATH3CCZT4/p1795199632958989
fix-proof: proven, red at 8accab4 (exit 1), green at fafe18b: pnpm --filter @agent-native/toolkit exec vitest run src/app/dashboard-charts/DashboardPanelChart.spec.tsx

@builder-io-integration builder-io-integration Bot changed the title Update from the Builder.io agent Fix stacked bars in combo charts with target lines Nov 20, 2026
@builder-io-integration builder-io-integration Bot changed the title Fix stacked bars in combo charts with target lines Analytics: keep bars stacked with target lines Nov 20, 2026
builder-io-integration[bot]

This comment was marked as outdated.

@github-actions

Copy link
Copy Markdown
Contributor

Visual recap — generation failed

Recap authentication failed — PLAN_RECAP_TOKEN was rejected; it may be expired, revoked, or minted for another Plans app. Personal token: run npx @agent-native/core@latest connect <app-url> --client codex, then npx @agent-native/recap-cli@latest recap setup. Org service token: an owner/admin can mint a 10-year replacement with npx -y @agent-native/core@latest connect <app-url> --service-token <name> --ttl-days 3650. Update this repo's secret.

builder-io-integration[bot]

This comment was marked as outdated.

@builder-io-integration

Copy link
Copy Markdown
Contributor

The combo renderer still applies the existing rounded-corner styling to each bar, so interior segments can indeed be rounded. I am leaving that cosmetic behavior unchanged in this PR: choosing the outermost segment correctly depends on each row, axis, sign, and hidden series, and changing it would broaden the rendering fix beyond the reported stacking regression. The existing browser verification covers stacking and target lines; it did not specifically validate corner treatment.

@builder-io-integration builder-io-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Builder reviewed your changes and has a few items to flag 🟡

Review Details

Incremental Review Summary

The latest PR head adds the @agent-native/toolkit patch changeset and adjusts the chart test harness/specs; the combo-chart implementation continues to pass stacked through both render paths, scopes stack IDs by Y axis, and uses signed stacking. I rechecked the prior rounded-corner concern: it remains present because the combo bars still use a fixed rounded-top radius for every segment. A second low-severity presentation inconsistency is that the combo tooltip does not receive stacked, so it cannot show the stacked total as the standard stacked-bar renderer does. No prior inline comments existed to resolve. A spec typecheck attempt encountered unrelated existing errors elsewhere in the toolkit; parallel review reports the chart spec passes. This is a standard-risk UI change. 🧪 Browser testing: Skipped — the browser-test-planner agent is unavailable in this environment.

@builder-io-integration

Copy link
Copy Markdown
Contributor

The missing stacked total in combo tooltips is a real presentation difference. Passing stacked directly to ChartTooltip would sum every tooltip item, including target lines and series on different axes (panel-chart.tsx, around the stackedTotal calculation), so it could display a misleading total. I am leaving the existing tooltip behavior unchanged; a separately specified per-stack total would need to account for axis, sign, and visibility. The rounded-corner concern was addressed in my earlier reply.

@builder-factory
builder-factory requested review from a team and sanyamkamat and removed request for a team November 20, 2026 20:48
@builder-factory

Copy link
Copy Markdown
Contributor Author

The factory stopped working on this PR: the agent is blocked: A single-repository worktree is needed for the required proof, and the unresolved latency report needs a closeout safeguard..

A person needs to take it from here. A new review or comment from a person hands it back to the factory for 3 more rounds.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants