Plotly object not displayed by ipywidgets Button
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 18.8k
- Fork
- 2.8k
- Merge trung bình
- 16 giờ 26 phút
- Pull request đã merge (30 ngày)
- 21
Mô tả
Description
I am not sure if this is a bug or just something that is not yet supported. When trying to display plotly plots (plotly object) by clicking the Button widget, I run into some issues. Regarding the Databricks issue, I have also contacted them as I am not sure that error is on the plotly side. The Button displays other objects (such as their IntSlider) correctly.
Local
Plotly object is simply not displayed (no error is thrown). Same happens if the fig is defined outside the on_click function and only fig.show() is called:

Databricks
Uncaught ReferenceError: Plotly is not defined is thrown. Same happens even if plotly is defined at any place (e.g. inside the on_click function).

Reproduce
Minimal working example code:
import ipywidgets as widgets
import plotly.graph_objects as go
output_button = widgets.Output()
button = widgets.Button(
description='Fail to show plotly object',
disabled=False,
button_style='success',
icon='',
layout=widgets.Layout(width='480px', height='60px'),
style={'description_width':'initial'})
def fun_output(b):
with output_button:
print("Normal output works!")
fig = go.Figure()
fig.add_scatter(
x = [1, 2, 3, 4],
y = [3, 4, 5, 6],
opacity=0.8)
fig.show()
print("Plotly object not displayed!")
button.on_click(fun_output)
display(button, output_button)
Expected behavior
Expected the Plotly plot to be shown.
Context
- ipywidgets version 8.0.6
- Operating System and version: Win10
- Browser and version: /
Troubleshoot Output
sys.version:
3.10.0 | packaged by conda-forge | (default, Nov 10 2021, 13:20:59) [MSC v.1916 64 bit (AMD64)]
platform.platform():
Windows-10-10.0.19044-SP0
where jupyter:
C:\Users<user_name>.conda\envs\sandbox\Scripts\jupyter.exe
pip list:
Package Version
----------------------------- ---------
asttokens 2.2.1
attrs 23.1.0
backcall 0.2.0
backports.functools-lru-cache 1.6.4
certifi 2022.12.7
colorama 0.4.6
contourpy 1.0.7
cycler 0.11.0
debugpy 1.5.1
decorator 5.1.1
et-xmlfile 1.1.0
executing 1.2.0
fastjsonschema 2.16.3
fonttools 4.38.0
importlib-metadata 6.0.0
ipykernel 6.15.0
ipython 8.10.0
ipywidgets 8.0.6
jedi 0.18.2
jsonschema 4.17.3
jupyter_client 8.0.3
jupyter_core 5.2.0
jupyterlab-widgets 3.0.7
kiwisolver 1.4.4
llvmlite 0.39.1
matplotlib 3.6.3
matplotlib-inline 0.1.6
nbformat 5.8.0
nest-asyncio 1.5.6
numba 0.56.4
numpy 1.24.1
openpyxl 3.1.1
packaging 23.0
pandas 1.5.3
parso 0.8.3
pickleshare 0.7.5
Pillow 9.4.0
pip 22.3.1
platformdirs 3.0.0
plotly 5.14.1
prompt-toolkit 3.0.36
psutil 5.9.0
pure-eval 0.2.2
Pygments 2.14.0
pyparsing 3.0.9
pyrsistent 0.19.3
python-dateutil 2.8.2
pytz 2022.7.1
pywin32 305.1
pyzmq 23.2.0
setuptools 65.6.3
six 1.16.0
stack-data 0.6.2
tenacity 8.2.2
tornado 6.2
traitlets 5.9.0
typing_extensions 4.4.0
wcwidth 0.2.6
wheel 0.37.1
widgetsnbextension 4.0.7
wincertstore 0.2
zipp 3.14.0
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với ví dụ tối thiểu tại các điểm vào fun_output callback, output_button và button.on_click, tái hiện ví dụ đó bằng các phiên bản ipywidgets 8.0.6 và plotly 5.14.1 đã được báo cáo. So sánh hành vi cục bộ và hành vi trên Databricks, bao gồm cả lỗi trình duyệt đã được báo cáo; hoàn thành khi hình Plotly được kết xuất sau khi nhấp vào Button trong cả hai ngữ cảnh.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- jupyter-notebook, python
- Lĩnh vực
- frontend
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 35/100