Bring Drag & Drop to Dash with Dashboard Engine. 💫 Learn how at our next webinar!

Client side callbacks doc example for 3d scatter

I’m failing at a quite basic level it seems: I’m trying to get the simple example of client side callbacks (Clientside Callbacks | Dash for Python Documentation | Plotly) running for a 3D scatter plot whose data is stored in the browser (like promised in the doc).
I’m working with large data sets, hence 5000 data points.

import dash
from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html
import numpy as np

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

t = np.linspace(0, 100, 5000)
x, y, z = np.cos(t), np.sin(t), t

app.layout = html.Div([
    dcc.Graph(
        id='clientside-graph'
    ),
    dcc.RadioItems(
        id='clientside-graph-scale',
        options=[
            {'label': x, 'value': x} for x in ['linear', 'log']
        ],
        value='linear'
    ),
    dcc.Store(
        id='clientside-figure-store',
        data=[{'x': x, 'y': y, 'z': z, 'mode': 'markers'}]
    )
])
        
app.clientside_callback(
    """
    function(data, scale) {
        return {
            'data': data,
            'layout': {
                 'yaxis': {'type': scale}
             }
        }
    }
    """,
    Output('clientside-graph', 'figure'),
    [Input('clientside-figure-store', 'data'),
     Input('clientside-graph-scale', 'value')]
)


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