Search code examples
vega-liteobservablehq

Can I use vegalite v-5 in observable notebook using JSON syntax (not using vegalite API)?


The require("@observablehq/vega-lite") doesn't allow us to use vegalite v-5. It uses older versions. I know import {vl} from '@vega/vega-lite-api-v5' allows us to use version-5 and write in more programmatic fashion. But, the syntax on the vegalite homepage and using API is different. So, isn't there any way to use vegalite v-5 in JSON syntax (like of examples on https://vega.github.io/vega-lite/?

Thanks!


Solution

  • @observablehq/vega-lite was a helper to make vega-lite easier to embed in Observable notebooks, but it's not needed anymore since we now have an official Vega-embed module:

    // https://observablehq.com/@vega/hello-vega-embed
    embed = require("vega-embed@6")
    
    embed({ vega or vega-lite spec… })
    

    Note that Vega-embed accepts both Vega and Vega-lite specifications.