example 2 - abudaan/vega-multi-view GitHub Wiki

import { addViews } from 'vega-multi-view';
import fetchYAML from 'fetch-helpers';

fetchYAML('../my-global-config.yaml', 'yaml')
    .then(data => addViews(data, 'yaml'))
    .then(result => {
        console.log(result)
    });

Here we see an example where the global configuration is loaded as a YAML file. We use a small library called fetch-helpers that can fetch files in JSON, BSON, CSON and YAML format and parses the content of the file to a javascript object.

Although both fetch-helpers and vega-multi-view detect the file-type automatically, you can optionally pass the type as argument which makes it a tiny bit faster.

Note that you can not provide a type for view specific configurations or for the vega specs; in those cases vega-multi-view will detect it for you and log a warning to the browser console if the type can not be inferred.