Custom SVG Legend - How to Include in the Download to Image?

I’ve added a custom Legend to a plotly.js chart. I add it after calling Plotly.plot by grabbing a reference to the svg DOM nodes within the plot container and appending a child to the plotly svg under the “svg-container”, in the 2nd “main-svg” within the “infolayer” group (those are the class names in quotes), which is where the the normal legend would go.

Everything seems to work well so far, except that this custom legend is not included in the downloaded image file when I use the built in “Download plot as a png” menu item from the menu bar.

Is there a way I can have my custom legend svg content included up by the function that generates this image file?

We don’t expose an official way to export things to have been “hacked” into a plotly.js graph div.

In brief, we only intend to export the parts plotly.js generates from user data and layout.

You could try to look at our snapshotting code:

for ideas on how to snapshot an <svg>.