Using plotly.js for graphing data in discourse forums

Hi, I wrote a quick theme component for discourse that makes plotly available in a discourse instance in a similar way to mermaid.

I haven’t been quite game to make it live on my site yet though. A couple of (maybe trivial/silly) concerns I have that maybe someone has opinions about:

  • plotly-2.35.2.min.js is kind of large at 4.5MB (discourse complains and you have to tweak a setting); is there a reasonable way to split that up or make it smaller somehow?
  • I think yaml looks better than json when you include it in text, but it is kind-of a mismatch to the existing plotly.js documentation out there…
  • I’m letting people put in arbitrary data for the data and layout parameters of Plotly.newPlot; though I am overriding width/height if they’re set too large. Is that safe, both from a security perspective (could arbitrary data trick plotly into some XSS problems?) and a shoot-yourself-in-the-foot perspective (making your graph unusable or something?)
  • should I replace newPlot() with react() or something? maybe that would be better when the plot is being created in the editor, at least?

Anyway, if anyone who’s familiar with javascript/plotly wanted to have a look at the source and see if I’m doing something overly silly, that would be great :slight_smile: