How to use the vega.Warn 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 / vega-lite / test-gallery / main.ts View on Github external
loadJSON('examples/specs/' + example + '.vl.json', function(vlSpec: TopLevelSpec) {
      const vgSpec = vl.compile(vlSpec).spec;
      const runtime = vega.parse(vgSpec); // may throw an Error if parsing fails
      new vega.View(runtime)
        .logLevel(vega.Warn)
        .initialize(document.querySelector('.viz#'+ example + '> div.view'))
        .renderer('canvas')
        .run();

      d3.select('.viz#'+ example + '> .desc').text(vlSpec.description || '');
    });
  });
github vega / vega / packages / vega-cli / src / render.js View on Github external
const vega = require('vega'),
      path = require('path'),
      args = require('./args'),
      read = require('./read');

function load(file) {
  return require(path.resolve(file));
}

const Levels = {
  error: vega.Error,
  warn:  vega.Warn,
  info:  vega.Info,
  debug: vega.Debug
};

module.exports = function(type, callback, opt) {
  // parse command line arguments
  const arg = args(type);

  // set baseURL, if specified. default to input spec directory
  const base = arg.base || (arg._[0] ? path.dirname(arg._[0]) : null);

  // set log level, defaults to logging warning messages
  const loglevel = Levels[String(arg.loglevel).toLowerCase()] || vega.Warn;

  // load config file, if specified
  const config = arg.config ? load(arg.config) : null;
github vega / vega / packages / vega-cli / src / render.js View on Github external
module.exports = function(type, callback, opt) {
  // parse command line arguments
  const arg = args(type);

  // set baseURL, if specified. default to input spec directory
  const base = arg.base || (arg._[0] ? path.dirname(arg._[0]) : null);

  // set log level, defaults to logging warning messages
  const loglevel = Levels[String(arg.loglevel).toLowerCase()] || vega.Warn;

  // load config file, if specified
  const config = arg.config ? load(arg.config) : null;

  // set output image scale factor
  const scale = arg.scale || undefined;

  // use a seeded random number generator, if specified
  if (typeof arg.seed !== 'undefined') {
    if (Number.isNaN(arg.seed)) throw 'Illegal seed value: must be a valid number.';
    vega.setRandom(vega.randomLCG(arg.seed));
  }

  // load custom number format locale, if specified
  if (arg.format) vega.formatLocale(load(arg.format));
github vega / lyra / src / js / ctrl / index.ts View on Github external
return parsePromise.then(function(runtime) {
    ctrl.view = new vg.View(runtime)
      .initialize(el)
      .logLevel(vg.Warn)
      .hover();

    // Register all event listeners to the new view
    listeners.register();
    // the update() method initiates visual encoding and rendering:
    // View has to update once before scene is ready
    ctrl.update();
    // Re-parse complete: null out the completed promise
    parsePromise = null;
  });
};
github vega / voyager / src / components / vega-lite / index.tsx View on Github external
//       {"a": "I", "b": 52}
    //     ]
    //   },
    //   "mark": "bar",
    //   "encoding": {
    //     "x": {"field": "a", "type": "quantitative"},
    //     "y": {"field": "b", "type": "quantitative"}
    //   }
    // };
    const {logger} = this.props;
    const vlSpec = this.props.spec;
    try {
      const spec = vl.compile(vlSpec, logger).spec;
      const runtime = vega.parse(spec, vlSpec.config);
      this.view = new vega.View(runtime)
        .logLevel(vega.Warn)
        .initialize(this.refs[CHART_REF] as any)
        .renderer(this.props.renderer || 'canvas')
        .hover();
      vegaTooltip.vega(this.view);
      this.bindData();
    } catch (err) {
      logger.error(err);
    }
  }
github cdapio / cdap / cdap-ui / app / cdap / components / VegaLiteChart / index.js View on Github external
height: dimension.height - (this.props.heightOffset || 0),
        data: {
          name: this.state.id,
        },
      };
      if (this.props.width) {
        if (typeof this.props.width === 'function') {
          vlSpec.width = this.props.width(dimension, this.state.data);
        } else {
          vlSpec.width = this.props.width;
        }
      }
      const spec = vl.compile(vlSpec).spec;
      const runtime = vega.parse(spec);
      this.view = new vega.View(runtime)
        .logLevel(vega.Warn)
        .initialize(el)
        .renderer('svg')
        .hover();
      if (this.props.tooltipOptions && Object.keys(this.props.tooltipOptions).length) {
        vegaTooltip.vega(this.view, this.props.tooltipOptions);
      } else {
        vegaTooltip.vega(this.view);
      }
      this.bindData();
    } catch (err) {
      console.log('ERROR: Failed to compile vega spec ', 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);
    }

    window.VEGA_DEBUG.view = view;
github datadotworld / chart-builder / src / components / VegaLiteImage.js View on Github external
async constructView() {
    let { spec, data } = this.props
    const loader = vega.loader()
    const logLevel = vega.Warn
    const renderer = 'svg'

    spec = vl.compile(spec).spec

    const runtime = vega.parse(spec)
    const view = new vega.View(runtime, {
      loader,
      logLevel,
      renderer
    }).initialize()

    view.change('source', vega.changeset().insert(data))

    const svgString: string = await view.toSVG()

    const blob = new Blob([svgString], { type: 'image/svg+xml' })
github datadotworld / chart-builder / src / components / VegaLiteEmbed.js View on Github external
async constructView() {
    const { spec, data, onViewRender } = this.props
    const loader = vega.loader()
    const logLevel = vega.Warn
    const renderer = 'svg'

    try {
      const vgSpec = vl.compile(spec).spec

      const runtime = vega.parse(vgSpec)

      const view = new vega.View(runtime, {
        loader,
        logLevel,
        renderer
      })
        .initialize(this.nodeRef.current)
        .change('source', vega.changeset().insert(data))

      try {