Scott/combo chart fix#428
Open
sagrimson wants to merge 6 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a stable Y-axis width calculation for charts by extracting measurement utilities into a shared measure_axis_width.ts file, and updates horizontal/vertical bar and line charts to use it. It also enhances the query provider, store, and comparison chart derivation to correctly support same-place, different-variable comparisons by merging and narrowing results appropriately. The review feedback points out that the helper functions niceNum and numericAxisLabels were duplicated in both data_chart_bar_vertical.tsx and data_chart_line.tsx instead of being imported from the new utility file.
sagrimson
force-pushed
the
scott/combo-chart-fix
branch
from
July 24, 2026 23:47
7097b97 to
aa8960f
Compare
sagrimson
force-pushed
the
scott/combo-chart-fix
branch
from
July 24, 2026 23:58
aa8960f to
6b08ae9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Fixes combo (comparison) chart generation when multiple variables are selected for the same place, adds LLM-driven chart style changes and compare/combine intent detection, and stabilizes the Y-axis width across all chart types.
Previously, selecting cards like "Female Life Expectancy in Japan" and "Male Life Expectancy in Japan" would overwrite each other since they shared the same entity key, resulting in only one series appearing in the combined chart. Additionally, changing chart styles and triggering combine/compare flows relied on fragile client-side regex matching — both are now delegated to the LLM via the query parsing step.
Changes Made
LLM-driven chart style changes
chartStyleIntentin query parsing — the LLM can now detect when a user wants to change chart appearance (e.g. "make these horizontal", "switch to a line chart") and returns achartStyleIntentwith atargetStylevalue (bar-vertical|bar-horizontal|line). Unsupported chart types (pie, scatter, etc.) produce a follow-up with supported options instead (parse_query.md,parse_query.ts)chartStyleChangestream event — new stream event type lets the server signal a style change; the client applies it to all selected chart shapes and persists it in the store (types.ts,route.ts, query_provider.tsx)chartStyleon cards —ChartStyletype promoted from the local menu component toserver/types.ts; stored onCardEntry, the tldraw shape props, andAtlasContentso it survives across export/import and re-renders (types.ts, store.ts,helpers.ts,shapes/card.tsx,chart.tsx,menu_chart_options.tsx)cardSetChartStylestore action — new zustand action to update a card's persisted chart style (store.ts)LLM-driven combine/compare intent
combineIntentin query parsing — the LLM detects compare/combine requests (e.g. "combine these", "compare these charts") when multiple chart cards are selected, replacing the client-sideisCombineIntentregex. ReturnscombineIntent: truein the parsed query (parse_query.md,parse_query.ts)route.tshandlescombineIntentas an early exit: runs the comparison step directly with the selected results sent from the client, removing the separate/api/combineendpoint dependency for this pathhasChartSelection,chartSelectionCount, andselectedResultsare now included in the query request so the LLM and server have full context about what's selected (types.ts, query_provider.tsx,route.ts)Same-place multi-variable fix
variablesandtimeSeriesarrays instead of overwriting. Deduplicates bydcid/variableDcid+entityDcidso repeated entries are skipped (query_provider.tsx)deriveComparisonChartContentdetects same-place vs. different-place scenarios: when all results share one entity it overlays every variable as a separate series; otherwise it builds one series per place as before (sync_store.ts)deriveChartContentForVariablederives chart content targeting a specific variable DCID (and optionally entity DCID), used byderiveContentForCardwhen a card hasvariableDcidset (sync_store.ts)getResultsForSelectedCardsuses a compositeentityDcid::variableDcidkey so cards with the same place but different variables produce distinct results; narrows each result to only the targeted variable'stimeSeriesandvariableswhencard.variableDcidis set (store.ts)Stable Y-axis width
measureAxisWidthutility — new shared utility uses a cached off-screen<canvas>to measure the widest label in pixels; companionnumericAxisLabelsgenerates representative formatted tick strings. Applied to bar-vertical, bar-horizontal, and line charts, replacing Recharts'width="auto"with a pre-measured value that prevents layout jitter on resize (measure_axis_width.ts)Minor