diff --git a/CHANGELOG.md b/CHANGELOG.md index 638fb47b176..89da1e55f17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## Unreleased + +### Fixed +- Fix third-party widget display issues in v6 [[#5102]https://github.com/plotly/plotly.py/pull/5102] + ## [6.0.1] - 2025-03-14 ### Updated diff --git a/plotly/basewidget.py b/plotly/basewidget.py index 8ad06c0f72f..812288b7136 100644 --- a/plotly/basewidget.py +++ b/plotly/basewidget.py @@ -142,6 +142,11 @@ def __init__( # views of this widget self._view_count = 0 + # Initialize widget layout and data for third-party widget integration + # -------------------------------------------------------------------- + self._widget_layout = deepcopy(self._layout_obj._props) + self._widget_data = deepcopy(self._data) + def show(self, *args, **kwargs): return self diff --git a/tests/test_core/test_figure_widget_backend/test_validate_initialization.py b/tests/test_core/test_figure_widget_backend/test_validate_initialization.py new file mode 100644 index 00000000000..5f68bd343d0 --- /dev/null +++ b/tests/test_core/test_figure_widget_backend/test_validate_initialization.py @@ -0,0 +1,21 @@ +from unittest import TestCase +import plotly.graph_objs as go +import pytest + +try: + go.FigureWidget() + figure_widget_available = True +except ImportError: + figure_widget_available = False + + +class TestInitialization(TestCase): + if figure_widget_available: + + def test_widget_layout_present_on_init(self): + fig = go.FigureWidget(data=go.Scatter(x=[1, 2], y=[1, 2])) + assert fig._widget_layout != {} + + def test_widget_data_present_on_init(self): + fig = go.FigureWidget(data=go.Bar(x=[1, 2], y=[1, 2])) + assert fig._widget_data != []