var spec = { "data": { "values": [ {"a": "C", "b": 2}, {"a": "C", "b": 7}, {"a": "C", "b": 4}, {"a": "D", "b": 1}, {"a": "D", "b": 2}, {"a": "D", "b": 6}, {"a": "E", "b": 8}, {"a": "E", "b": 4}, {"a": "E", "b": 7} ] }, "mark": "bar", "encoding": { "y": {"field": "a", "type": "nominal"}, "x": { "aggregate": "average", "field": "b", "type": "quantitative", "axis": { "title": "Average of b" } } } }; var opt = { "mode": "vega-lite" }; vega.embed("#vis", spec, opt, function(error, result) { // Callback receiving the View instance and parsed Vega spec // result.view is the View, which resides under the '#vis' element });