How to use the vega-tooltip.Handler function in vega-tooltip

To help you get started, we’ve selected a few vega-tooltip 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 / 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',
                spec: compactStringify(spec),
                config: vgSpec.config,
github vega / vega-embed / src / embed.ts View on Github external
// This call may throw an Error if parsing fails.
  const runtime = vega.parse(vgSpec, mode === 'vega-lite' ? {} : config);

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

  if (opts.tooltip !== false) {
    let handler: TooltipHandler;
    if (isTooltipHandler(opts.tooltip)) {
      handler = opts.tooltip;
    } else {
      // user provided boolean true or tooltip options
      handler = new Handler(opts.tooltip === true ? {} : opts.tooltip).call;
    }

    view.tooltip(handler);
  }

  let { hover } = opts;

  if (hover === undefined) {
    hover = mode === 'vega';
  }

  if (hover) {
    const { hoverSet, updateSet } = (typeof hover === 'boolean' ? {} : hover) as Hover;

    view.hover(hoverSet, updateSet);
  }
github Kitware / candela / packages / vega / src / mixin / VegaView.js View on Github external
_resizeContent (spec, size) {
    if (spec.spec) {
      spec.spec.width = size.width;
      spec.spec.height = size.height;
    } else {
      spec.width = size.width;
      spec.height = size.height;
    }
    let vegaSpec = spec;
    if (spec.$schema && schemaParser(spec.$schema).library === 'vega-lite') {
      vegaSpec = vegaLiteCompile(spec).spec;
    }
    let handler = new Handler();
    this.view = new View(parse(vegaSpec))
      .renderer(this.options.renderer || 'canvas')
      .tooltip(handler.call)
      .initialize(this.content)
      .hover()
      .run();

    return {
      width: window.parseInt(this.content.firstChild.getAttribute('width')),
      height: window.parseInt(this.content.firstChild.getAttribute('height'))
    };
  }
github vega / vega-lite / site / static / index.ts View on Github external
export function embedExample($target: any, spec: TopLevelSpec, actions = true, tooltip = true) {
  const {spec: vgSpec} = compile(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', '#')
      .on('click', function() {
        post(window, editorURL, {
          mode: 'vega-lite',
          spec: compactStringify(spec),

vega-tooltip

A tooltip plugin for Vega-Lite and Vega visualizations.

BSD-3-Clause
Latest version published 10 months ago

Package Health Score

79 / 100
Full package analysis