コード例 #1
0
def generate_liveOut_layout():
    'Generate the layout per-app, generating each tine a new uuid for the state_uid argument'
    return html.Div([
        dpd.Pipe(id="named_count_pipe",
                 value=None,
                 label="named_counts",
                 channel_name="live_button_counter"),
        html.Div(id="internal_state",
                 children="No state has been computed yet",
                 style={'display':'none'}),
        dcc.Graph(id="timeseries_plot"),
        dcc.Input(value=str(uuid.uuid4()),
                  id="state_uid",
                  style={'display':'none'},
                 )
        ])
コード例 #2
0
ファイル: app.py プロジェクト: Simplorios/django-test
import dash
import dash_html_components as html

import dpd_components as dpd

from django_plotly_dash import DjangoDash

app = DjangoDash('Example')  # replaces dash.Dash

app.layout = html.Div([
    html.H1('Some text', id='text'),
    dpd.Pipe(id='live-update', label="live_label", channel_name="live_channel")
])


@app.callback(dash.dependencies.Output('text', 'children'),
              [dash.dependencies.Input('live-update', 'value')])
def live_update(value):
    return str(value)
コード例 #3
0
import dpd_components
import dash
import dash_html_components as html

app = dash.Dash('')

app.scripts.config.serve_locally = True

app.layout = html.Div([
    dpd_components.Pipe(id='input',
                        value='my-value-fredd',
                        source='my-lvvvvvvvvabel'),
    html.Div(id='output')
])


@app.callback(dash.dependencies.Output('output', 'children'), [
    dash.dependencies.Input('input', 'value'),
    dash.dependencies.Input('input', 'source')
])
def display_output(value, source):
    return 'Value is %s and Source is %s' % (value, source)


if __name__ == '__main__':
    app.run_server(debug=True)
コード例 #4
0
import random
import plotly.graph_objs as go
from collections import deque
import dpd_components as dpd
from django_plotly_dash import DjangoDash
from django_plotly_dash.consumers import send_to_pipe_channel

X = deque(maxlen=20)
Y = deque(maxlen=20)
X.append(1)
Y.append(1)

app = DjangoDash('liveArduino')
app.layout = html.Div([
    dpd.Pipe(id="arduino_sensor_pipe",
             value={'valor': 0},
             label="arduino_sensor",
             channel_name="live_arduino_sensor"),
    html.Div(id="internal_state",
             children="No state has been computed yet",
             style={'display': 'none'}),
    dcc.Graph(id="timeseries_plot"),
])


@app.callback(dash.dependencies.Output('internal_state', 'children'), [
    dash.dependencies.Input('arduino_sensor_pipe', 'value'),
])  #dash.dependencies.Input('state_uid', 'value'),])
def callback_arduino_sensor_pipe(arduino_sensor, **kwargs):
    ## Guard against missing input on startup
    if not arduino_sensor:
        arduino_sensor = {}