Skip to content

Commit 799eb10

Browse files
authored
Merge pull request #5102 from jescalada/ipywidgets-integration-fix
Fix widget initialization issue in v6
2 parents ae0fbed + 1bd4257 commit 799eb10

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## Unreleased
6+
7+
### Fixed
8+
- Fix third-party widget display issues in v6 [[#5102]https://github.com/plotly/plotly.py/pull/5102]
9+
510
## [6.0.1] - 2025-03-14
611

712
### Updated

plotly/basewidget.py

+5
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ def __init__(
142142
# views of this widget
143143
self._view_count = 0
144144

145+
# Initialize widget layout and data for third-party widget integration
146+
# --------------------------------------------------------------------
147+
self._widget_layout = deepcopy(self._layout_obj._props)
148+
self._widget_data = deepcopy(self._data)
149+
145150
def show(self, *args, **kwargs):
146151
return self
147152

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from unittest import TestCase
2+
import plotly.graph_objs as go
3+
import pytest
4+
5+
try:
6+
go.FigureWidget()
7+
figure_widget_available = True
8+
except ImportError:
9+
figure_widget_available = False
10+
11+
12+
class TestInitialization(TestCase):
13+
if figure_widget_available:
14+
15+
def test_widget_layout_present_on_init(self):
16+
fig = go.FigureWidget(data=go.Scatter(x=[1, 2], y=[1, 2]))
17+
assert fig._widget_layout != {}
18+
19+
def test_widget_data_present_on_init(self):
20+
fig = go.FigureWidget(data=go.Bar(x=[1, 2], y=[1, 2]))
21+
assert fig._widget_data != []

0 commit comments

Comments
 (0)