✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

Generating plotlyjs charts in python

I know that Dash allows to write code to generate a chart that is then viewable in a browser (with zoom/pan controls etc…), but I don’t think I can use Dash as it does not seem to allow me to do certain things (namely, dynamic / variable number of components).

Is there an easy way to do either of the below?

  1. using the same python code to generates a plotly.py image server-side, as well as to generate the html/javascript to view it on a webpage, with all the controls? I tried just fig.to_html() which works fine in a standalone way, but the html/js generated is tricky to integrate on a web page (it seems to be meant more for standalone pages).
  2. do matplotlib operations like df.plot(), etc… and get a javascript representation of it? Tried mpld3, it worked in some cases, not in others, seemed buggy

I don’t need fancy charts, all I want is a python fn that generates the json data you would normally feed to Plotly.newPlot('myDiv', data);

I think I found it, it was as simple as doing fig.to_json()

Hope I didn’t waste anyone’s time :roll_eyes: