Extend (or append) data instead of update

Hello, brad! After a new update of Dash, I immediately went to check if extendData was added in, and, lo and behold, Dash 0.41.0 seems to have something about it.

However, I am having some issues with the syntax, which I hope you could help me out with. Using the example you posted at the bottom of your pull request, I modified it in the hopes of getting a basic graph to

  1. Plot one point first (thereby creating the trace) using n_intervals as the only Input, and
  2. use n_intervals to keep extending said trace.

Needless to say, I am getting errors, and no amount of tinkering seems to help me out. Would you give a quick glance at my code below?

import dash
from dash.dependencies import Input, Output, State
import dash_html_components as html
import dash_core_components as dcc
import random

app = dash.Dash(name)

app.scripts.config.serve_locally = True
app.css.config.serve_locally = True

app.layout = html.Div([
html.Div([

    dcc.Graph(
        id='graph-extendable',
        figure={'layout': {'title': 'Random title',
                           'barmode':'overlay'}
              }
    ),
]),

dcc.Interval(
    id='interval-graph-update',
    interval=1000,
    n_intervals=0),

])

@app.callback(Output(‘graph-extendable’, ‘extendData’),
[Input(‘interval-graph-update’, ‘n_intervals’)]
)
def create_then_extend_single_trace(n_intervals):

return [dict(x=[[n_intervals]]), [0]]

if name == ‘main’:
app.run_server(debug=True)

1 Like