Search code examples
vegavega-lite

Cache a dataset in Vega-lite or Vega-embed


I have a use case that a user can create different visualizations with a single dataset in a trial-and-error fashion. Is it possible to cache the loaded and parsed dataset in Vega to increase performance?

Update:

According to @dominik's answer, I tried to put the data inline as a JavaScript object. However, it seems Vega-lite still parses the data, which costs a lot of time. The spec I used is shown below, which shows the data is indeed inline.

The Vega-lite spec with inline data

The screenshot of Chrome's profiling tool shows that the parse function takes most of the time.

The stack shown in Chrome's profiling tool


Solution

  • Not out of the box because there aren't any guarantees that the data does not change. However, you can read the dataset outside of Vega and then pass it either inline in the spec or through the view API.