How to use the vega.parse function in vega

To help you get started, we’ve selected a few vega examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vega / lyra / src / js / ctrl / index.ts View on Github external
setTimeout(function() {
      if (that.cancelled) {
        return;
      }
      // Recreate the vega spec
      resolve(vg.parse(ctrl.manipulators()));
    }, 10);
  });
github vega / vega-lite / build / site / static / index.js View on Github external
export function embedExample($target, spec, actions = true, tooltip = true) {
    const vgSpec = compile(spec).spec;
    const view = new vega.View(vega.parse(vgSpec), { loader: loader }).renderer('svg').initialize($target);
    if (tooltip) {
        const handler = new Handler().call;
        view.tooltip(handler);
    }
    view.run();
    if (actions) {
        select($target)
            .append('div')
            .attr('class', 'vega-actions')
            .append('a')
            .text('Open in Vega Editor')
            .attr('href', '#')
            // tslint:disable-next-line
            .on('click', function () {
            post(window, editorURL, {
                mode: 'vega-lite',
github vega / lyra / src / js / components / interactions / InteractionPreview.tsx View on Github external
public componentDidMount() {
    this.view = new View(parse(this.props.spec), {
      renderer:  'svg',  // renderer (canvas or svg)
      container: `#${this.props.groupName}-${this.props.id}`   // parent DOM container
    });
    this.view.width(100);
    this.view.height(100);
    this.view.runAsync();
  };
github vega / vega-desktop / viewer / components / VegaRenderer.jsx View on Github external
} catch (error) {
          vegaSpec = spec;
        }
      } else {
        vegaSpec = spec;
      }

      // Clear existing view
      if (this.view) {
        this.view.finalize();
      }

      this.container.innerHTML = '';

      try {
        const runtime = vg.parse(vegaSpec);

        // Tell loader to resolve data and image files
        // relative to the spec file
        const loader = vg.loader({
          baseURL: path.dirname(filePath),
          mode: 'file'
        });

        window.VEGA_DEBUG.view = null;

        this.view = new vg.View(runtime, {loader})
          .initialize(this.container)
          .renderer(renderer)
          .hover()
          .run();
github apple / turicreate / src / visualization / client / Turi Create Visualization / src / user_interface / src / elements / Plot / Chart / index.js View on Github external
}
        if (spec['$schema'].startsWith('https://vega.github.io/schema/vega-lite/')) {
            spec = vl.compile(spec).spec;
        }

        this.vega_json = spec;
        this.vega_json.autosize = {"type": "fit", "resize": true, "contains": "padding"};

        if(this.vega_json["metadata"] != null){
            if(this.vega_json["metadata"]["bubbleOpts"] != null){
                this.bubbleOpts = this.vega_json["metadata"]["bubbleOpts"];
            }
        }

        this.vegaLoading = true;
        this.vegaView = new vega.View(vega.parse(this.vega_json), {'renderer': 'svg'})
                                .initialize(this.vega_container)
                                .hover()
                                .run();
        this.vegaLoading = false;
        vegaTooltip.vega(this.vegaView, this.bubbleOpts);

        if(window.navigator.platform === 'MacIntel' && !window.tcvizBrowserMode){
            window.webkit.messageHandlers["scriptHandler"].postMessage({status: 'ready'});
        }
    }
github maierj / fastlane-action / .github / actions / statistics-chart-action / main.js View on Github external
}

        processedMonths.add(monthName);
        uniqueRepositories.add(actionRun.repository);
    }

    const vega = require('vega');
    const fs = require('fs');
    let uniqueRepositoriesSpec = require(__dirname + '/vega-specs/unique-repositories');
    let totalRunsSpec = require(__dirname + '/vega-specs/total-runs');

    uniqueRepositoriesSpec.data[0].values = uniqueRepositoriesValues;
    totalRunsSpec.data[0].values = totalRunsValues;

    const uniqueRepositoriesChartView = new vega.View(vega.parse(uniqueRepositoriesSpec), {renderer: 'none'});
    const totalRunsChartView = new vega.View(vega.parse(totalRunsSpec), {renderer: 'none'});

    fs.mkdirSync("chart-output");

    uniqueRepositoriesChartView.toCanvas()
        .then(function(canvas) {
            canvas.createPNGStream().pipe(fs.createWriteStream('chart-output/unique-repositories.png'));
        })
        .catch(function(err) {
            setFailed(err);
        });

    totalRunsChartView.toCanvas()
        .then(function(canvas) {
            canvas.createPNGStream().pipe(fs.createWriteStream('chart-output/total-runs.png'));
        })
        .catch(function(err) {
github vega / vega-editor / src / components / renderer / renderer.js View on Github external
renderVega(props) {
    this.refs.chart.style.width = this.refs.chart.getBoundingClientRect().width + 'px';

    let runtime;
    let view;

    runtime = vega.parse(props.vegaSpec);
    view = new vega.View(runtime)
      .logLevel(vega.Warn)
      .initialize(this.refs.chart)
      .renderer(props.renderer)

    if (props.mode === MODES.Vega) {
      view.hover()
    }

    view.run();

    this.refs.chart.style.width = 'auto';

    if (this.props.tooltip) {
      vegaTooltip.vega(view);
    }