addViews() - abudaan/vega-multi-view GitHub Wiki

// @flow
addViews(
    config: string | ConfigType,
    type?: "yaml" | "json" | "cson" | "bson" | "json-string"
): Promise<any>

You can pass the uri of a global configuration file or the configuration as object or JSON string. If you provide a uri, you can provide the file-type of the configuration file with the optional second argument. If you provide the configuration file as an object or a JSON string you can pass object and json-string respectively as the second argument. If you leave this empty, vega-multi-view will detect the file-type for you.

The types listed below will be explained in detail in configuration chapter.

// @flow
type ConfigType = {
    debug?: boolean,
    overwrite?: boolean,
    element?: string | HTMLElement
    renderer?: "canvas" | "svg",
    type?: "yaml" | "json" | "cson" | "bson" | "json-string" | "object",
    run?: boolean,
    hover?: boolean,
    specs: {
        [string]: SpecType,
    },
    styling?: StylingType,
    dataPath?: string,
    imagePath?: string,
};

type SpecType =
    | string
    | VegaSpecType
    | [string, string]
    | [VegaSpecType, string]
    | [VegaSpecType, ViewConfigType]
;

type StylingType = {
    url?: string,
    css?: string,
    cssAppend?: boolean,
    addToHead?: boolean,
    classes?: string | Array<string>,
    classesAppend?: boolean,
};

type ViewConfigType = {
    spec?: string,
    element?: false | string | HTMLElement
    renderer?: "canvas" | "svg",
    type?: "yaml" | "json" | "cson" | "bson" | "json-string" | "object",
    run?: boolean,
    hover?: boolean,
    leaflet?: boolean,
    styling?: StylingType,
    publish?: SignalType | Array<SignalType>,
    subscribe?: SignalType | Array<SignalType>,
    tooltipOptions: TooltipType,
};

type SignalType = {
    [signal: string]: string,
    [as: string]: string,
};

type TooltipType = {
    [showAllFields: string]?: boolean,
    [fields: string]?: {
        [formatType: string]: string,
        [field: string]: string,
        [title: string]: string,
    },
};

After all views have been added to the page, the resolve function returns a key-value store object containing information about each view. Information per view:

// @flow
type ResultType = {
    // The id as you have set it in the specs object (see below)
    id: string,

    // Reference to the HTML Element that contains the Vega view or
    // null in case of headless rendering.
    element: null | HTMLElement

    // The Vega specification as javascript object (see below)
    spec: VegaSpecType

    // The view specific configuration (see below)
    vmvConfig: ViewConfigType

    // Reference to the HTML element that contains the rendered Vega
    // view
    view: HTMLElement
};
⚠️ **GitHub.com Fallback** ⚠️