We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Just wanted to share my example usage. Notice the limitation in using the 3D Plot:
import dash import dash_core_components as dcc import dash_html_components as html import plotly.graph_objs as go from dash.dependencies import Output, Input, State from dash.exceptions import PreventUpdate import mydcc import time from datetime import datetime app = dash.Dash() app.config['suppress_callback_exceptions']=True #################################################################### layout1 = go.Layout(title='Mouse Movement', width=1250, height=750) layout2 = go.Layout(title='Mouse Movement 3D', width=1250, height=750, xaxis=dict(range=[-5, 5]), yaxis=dict(range=[-5, 5])) app.layout = html.Div([ dcc.Store(id='position-history', storage_type='session'), mydcc.Listener(id="position", aim='graph'), dcc.Graph(id='graph', figure={'layout': layout2}), dcc.Graph(id='3d-movement', figure={'layout': layout2}), dcc.Graph(id='movement', figure={'layout': layout1}), html.Div(id='print') ]) @app.callback(Output('position-history', 'data'), [Input('position', 'data')], [State('position-history', 'data')]) def track_movement(current_position, position_history): if current_position is None: raise PreventUpdate print(current_position) if position_history is None: position_history = {'t': [], 'x': [], 'y': []} else: history_t = position_history['t'] or [] history_x = position_history['x'] or [] history_y = position_history['y'] or [] history_t.append(datetime.now()) history_x.append(current_position['x']) history_y.append(current_position['y']) position_history = {'t': history_t, 'x': history_x, 'y': history_y} return position_history @app.callback( Output('movement', 'figure'), [Input('position-history', 'modified_timestamp')], [State('position-history', 'data')]) def on_data(timestamp, position_history): if timestamp is None: raise PreventUpdate if position_history is not None: trace_x = go.Scatter(x=position_history['t'], y=position_history['x']) trace_y = go.Scatter(x=position_history['t'], y=position_history['y']) data = [trace_x, trace_y] print("t: {}, x: {}, y: {}".format(position_history['t'][-1], position_history['x'][-1], position_history['y'][-1])) else: data = [] figure = go.Figure(data=data) return figure @app.callback( Output('3d-movement', 'figure'), [Input('position-history', 'modified_timestamp')], [State('position-history', 'data')]) def on_data(timestamp, position_history): if timestamp is None: raise PreventUpdate if position_history is not None: trace = go.Scatter3d(x=position_history['x'], y=position_history['y'], z=position_history['t']) data = [trace] else: data = [] figure = go.Figure(data=data) return figure if __name__ == '__main__': app.run_server()
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Just wanted to share my example usage. Notice the limitation in using the 3D Plot:
The text was updated successfully, but these errors were encountered: