Documentation

Ataytis Vega Studio documentation.

Build, inspect, refine, and share Vega-powered Power BI visuals.

Authoring fundamentals

Power BI extensions to Vega

Use the Power BI colour schemes, expression functions, pattern fills, and container signals that Ataytis Vega Studio adds to the standard Vega runtime.

What the Studio adds to Vega

A specification written for Ataytis Vega Studio is standard Vega, with a small set of additions registered into the runtime before your specification is parsed. They exist so a visual can inherit the report theme, format numbers the way the rest of the report formats them, and drive Power BI cross-filtering — none of which plain Vega knows anything about.

Container signals

If your specification omits width or height, the Studio supplies them as the signals pbiContainerWidth and pbiContainerHeight, so the visual fills whatever space Power BI gives it. Declaring your own fixed width and height overrides this, which is usually what you want only while designing at a known size.

A third signal, pbiContainer, carries the full container and scroll state as an object, for designs that need to react to scrolling as well as size.

PropertyMeaning
pbiContainer.width / heightCurrent visible container dimensions.
pbiContainer.scrollWidth / scrollHeightTotal dimensions of scrollable content.
pbiContainer.scrollLeft / scrollTopCurrent horizontal and vertical scroll positions.

Report theme colour schemes

Four Vega colour schemes are bound to the current Power BI report theme. Use them in a scale range and the visual will follow the report theme instead of hard-coded colours, including when the theme changes later.

SchemeUse for
pbiColorNominalUnordered categories — the report theme's data colours in order.
pbiColorOrdinalOrdered categories such as ratings or size bands.
pbiColorLinearA continuous measure rendered as a sequential ramp.
pbiColorDivergentA measure read against a meaningful midpoint, such as variance to target.
Vega scale
{
  "name": "colorScale",
  "type": "ordinal",
  "domain": { "data": "chartData", "field": "Category" },
  "range": { "scheme": "pbiColorNominal" }
}

Expression functions

These functions are available anywhere a Vega expression is, including signals, update encodings, and tooltip signals.

FunctionWhat it returns
pbiColor(value, shadePercent)A colour from the report theme, selected by zero-based index or by name. The optional second argument shades the result by a percentage.
pbiFormat(value, formatString)The value formatted with a Power BI format string, so a mark label matches the rest of the report.
pbiFormatAutoUnit(value, formatString)The same, but applying automatic display units — the equivalent of the Auto option in the Power BI formatting pane.
pbiPatternSVG(id, foreground, background)A pattern fill reference that can be used as a mark fill.
pbiCrossFilterApply(event, filterExpression)Applies a cross-filter selection to the report. See Power BI interactions.
pbiCrossFilterClear()Clears the current cross-filter selection.

Named theme colours

As well as a numeric index, pbiColor accepts the report theme's named colours. These follow the theme's sentiment and divergent settings, so a visual signalling good and bad states stays consistent with the rest of the report.

NameTheme colour
positive / goodSentiment positive.
negative / badSentiment negative.
neutralSentiment neutral.
min, middle, maxThe divergent minimum, midpoint, and maximum.
Vega expression
"fill": {
  "signal": "datum.Variance < 0 ? pbiColor('bad') : pbiColor('good')"
}

Pattern fills

Pattern fills give a second visual channel alongside colour, which matters when a report must stay readable in greyscale or for colour-blind viewers. pbiPatternSVG takes a pattern identifier and a foreground and background colour, and returns a fill reference.

GroupIdentifiers
Diagonal stripesdiagonal-stripe-1 to diagonal-stripe-6
Horizontal stripeshorizontal-stripe-1 to horizontal-stripe-9
Vertical stripesvertical-stripe-1 to vertical-stripe-9
Circlescircles-1 to circles-9
Dotsdots-1 to dots-9
Othercrosshatch, houndstooth
Vega mark encoding
"fill": {
  "signal": "pbiPatternSVG('diagonal-stripe-3', pbiColor(0), '#ffffff')"
}
Power BI extensions to Vega | AtaytisTech