plotly.py icon indicating copy to clipboard operation
plotly.py copied to clipboard

To HTML exported jupyter notebooks are not working anymore

Open JoergVanAken opened this issue 3 years ago • 2 comments

Hi!

For a couple of month I was able to export jupyter notebooks which include ipywidgets and plotly figures to html. Everything was working as expected. But yesterday I opened one of these HTML files and the widgets don’t show figures. In the javascript console there is an error “jupyterlab-plotly.js not found”, but I am not sure if this is the origin of the problem. Generating new html files does not work either. Same result on different computers. Any ideas what has happened?

Sample code:

import pandas as pd
import plotly.graph_objects as go
import ipywidgets as widgets
from IPython.display import Markdown

s = pd.Series(index=[1, 2, 3, 4, 5],  data=[0, 1, 2, 4, 9])

Markdown('# Figure')

fig = go.Figure()
trace = go.Scatter(x=s.index, y=s.values, mode='lines')
fig.add_trace(trace)
fig.show()

Markdown('# FigureWidget')

_fig = go.FigureWidget(fig)
_fig.show()

Markdown('# widgets.HBox')

widgets.HBox([go.FigureWidget(fig)])

Markdown('# widgets.Tab')

widgets.Tab([go.FigureWidget(fig)])

Markdown('# The end')

Conversion to HTML:

jupyter nbconvert --no-input --execute plotly_check.ipynb --to html

The first two figures appear, the others don’t. I have used a fresh conda environment with python 3.9 and plotly 5.10

JoergVanAken avatar Sep 09 '22 10:09 JoergVanAken

The reason for this issue is not plotly, the widgets problem is there with text only widgets, too

JoergVanAken avatar Sep 13 '22 13:09 JoergVanAken

@JoergVanAken Just in case it can help you (because I just lost 1 hour to understand if I was doing something wrong when saving my graphs to html), my graph were not showing because I was trying to open them in a folder ~/Documents/Test_Python/Test_Plotly. If I change a single thing, it works, don't ask me why (like from ~/Documents/Test_Plotly or ~/Documents/Test_Python/Test_Plotl)

paLeziart avatar Sep 19 '22 14:09 paLeziart

Hi - we are trying to tidy up the stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for several years, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. Thanks for your help - @gvwilson

gvwilson avatar Jul 04 '24 13:07 gvwilson