🏠 back to Observable

Vega "fold" transformation does not work in Observable

I have written up an observable showing that neither vega-embed nor vega-lite has the transformation fold implemented and working.

I am lost on what the cause could be, there you go:

looking at the console you might need to use vega 4.2 and https://unpkg.com/vega-lite@3.0.0-rc3/build/vega-lite.min.js as the v. of vega lib you are using doesn’t recognize the fold transform. most likely was added in the latest release and why it works in vega editor.

1 Like

see this fork with a fix using latest vega and vega-lit libs:

.@mike & @tom I think it would be beneficial to update those libs for devs using @observablehq/vega-lite@0.1 shorthand require on this site to experiment with vega.

I would also suggest you version using vega v. So, @observablehq/vega-lite@3.0 would refer to a shorthand vega-lite div setup for that lib.

We’ll update @observable/vega-lite when Vega-Lite 3.0 is released. Currently only a release candidate is available, and we can’t pin to 3.0 until it is released.

In the meantime, you can use require.alias to override the dependencies and get a different version. For example, to get the latest version:

vegalite = require.alias({
  "vega": "vega@latest",
  "vega-lite": "vega-lite@latest"
})("@observablehq/vega-lite")
2 Likes

don’t work in that notebook for some reason.

It works here:

It won’t work if you’ve already require’d @observablehq/vega-lite without configuring require.alias in your notebook, since in that case require will return the previously-loaded module from the cache (without the aliases). Possibly d3-require should have separate caches for require.alias; I’ll file an issue. This bug has now been fixed in d3-require.

1 Like

perfect! now we have latest v and specific v. examples in place.

Thanks @mike!

Is this a similar issue ?

Error: Unrecognized function: isValid is the message returned by a vega-lite spec when using vega-embed@3.
see test notebook

Switching to approches 1 and 3 as reported at @mbostock/hello-vega-lite/2 i.e. requiring vega and vega-lite in a function, works well.