Skip to content

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

Description

@megalithic

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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions