How to use the vega.logger 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 nyurik / kibana-vega-vis / public / vega_view / parse_input_spec.js View on Github external
const controlsDir = controlsDirection === 'horizontal' ? 'row' : 'column';

  // Default autosize should be fit, unless it's a map (leaflet-vega handles that)
  if (spec.autosize === undefined && !useMap) {
    spec.autosize = { type: 'fit', contains: 'padding' };
  }

  // injectConfigValues(spec, isVegaLite);

  const vlspec = isVegaLite ? spec : undefined;

  if (isVegaLite) {
    if (useMap) {
      throw new Error('"_map" configuration is not compatible with vega-lite spec');
    }
    const logger = vega.logger(vega.Warn);
    logger.warn = onWarning;
    spec = vegaLite.compile(vlspec, logger).spec;
  }

  const useResize = !useMap && (spec.autosize === 'fit' || spec.autosize.type === 'fit');
  const useHover = !isVegaLite;

  // Padding is not included in the width/height by default
  let paddingWidth = 0;
  let paddingHeight = 0;
  if (useResize && spec.padding && spec.autosize.contains !== 'padding') {
    if (typeof spec.padding === 'object') {
      paddingWidth += (+spec.padding.left || 0) + (+spec.padding.right || 0);
      paddingHeight += (+spec.padding.top || 0) + (+spec.padding.bottom || 0);
    } else {
      paddingWidth += 2 * (+spec.padding || 0);
github vega / vega / packages / vega-cli / src / render.js View on Github external
function render(spec) {
    const view = new vega.View(vega.parse(spec, config), {
        loader: vega.loader({baseURL: base}),   // load files from base path
        logger: vega.logger(loglevel, 'error'), // route all logging to stderr
        renderer: 'none'                        // no primary renderer needed
      }).finalize();                            // clear any timers, etc

    return (type === 'svg'
        ? view.toSVG(scale)
        : view.toCanvas(scale, opt)
      ).then(_ => callback(_, arg));
  }