Skip to content

fix: escape dotted field names in Vega chart specs so dimension comparison charts render - #10086

Merged
nishantmonu51 merged 3 commits into
mainfrom
nishant/fix-dotted-dimension-chart-pivot
Nov 2, 2026
Merged

nishantmonu51 merged 3 commits into
mainfrom
nishant/fix-dotted-dimension-chart-pivot

Conversation

@nishantmonu51

@nishantmonu51 nishantmonu51 commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Dimension comparison on the explore page renders the shared Vega stacked bar, and nested Druid columns surface as dimensions whose names contain dots (for example query.context.metaData.type). The hover layer's pivot transform received that name unescaped, so Vega read it as a nested field path, threw inside the dataflow, and every time series chart rendered blank.

  • Escape the color dimension in createVegaTransformPivotConfig (used by the stacked, normalized, grouped bar and line charts), in the area chart's inline pivot, and in the grouped bar xOffset encoding.
  • Sweep the remaining spec builders for raw names handed to Vega as field references and escape them: the hover layer x field (which also restores custom x sorts for dotted dimensions), the normalized bar joinaggregate, the funnel window, fold, color and label encodings, the multi-measure, comparison and combo fold inputs, and the heatmap and pie label text. fold.as keeps the raw name because Vega emits the raw name as the fold key.
  • Add spec tests for every escaped slot via a vegaFieldReferences helper that collects each field reference in a spec, plus a headless Vega render test that fails on the unescaped name.

Steps to reproduce:

  1. Open an explore whose metrics view has a dimension with a dot in its name (any Druid nested column).
  2. Turn on dimension comparison for that dimension and select two values in the leaderboard.
  3. Before this change the measure charts are blank; after it the stacked bars render.

Closes APP-957

Checklist:

  • Covered by tests
  • Ran it and it works as intended
  • Reviewed the diff before requesting a review
  • Checked for unhandled edge cases
  • Linked the issues it closes
  • Checked if the docs need to be updated. If so, create a separate Linear DOCS issue
  • Intend to cherry-pick into the release branch
  • I'm proud of this work!

…e in chart specs

Follow-up to the dimension comparison fix: audit every spec builder for
raw field names handed to Vega as field references and escape them.

- builder.ts: buildHoverRuleLayer takes the raw x field, escapes it for
  the encoding and looks up custom sort values by the raw name, so a
  custom x sort is no longer lost for dotted dimensions.
- stacked-bar/normalized.ts: joinaggregate groupby and field are escaped.
- funnel/spec.ts: window field and sort, multi-measure fold, color,
  value label and stage tooltip encodings are escaped.
- multi-metric-chart.ts, comparison-builder.ts: fold inputs are escaped
  while fold.as keeps the raw name, which is what Vega emits as the key.
- heatmap/spec.ts, circular/pie.ts: data label text encodings are escaped.
- test-fixtures.ts: vegaFieldReferences helper collects every field
  reference in a spec; new tests assert dotted names only reach Vega
  escaped for the normalized bar, grouped bar sort lookup, multi-measure
  fold, comparison fold, funnel, heatmap and pie specs.
@nishantmonu51 nishantmonu51 changed the title fix: escape dotted dimension names in createVegaTransformPivotConfig so dimension comparison charts render fix: escape dotted field names in Vega chart specs so dimension comparison charts render Nov 2, 2026
buildHoverRuleLayer escapes the x field itself, but the area and combo
builders still passed a pre-escaped name, so any x field with punctuation
was escaped twice and the hover rule referenced a field that does not
exist. Both now pass config.x?.field. The combo fold inputs are escaped
as well, matching the multi-measure and comparison builders.

Adds regression tests for the area and combo hover x field and sort, and
for the combo fold, filter and color domain.
@nishantmonu51
nishantmonu51 merged commit f894b32 into main Nov 2, 2026
10 checks passed
@nishantmonu51
nishantmonu51 deleted the nishant/fix-dotted-dimension-chart-pivot branch November 2, 2026 15:01
nishantmonu51 added a commit that referenced this pull request Nov 2, 2026
…rison charts render (#10086)

* fix: escape dotted dimension names in Vega chart pivots so dimension comparison charts render

* fix: escape dotted field names at every remaining Vega field reference in chart specs

Follow-up to the dimension comparison fix: audit every spec builder for
raw field names handed to Vega as field references and escape them.

- builder.ts: buildHoverRuleLayer takes the raw x field, escapes it for
  the encoding and looks up custom sort values by the raw name, so a
  custom x sort is no longer lost for dotted dimensions.
- stacked-bar/normalized.ts: joinaggregate groupby and field are escaped.
- funnel/spec.ts: window field and sort, multi-measure fold, color,
  value label and stage tooltip encodings are escaped.
- multi-metric-chart.ts, comparison-builder.ts: fold inputs are escaped
  while fold.as keeps the raw name, which is what Vega emits as the key.
- heatmap/spec.ts, circular/pie.ts: data label text encodings are escaped.
- test-fixtures.ts: vegaFieldReferences helper collects every field
  reference in a spec; new tests assert dotted names only reach Vega
  escaped for the normalized bar, grouped bar sort lookup, multi-measure
  fold, comparison fold, funnel, heatmap and pie specs.

* fix: pass raw x fields to the hover layer from the area and combo charts

buildHoverRuleLayer escapes the x field itself, but the area and combo
builders still passed a pre-escaped name, so any x field with punctuation
was escaped twice and the hover rule referenced a field that does not
exist. Both now pass config.x?.field. The combo fold inputs are escaped
as well, matching the multi-measure and comparison builders.

Adds regression tests for the area and combo hover x field and sort, and
for the combo fold, filter and color domain.

(cherry picked from commit f894b32)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants