Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Great write-up; might be worth mentioning how to handle additional client-side things.. tooltips for instance.. #1

Open
megalithic opened this issue Apr 20, 2022 · 1 comment

Comments

@megalithic
Copy link

Having just gone through this with a project at work, here's some additional items that could be added for charting interactions with vega-embed:

this.viewPromise = vegaEmbed(container, spec, {
  renderer: "svg",
  actions: false,
  tooltip: {
    theme: "custom_theme",
    formatTooltip: (datum, sanitize) => `
      <span class="tooltip-inner another-class">
        <span class="primary">${sanitize(datum.date)}</span>
        <strong class="secondary">${sanitize(datum.count)}</strong>
      </span>`,
  },
})

You'd need the additional VegaLite code in your LiveView code to handle tooltip data things.

In addition, you might want to add a destroyed event to handle cleanup..

destroyed() {
  if (this.viewPromise) {
    this.viewPromise.then((view) => view.finalize());
  }
},

Hope that helps!

@filipecabaco
Copy link
Owner

Wanted to keep it as a really simple example but can add it later 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants