This website is for Vega-Lite v1. Go to the main Vega-Lite homepage for the latest release.

Compiling Vega-Lite to Vega

If you would rather compile your Vega-Lite specifications into Vega, you can use Vega-Lite’s included javascript compiler or one of several bundled command line utilities.

First install Vega-Lite using npm (npm install vega-lite) or by downloading the latest release. (For the latter, you will also have to download Vega and D3.)

Using Javascript

If you want access to the compiled Vega spec from a Javascript program, you can compile your Vega-Lite spec using the vl.compile function.

var vgSpec = vl.compile(vlSpec).spec;

Then, you can continue to use the Vega runtime’s vg.parse.spec method to render your Vega spec.

vg.parse.spec(vgSpec, function(chart) {
  chart({el:"#vis"}).update();
});

From the Command Line

If you want to compile your Vega-Lite specs from the command line, we provide a set of scripts which make it easy to go from Vega-Lite to Vega, SVG, or PNG. These scripts are vl2vg, vl2svg, and vl2png respectively.

Each script simply accepts your Vega-Lite specification as its first argument.

vl2svg vlSpec