Skip to content

Support for plotly.graph_objs #17

@bcliang

Description

@bcliang

Currently, this component expects data to be provided as a dict. However, many users instead generate traces using Plotly's build-in graph_objs. For example:

Currently, dash-extendable-graph supports:

...
@app.callback(Output('sensor-signal', 'extendData'),
              [Input('store-sensor-data', 'modified_timestamp')],
              [State('store-sensor-data', 'data')])
def extend_scatter_plot(data_updated, data):
    payload = [dict(x=data['x1'], y=data['y1']), 
               ... #additional traces
               dict(x=data['xn'], y=data['yn'])]
    return payload

But users may prefer not to rely on creating their own dictionaries for each trace that should be updated. For the above example, a user may prefer to generate a trace object via plotly.graph_objs.Scatter

@app.callback(Output('sensor-signal', 'extendData'),
              [Input('store-sensor-data', 'modified_timestamp')],
              [State('store-sensor-data', 'data')])
def extend_scatter_plot(data_updated, data):
    payload = [
        plotly.graph_objs.Scatter(
            x=data['x'],
            y=data['y'])
    ]
    return payload

In the simple example, it doesn't appear to make much difference. However, it could be significantly easier for users if they, for example, use many different trace types with different data-containing keys.

Considerations

  • How to handle non-data-containing keys? For example styling and legend information (e.g. line, marker, mode, visible, name)
  • How to handle non-data graph_objs? (e.g. Layout)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions