✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

I can't use Scattergl in Dash App

Hello everyone,

I have a problem with Scattergl used inside a Dash app. The error message in the browser is as follows:

The normal Scatter plot works fine. Interesting is, that Scattergl works fine, when writing it to a html file and viewing it in the browser.

The following code reproduces the issue (usegl = True):

import plotly.graph_objects as go
import dash
import dash_core_components as dcc
import dash_html_components as html

usegl = True

if usegl:
    fig = go.Figure(
        data=go.Scattergl(
            x=[1, 2, 3],
            y=[0, 1, 0],
        )
    )
else:
    fig = go.Figure(
        data=go.Scatter(
            x=[1, 2, 3],
            y=[0, 1, 0],
        )
    )

# this works fine with both, Scatter AND Scattergl:
fig.write_html('result.html')

# this doesn't work with Scattergl -> error message in the browser: "cannot read property 'length' of null"
app = dash.Dash()
app.layout = html.Div(
    children=dcc.Graph(
        figure=fig
    )
)
app.run_server(debug=True)

These are the versions I’m working on:
dash 1.11.0
dash-core-components 1.9.1
dash-html-components 1.0.3
dash-renderer 1.4.0
dash-table 4.6.2
plotly 4.6.0

Any thoughts about that? Has anyone seen this before? The thing is, that I would love to use Dash, but without Scattergl I have no fun displaying my large data set.

Thank you very much in advance!

Hi @flo1 welcome to the forum! Thanks for writing a standalone app, it makes it really easier to diagnose. I cannot reproduce the problem, maybe you have incompatible versions of dash and dash-core-components (this is a known source of rendering problems). Could you try uninstalling dash, dash-core-components, dash-html-components, dash-renderer and dash-table, then reinstall dash only (which will install as well compatible versions of all other packages)?

Hi @Emmanuelle ,

many thanks for your quick response! I tried it without success. Anyways, I’ve solved the issue and can’t believe what it was:

The fact that you couldn’t reproduce the error, brought me to the idea, that it could be platform- or browser dependent. I’m working on a Ubuntu machine and the brave browser, which is basically chrome. The issue was, that brave blocked “1 item” from the site. When I disabled the brave shield for this site, it worked!

Interesting is, that brave doesn’t block the Scattergl plot when I write it to a standalone html file (see code above) and secondly, that brave doesn’t block anything when using the normal Scatter plot, even when embedded in the Dash app?!

Maybe this could help someone out there in the future.

Again, thanks for answering, have a nice weekend!

1 Like