plotly / plotly.py

The interactive graphing library for Python :sparkles: This project now includes Plotly Express!
https://plotly.com/python/
MIT License
15.62k stars 2.51k forks source link

Sunburst graph open in Firefox but not Chrome (at least in Windows) #4646

Open rodrigodesalvobraz opened 4 days ago

rodrigodesalvobraz commented 4 days ago

I am using the Sunburst graph which shows in the browser with a localhost web server.

When (up-to-date) Chrome is used as the default browser, sometimes the graph loads fine, sometimes it keeps “loading” and doesn’t load, sometimes it finishes “loading” but the page is blank.

It does work every time when I make Firefox the default browser.

But back in Chrome, the behavior seems random and does not depend on the data. If I try the same dataset repeatedly, it sometimes loads, sometimes doesn’t.

I’ve seen others report similar problems but in those threads it seems the problem was the underlying data. This is not so for me since sometimes the data loads fine, but a lot of the times it doesn’t.

Opening Chrome’s developer tools does not show anything that looks like an error.

There is a discussion (and repro confirmation by others) at Plotly community forum.

The code below runs successfully every time when the default browser is Firefox, but only about half the executions when the default browser is Chrome. I am on plotly 5.21.0, Python 3.11.9, Windows 10.

import plotly.graph_objects as go

labels = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '80', '81', '82', '83', '84', '85', '86', '87', '88', '89', '90', '91', '92', '93', '94', '95', '96', '97', '98', '99', '100', '101', '102', '103', '104', '105', '106', '107', '108']
parents = ['', '1', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '1', '16', '16', '16', '16', '1', '21', '22', '22', '22', '22', '22', '22', '22', '22', '22', '21', '32', '32', '32', '21', '36', '36', '36', '36', '36', '36', '36', '36', '36', '36', '21', '47', '21', '49', '49', '21', '52', '21', '54', '54', '21', '57', '21', '59', '21', '61', '21', '21', '64', '21', '66', '1', '68', '68', '1', '71', '71', '71', '1', '75', '75', '1', '', '79', '80', '80', '80', '80', '80', '79', '86', '87', '86', '89', '89', '89', '89', '89', '86', '86', '86', '86', '86', '79', '100', '100', '79', '103', '103', '103', '103', '79']
values = [5640.0, 2130.0, 225.0, 15.0, 60.0, 15.0, 235.0, 255.0, 20.0, 60.0, 30.0, 15.0, 1155.0, 30.0, 15.0, 240.0, 120.0, 60.0, 30.0, 30.0, 2925.0, 390.0, 90.0, 15.0, 30.0, 45.0, 60.0, 75.0, 30.0, 15.0, 15.0, 315.0, 30.0, 15.0, 60.0, 1035.0, 15.0, 45.0, 45.0, 60.0, 90.0, 45.0, 45.0, 60.0, 600.0, 30.0, 240.0, 30.0, 300.0, 240.0, 60.0, 45.0, 45.0, 60.0, 30.0, 30.0, 15.0, 15.0, 75.0, 75.0, 195.0, 195.0, 30.0, 15.0, 15.0, 210.0, 210.0, 135.0, 105.0, 30.0, 90.0, 60.0, 15.0, 15.0, 105.0, 75.0, 30.0, 15.0, 1645.0, 345.0, 165.0, 135.0, 15.0, 15.0, 15.0, 1045.0, 175.0, 85.0, 615.0, 90.0, 30.0, 285.0, 15.0, 195.0, 30.0, 90.0, 90.0, 30.0, 15.0, 45.0, 30.0, 15.0, 165.0, 15.0, 30.0, 30.0, 90.0, 45.0]

fig = go.Figure(go.Sunburst(
    labels=labels,
    parents=parents,
    values=values,
    branchvalues="total",
    textinfo='label+percent parent',
))

fig.update_layout(
    margin=dict(t=0, l=0, r=0, b=0),
    sunburstcolorway=["#636efa", "#ef553b", "#00cc96"]
)

fig.show()