Writing Vega specifications
Structure maintainable Vega JSON, separate reusable configuration, and use the Studio preview cycle to develop visual behavior safely.
Ataytis Vega Studio runs the Vega grammar and runtime, providing direct access to dataflow transforms, scales, projections, axes, legends, marks, signals, event streams, and expressions inside Power BI.
Specification and configuration
| Editor content | Keep here |
|---|---|
| Vega JSON | Schema, data references, transforms, signals, scales, axes, legends, marks, and visual-level metadata. |
| Configuration | Reusable Vega configuration such as default mark styling, axis defaults, legend defaults, range choices, and autosize behavior. |
Keeping configuration separate makes a complex specification easier to read and allows exported templates to preserve the applied configuration without flattening it into every mark definition.
Specification structure
- 1
Declare the schema and viewport behavior
Set
$schema, dimensions or container sizing, padding, background, and autosize behavior first. - 2
Declare datasets and transforms
Reference
dataset, then add named derived datasets and transforms in a logical order. - 3
Add signals
Keep visual parameters, interaction state, and responsive calculations in clearly named signals.
- 4
Define scales and projections
Use stable names and keep domain/range decisions close to the datasets they depend on.
- 5
Add guides
Define axes and legends after their scales so relationships remain easy to follow.
- 6
Build marks in visual stacking order
Place backgrounds first, data marks next, then labels, annotations, and interactive overlays.
- 7
Add metadata last
Use Studio-generated template metadata when exporting rather than hand-authoring portable field placeholders.
Authoring cycle
- Make one structural change at a time and apply it manually.
- Check Diagnostics immediately if the preview stops rendering.
- Check Data table before assuming a transform or scale is wrong.
- Use Live signals to verify interaction state and responsive calculations.
- Only enable live preview after the specification parses successfully.
- Save the PBIX at stable milestones and export reusable templates as separate versioned files.


