/fabric-apps:vega-lite-app-gotchasfrom fabric-apps
Fixes Vega-Lite rendering issues in React/Power BI/Fabric apps: ordinal sorting, multi-series tooltips, CSS variable resolution, axis label clipping, KPI card layout, and fabric-visuals 5.0 traps.
Ships in fabric-apps. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Fourteen traps that cost real time when rendering Vega-Lite specs through a VegaVisual
component (Vega writes resolved SVG; Tailwind tree-shakes; cards clip). Each looks like it
should work; the fix is non-obvious.
Labels, layers and dates are in
references/labels-layers-dates.md: a value label cut
at the plot edge or over the row names, two-line axis labels on the marks, Conflicting axis property labelExpr, a test on a temporal field that never matches, month labels a month out.
Source: distilled from the Sparklines / Bullet / Imperial-DSMS Fabric Apps. Hex values in examples are the corporate-blue design tokens (
--ds-blue-700=#1F4E8C).
labelExprA sort: ["Jan", "Feb", …] array on an ordinal axis is often ignored and the axis sorts
alphabetically (Apr, Aug, Dec, …). Don't fight it with sort: { field, op: "min" }.
Bind the axis to the numeric field (ordinal scales sort numerically for numeric data)
and re-label ticks with labelExpr:
// ❌ Looks right, didn't sort
x: { field: "monthShort", type: "ordinal", sort: ["Jan","Feb", /* … */ "Dec"] }
// ✅ Numeric field sorts correctly; labelExpr restores the text
x: {
field: "monthOfYear", type: "ordinal",
axis: {
labelExpr:
"['','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'][datum.value]",
},
}
Same fix for any "string label that should sort by a hidden numeric".
rule layer + pivotFor a multi-series line chart with point: true, Vega's nearest-x default tooltip kicks in,
shows ALL series with raw field names, and silently ignores your custom tooltip: [...].
The canonical fix is a selection-free invisible rule layer that owns the tooltip:
{
transform: [
{ pivot: "businessLine", value: "revenueLabel", groupby: ["monthOfYear", "monthShort"] }
],
mark: { type: "rule", opacity: 0, strokeWidth: 32 }, // 32px-wide hover region
encoding: {
color: { value: "transparent" },
tooltip: [
{ field: "monthShort", title: "Month" },
...seriesNames.map((name) => ({ field: name, title: name })),
],
},
}
Pass seriesNames in from React (Array.from(byLine.keys())); don't hardcode them. This
pattern is selection-free on purpose (see #8).
~sformat: "$,.2s" auto-picks SI suffixes, so one tooltip mixes $420k and $1.2M. When the
user said "in millions", compute a string column in the React data table and reference
it as a nominal field:
const fmtMillions = (v: number) => "$" + (v / 1_000_000).toFixed(2) + "M";
// row: { …, revenueLabel: fmtMillions(r.revenue) }
tooltip: [{ field: "revenueLabel", title: "Revenue" }]
var(--ds-*): hardcode hex inside the specCSS variables work in DOM nodes but Vega writes resolved SVG, where CSS vars become empty strings (→ "color is not a valid CSS color", or nothing renders). Inside any Vega spec use literal hex:
const BLUE_700 = "#1F4E8C"; // mirror the design token once, at module top
mark: { type: "bar", color: BLUE_700 } // ✅ (never color: "var(--ds-blue-700)")
Keep a small palette object per page module so the values live in one place.
--color-brand must be in @theme staticVegaVisual and DataGrid call useCssTheme(), which reads --color-brand at runtime. If
it's only set via @theme { … }, Tailwind tree-shakes it out when no utility consumes it and
the chart loses its primary color. Force it with @theme static:
@theme static {
--color-brand: #1F4E8C;
--color-brand-foreground: #1F4E8C;
--color-hover: #F1F6FC;
}
minHeight, not fixed height + overflow:hiddenA ChartCard body with overflow: hidden and a fixed height makes Vega's bottom axis labels
vanish silently. Let the SVG's natural size drive the container:
// ❌ <div style={{ padding: 16, height: bodyHeight, overflow: "hidden" }}>
// ✅
<div style={{ padding: 16, minHeight: bodyMinHeight }}>
A label + big value + conditionally-coloured pill is well-suited to Vega-Lite layered
text/rect marks with literal pixel coordinates (x: { value: 0 }, y: { value: 30 }).
Pre-format the metric as a string (nominal) so each card chooses its own currency /
percent format without baking d3-format codes into the spec.
params: { name: "hover" } for multi-series tooltipsRe-rendering the same named selection triggers "Duplicate signal name: hover_tuple". The
invisible-rule + pivot pattern in #2 is selection-free and side-steps this entirely.
VegaVisual and VisualContainerFound building the Reading Room app on @microsoft/fabric-visuals 5.0.0 (31 Oct 2026), each
confirmed with a headless renderVisualToSvg render as well as in the browser.
axis: null is ignored: switch the parts off one by oneThe axis still draws, labels, ticks and title included. For a bar chart labelled at the bar ends:
x: { field: "Hours", type: "quantitative",
axis: { labels: false, ticks: false, domain: false, grid: false, title: null } }
format and formatType are ignored: format ticks with labelExprA temporal axis with format: "%a %e %b" printed NaN, and a quantitative axis with
format: ".0%" used the column's model format string instead. labelExpr is honoured:
axis: { labelExpr: "utcFormat(datum.value, '%a %e %b')" } // temporal
axis: { labelExpr: "format(datum.value, '.0%')" } // a 0-1 share
sort with the default op: use max or minLayers share (union) the y scale's domain, and a union accepts only count, min and max
sort ops (the warning reads "as unioned domains only support boolean or op "count", "min",
and "max""). sort: { field: "Hours", order: "descending" } defaults to sum, so it is dropped and the bars fall back to
alphabetical order. A bar plus its text label is two layers, so this bites every labelled bar:
y: { field: "Area", type: "nominal", sort: { field: "Hours", op: "max", order: "descending" } }
A text mark over a number prints "2.1K" for 2,131. Add the label as a pre-formatted string
column in the data table (as in #3) and encode it as nominal.
fieldId, and values are taggedonInteraction events carry selections[0].predicates, each
{ type: "set", fieldId, values: [{ kind: "value", value }] } (not name and bare values). A
clear arrives as action: "clear" or an empty selections.
selectableFields lets a click select a field the mark does not encode, such as the part of the
site behind a page's bar.
VisualContainer's header toolbar re-wraps the title on hoverWith a header, the Copy visual and More actions toolbar sits in flow beside it at zero width
and widens on hover or focus, by design, so a wrapping title re-wraps and the chart under it
jumps. Keep the width and fade the toolbar instead, in a cascade layer after fabric-visuals
(the library's Griffel styles live there):
@layer components {
[vc-toolbar=""] { width: auto; margin-inline-start: var(--spacing-m); overflow: visible;
opacity: 0; transition: opacity 150ms ease-out; }
[data-lyra-selection-boundary]:hover [vc-toolbar=""],
[data-lyra-selection-boundary]:focus-within [vc-toolbar=""],
[vc-toolbar=""]:has([aria-expanded="true"]) { opacity: 1; }
}
[data-lyra-selection-boundary] is the container's own root; a bare section:hover also
matches any <section> inside the card. Without a header the toolbar floats above the card's
top edge instead, which overlaps the card above in a tight grid.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
vega-lite, power-bi, fabric-visuals, chart-gotchas, svg-css-variables
3 skills in this plugin
/fabric-app-workflowThe authoring conventions for a Fabric / Rayfin data app over a published semantic model (how query+spec+factory files are organised, the mockup→wire-spec→production pipeline, the Claude Design ZIP handoff, reusable Sparkline props, and matrix/table UI gotchas). Invoke when adding a new chart/visual to a Fabric App, asking "where do DAX queries live", "how do I wire a Vega spec", "where do I put a new query", working with `mockups/`, `.vl.json5` / `.jsonc` specs, `npm run mockups:watch` / `wire-spec` / `import-design`, the `src/queries/<domain>/` triplet pattern, building a reusable Sparkline component, fighting matrix/table column widths or fabric-datagrid headers cut short, Show as table printing raw numbers, a page that breaks at phone or laptop widths, writing card titles that state a finding computed from the rows, or `replace_all` indentation edits./rayfin-fabric-cliOperational gotchas for building Microsoft Fabric Apps with the Rayfin scaffold and the `fabric-app-data` / `rayfin` CLIs (Vite + React data apps over a published semantic model, with optional Fabric SQL DB writeback via DAB GraphQL). Invoke on TLS/certificate errors from npm/npx or the Fabric SDK, "rayfin up" / "db apply" failures, `fabric-app-data query` "too many arguments", "Dialect is required when Data module is enabled", "No compiled data/*.js files found", TS6377 tsBuildInfo errors, a writeback `create()` that silently never lands a row, UUID primary-key / `NEWID()` issues, or enabling the data service on an app scaffolded without it. Also invoke before scaffolding a new app (`npm create @microsoft/rayfin`, `rayfin init`), before passing `--overwrite`, when a fresh `dataapp` scaffold has no `fabric-visuals` or `src/queries`, when the scaffold's install fails with EALLOWSCRIPTS, or when running DAX through `fabric-app-semantic-model-tools run-dax-query`. Covers scaffold target safety, the template versions (SDK or connector), NODE_OPTIONS, the npm 11.16 allow-scripts failure, AVG HTTPS-shield interference, query CLI syntax, what the first `rayfin up` changes, the five edits to turn on writeback, and client-supplied UUID ids.npx claudepluginhub insightfulanalytics/pbi_agentic_dev --plugin fabric-appsOther plugins' skills for the same job