apache-superset/superset-ui-plugins

How do I specify what element/div-id the chart should use?

andreaslordos opened this issue · 2 comments

Most plugins export a function which takes in two parameters - props and element. I'm writing my own plugin currently, and it's successfully passing the props parameter, but it's failing to pass an element parameter, instead passing { }.

Where do I specify the DOM element the chart should be contained inside?

To give you an example of what I mean, here is the beginning of the ForceDirected plugin:

function ForceDirected(element, props) {
  const { data, width, height, linkLength = 200, charge = -500 } = props;
  const div = d3.select(element);
  div.classed('superset-legacy-chart-force-directed', true);

At what point/where in the codebase is the element parameter passed?

Issue-Label Bot is automatically applying the label #question to this issue, with a confidence of 0.86. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

Figured it out. Essentially, at no point do you explicitly specify the element parameter. However, you need to make sure you follow the format of other plugins and have a React[plugin].js file in the directory of your plugin folder, and make sure index.js points to it as well.