[fastpages] Plotly plot doesn't load, JS error in browser

Good point about the notebook compatibility on colab, it won’t work with notebook_connected (I guess that’s why they have a colab specific renderer!). Maybe a slightly simpler code would leverage the detection already made by plotly. pio.renderers.default will be ‘colab’ when run there. So the test could be:

import plotly.io as pio
if pio.renderers.default != 'colab':
    pio.renderers.default = 'notebook_connected'
    # js, etc.
1 Like
from IPython.display import HTML
...
...
...
HTML(fig.to_html(include_plotlyjs='cdn'))

I hope this can help you.

1 Like