Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for plotly.graph_objs #17

Open
bcliang opened this issue Apr 4, 2019 · 0 comments
Open

Support for plotly.graph_objs #17

bcliang opened this issue Apr 4, 2019 · 0 comments

Comments

@bcliang
Copy link
Owner

bcliang commented Apr 4, 2019

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant