Skip to content

Invalid value of type 'builtins.dict' error when copying figure in 6.0.0rc0 #4925

Closed
@LiamConnors

Description

@LiamConnors

The example below throws an error in 6.0.0rc0 but not in 5.24.1

    raise ValueError(
ValueError: 
    Invalid value of type 'builtins.dict' received for the 'x' property of scatter
        Received value: {'dtype': 'i2', 'bdata': 'oAelB6oHrwe0B7kHvgfDB8gHzQfSB9cH'}

    The 'x' property is an array that may be specified as a tuple,
    list, numpy array, or pandas Series
from dash import Dash, dcc, html
import plotly.express as px

import copy

app = Dash(__name__)

gapminder = px.data.gapminder().query("(country=='Canada') | (country=='United States') | (country=='Mexico')")

fig = px.line(gapminder, x="year", y="gdpPercap", color='country')
fig.update_yaxes(title_text='Year')
fig.update_xaxes(title_text='Adoption Rate')

# Default dimensions
fig.update_layout(
    margin=dict(l=60, r=0, t=0, b=60),
)

fig_custom_height = copy.deepcopy(fig)
fig_custom_height.update_layout(height=800)

fig_custom_short_height = copy.deepcopy(fig)
fig_custom_short_height.update_layout(height=200)

app.layout = [
                dcc.Graph(
                figure = fig_custom_height,
                ),
                dcc.Graph(
                figure = fig_custom_short_height,
            ),

]

if __name__ == '__main__':
    app.run_server(debug=True)

pip list output:

Package              Version
-------------------- -----------
blinker              1.9.0
certifi              2024.8.30
charset-normalizer   3.4.0
click                8.1.7
dash                 2.18.2
dash-core-components 2.0.0
dash-html-components 2.0.0
dash-table           5.0.0
Flask                3.0.3
idna                 3.10
importlib_metadata   8.5.0
itsdangerous         2.2.0
Jinja2               3.1.4
MarkupSafe           3.0.2
narwhals             1.15.2
nest-asyncio         1.6.0
numpy                2.1.3
packaging            24.2
pandas               2.2.3
pip                  23.2.1
plotly               6.0.0rc0
python-dateutil      2.9.0.post0
pytz                 2024.2
requests             2.32.3
retrying             1.3.4
setuptools           65.5.0
six                  1.16.0
tenacity             9.0.0
typing_extensions    4.12.2
tzdata               2024.2
urllib3              2.2.3
Werkzeug             3.0.6
zipp                 3.21.0

Metadata

Metadata

Assignees

Labels

P1needed for current cyclebugsomething broken

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions