Ejemplo n.º 1
0
def get_body():
    """ """
    return html.Div(
        [
            html.Div(
                [
                    html.Div([], id=CALENDAR_ID),
                    dcc.Interval(
                        id=CALENDAR_INTERVAL_ID,
                        interval=CALENDAR_INTERVAL_MS,
                        n_intervals=0,
                    ),
                ],
                className="col p-2",
            ),
            html.Div([html.Div([], id=GPU_GRAPHS_ID)], className="col"),
            html.Div(
                [
                    html.Div([], id=GPU_TABLES_ID),
                ],
                className="col p-2",
            ),
            dcc.Interval(id=GPU_INTERVAL_ID, interval=GPU_INTERVAL_MS, n_intervals=0),
        ],
        className="row p-3",
    )
Ejemplo n.º 2
0
    def make_header(self):

        header = html.Div([
            html.H1("Overview of Successful Response Rate Last 24 hours"),
            dcc.Interval(id="main-content-table-interval",
                         interval=30 * 1000,
                         n_intervals=0)
        ], id="main-content-header")

        return header
Ejemplo n.º 3
0
    def make_header(self):

        header = html.Div([
            html.H1("SOA Serial Monitor Last 24 hours"),
            dcc.Interval(id="main-content-table-interval",
                         interval=30 * 1000,
                         n_intervals=0)
        ],
                          id="main-content-header")

        return header
Ejemplo n.º 4
0
    def make_header(self):

        header = html.Div([
            html.H2("Authoritative DNS Server Response Time"),
            dcc.Interval(id="main-content-graph-interval",
                         interval=60 * 1000,
                         n_intervals=0)
        ], id="main-content-header",
           style=dict(color=self.text_color))

        return header
Ejemplo n.º 5
0
    def make_header(self):

        header = html.Div([
            html.H1("Authoritative DNS Server Service Level Monitor"),
            dcc.Interval(id="main-content-graph-interval",
                         interval=150 * 1000,
                         n_intervals=0)
        ],
                          id="main-content-header")

        return header
Ejemplo n.º 6
0
def test_intv002_restart(dash_dcc):
    app = Dash(__name__)
    app.layout = html.Div([
        dcc.Interval(
            id="interval",
            interval=100,
            n_intervals=0,
            max_intervals=-1,
        ),
        html.Button("Start", id="start", n_clicks_timestamp=-1),
        html.Button("Stop", id="stop", n_clicks_timestamp=-1),
        html.Div(id="output"),
    ])

    @app.callback(
        Output("interval", "max_intervals"),
        [
            Input("start", "n_clicks_timestamp"),
            Input("stop", "n_clicks_timestamp"),
        ],
    )
    def start_stop(start, stop):
        if start < stop:
            return 0
        else:
            return -1

    @app.callback(Output("output", "children"),
                  [Input("interval", "n_intervals")])
    def display_data(n_intervals):
        return f"Updated {n_intervals}"

    dash_dcc.start_server(app)

    wait.until(lambda: dash_dcc.find_element("#output").text != "Updated 0", 3)
    dash_dcc.find_element("#stop").click()
    time.sleep(2)

    text_now = dash_dcc.find_element("#output").text
    time.sleep(2)
    text_later = dash_dcc.find_element("#output").text

    assert text_now == text_later

    dash_dcc.find_element("#start").click()

    wait.until(lambda: dash_dcc.find_element("#output").text != text_later, 3)

    assert dash_dcc.get_logs() == []
Ejemplo n.º 7
0
    def __init__(self, time, price):

        self.time = time
        self.closingPrice = price
        print(self.time)
        print(self.closingPrice)
        self.app = dash.Dash(__name__)

        self.app.layout = html.Div([
            dcc.Graph(id="live-graph", animate=True),
            dcc.Interval(id="graph-update", interval=60000, n_intervals=0),
        ])
        self.app.callback(Output("live-graph", "figure"),
                          [Input("graph-update", "n_intervals")])(
                              self.update_graph)
Ejemplo n.º 8
0
def plot_live_inference(purpose_hdf5_group: h5py.Group):
    data_hdf5_group = purpose_hdf5_group["data"]
    occ_dem_dataset = data_hdf5_group[ChannelEnum.OCC_DEM.value]
    comp_dem_dataset = data_hdf5_group[ChannelEnum.COMP_DEM.value]

    occ_dems = np.array(occ_dem_dataset)
    comp_dems = np.array(comp_dem_dataset)

    app = dash.Dash(__name__)
    app.layout = html.Div([
        dcc.Graph(id='live-graph', animate=True),
        dcc.Interval(id='graph-update',
                     interval=500,
                     n_intervals=0,
                     max_intervals=comp_dem_dataset.shape[0]),
    ])

    @app.callback(Output('live-graph', 'figure'),
                  [Input('graph-update', 'n_intervals')])
    def update_graph_scatter(i):
        data_occ = plotly.graph_objs.Surface(z=occ_dems[i],
                                             name='Occluded DEM',
                                             colorscale="viridis",
                                             opacity=0.9,
                                             showscale=False)

        data_comp = plotly.graph_objs.Surface(z=comp_dems[i],
                                              name='Composed DEM',
                                              colorscale="viridis",
                                              colorbar={
                                                  "len": 0.6,
                                                  "lenmode": "fraction"
                                              },
                                              opacity=0.65,
                                              showscale=True)

        layout = go.Layout(title='Occluded & Composed DEM',
                           width=1000,
                           height=900,
                           scene={"aspectratio": {
                               "x": 1,
                               "y": 1,
                               "z": 0.3
                           }})

        return {'data': [data_occ, data_comp], 'layout': layout}

    app.run_server()
Ejemplo n.º 9
0
def serve_layout():
    return html.Div([
        html.A(id='api-help-link',
               children='?',
               href=f'{request.url_root}help' if has_request_context() else '',
               target='_blank',
               title='View the API documentation',
               style={
                   'color': '#fff',
                   'background-color': '#f15A29',
                   'width': 16,
                   'height': 16,
                   'display': 'inline-block',
                   'border-radius': '100%',
                   'font-size': 16,
                   'text-align': 'center',
                   'text-decoration': 'none',
                   'box-shadow': 'inset -2px -2px 1px 0px rgba(0,0,0,0.25)',
                   'margin-left': '98%',
                   'margin-bottom': 4,
               }),
        dcc.Dropdown(
            id='omega-dropdown',
            options=dropdown_options,
            multi=True,
            placeholder='Select the OMEGA iServer(s)...',
        ),
        DatetimeRangePicker(id='datetime-range',
                            **datetime_range_picker_kwargs(cfg)),
        dcc.Tabs(
            id='tabs',
            value='temperature',
            children=[
                dcc.Tab(label='Current Readings', value='current-readings'),
                dcc.Tab(label='Temperature', value='temperature'),
                dcc.Tab(label='Humidity', value='humidity'),
                dcc.Tab(label='Dewpoint', value='dewpoint'),
            ],
            style={'display': 'inline-block'},
        ),
        html.Div(id='plot-viewer'),
        html.Div(id='current-readings-viewer'),
        dcc.Interval(
            id='current-readings-interval',
            interval=cfg.value('current_readings/interval', 10) * 1000,
        ),
    ])
Ejemplo n.º 10
0
def get_footer():
    """ """
    return html.Footer(
        [
            html.Div(
                [
                    html.P([f"{k}: "]),
                    html.A([html.Img(src=v)], href=v.split(".svg")[0]),
                ],
                className="col",
            ) for k, v in BUILD_STATUS_MAPPING
        ] + [
            dcc.Interval(
                id=BUILD_STATUS_INTERVAL, interval=60 * 1000, n_intervals=0)
        ],
        className="page-footer text-center row p-3",
    )
Ejemplo n.º 11
0
def test_intv001_interval(dash_dcc):
    app = Dash(__name__)
    app.layout = html.Div([
        html.Div(id="output"),
        dcc.Interval(id="interval", interval=1, max_intervals=2),
    ])

    @app.callback(Output("output", "children"),
                  [Input("interval", "n_intervals")])
    def update_text(n):
        return str(n)

    dash_dcc.start_server(app)

    time.sleep(5)

    dash_dcc.wait_for_text_to_equal("#output", "2")
    assert dash_dcc.get_logs() == []
Ejemplo n.º 12
0
def generate_tab_other():
    return html.Div([
        html.Div(children=[
            dcc.Interval(id="tab-other-default-interval",
                         interval=1 * 2000,
                         n_intervals=0),
            html.Div(children=[
                dcc.Graph(
                    id='piechart-events',
                    config={
                        'displayModeBar': False,
                    },
                ),
            ],
                     style={
                         'padding': 10,
                         'flex': 1
                     }),
        ],
                 style=generate_box())
    ])
Ejemplo n.º 13
0
def get_header():
    """ """
    with open(
        Path(__file__).parent.parent.parent / ".github" / "images" / "aivclab.svg", "rb"
    ) as svg:
        encoded = base64.b64encode(svg.read())
        return html.Div(
            [
                html.Div(
                    [html.H1(HTML_TITLE)],
                    className="col text-left align-self-center p-1",
                ),
                html.Div(
                    [
                        html.Img(
                            src="/assets/alexandra.png",
                            style={"height": "110px", "object-fit": "contain"},
                        ),
                        html.Img(
                            src=f"data:image/svg+xml;base64,{encoded.decode()}",
                            # className='img-responsive',
                            style={"height": "110px", "object-fit": "contain"},
                        ),
                    ],
                    className="col text-center p-1",
                ),
                html.Div(
                    [
                        html.H1(id=TIME_ID),
                        dcc.Interval(id=TIME_INTERVAL_ID, interval=1000, n_intervals=0),
                    ],
                    className="col text-right align-self-center p-1",
                ),
            ],
            className="row p-3",
        )
Ejemplo n.º 14
0
                        2016: "2016",
                    },
                ),
                dbc.Button(
                    id="my-button",
                    children="Submit",
                    n_clicks=0,
                    color="primary",
                    className="mt-4",
                ),
            ],
            width=6,
        ),
    ]),
    dcc.Store(id="storage", storage_type="session", data={}),
    dcc.Interval(id="timer", interval=1000 * 60, n_intervals=0),
])


@app.callback(Output("storage", "data"), Input("timer", "n_intervals"))
def store_data(n_time):
    dataframe = update_wb_data()
    return dataframe.to_dict("records")


@app.callback(
    Output("my-choropleth", "figure"),
    Input("my-button", "n_clicks"),
    Input("storage", "data"),
    State("years-range", "value"),
    State("radio-indicator", "value"),
Ejemplo n.º 15
0
        dbc.Nav(
            [
                dbc.NavLink(f"{ctag}", href=f"/{ctag}", active="exact")
                for ctag in COMPRESSOR_TAGS
            ],
            vertical=True,
            pills=True,
        ),
    ],
    style=SIDEBAR_STYLE,
)

content = html.Div(id="page-content", style=CONTENT_STYLE)
interval = dcc.Interval(
    id="interval-component",
    interval=900 * 1000,
    n_intervals=0,  # in milliseconds
)
store = dcc.Store(id="store")
store_int = dcc.Store(id="store-int")


app.layout = html.Div(
    [dcc.Location(id="url"), sidebar, content, store, interval, store_int]
)


@app.callback(Output("page-content", "children"), [Input("url", "pathname")])
def render_page_content(pathname):
    if pathname[1:] in COMPRESSOR_TAGS:
        return page_layout()
Ejemplo n.º 16
0
                'padding-top': 8
            },
        )
    ],
             className="banner",
             style={
                 'width': '96%',
                 'margin-top': '2%'
             }),

    # Main HTML division
    html.Div(
        [

            # Element that allows you to update components on a predefined interval
            dcc.Interval(
                id="interval-update", interval=2 * 1000, n_intervals=0),

            # Invisible div that stores the JSON-serialized dataframe of DAQ data
            dcc.Store(id='store-daq-keys'),
            dcc.Store(id='store-daq-values'),

            # Html div that stores the DAQ graph and display parameters
            div_graph_daq(),

            # The html div storing the DAQ controls
            div_daq_controls(),

            # The html div storing the device measurement control
            div_device_controls(),

            # The html div storing the DAQ output
Ejemplo n.º 17
0
                         "color": "white",
                     },
                     {
                         "if": {
                             "filter_query": "{Action} != SELL",
                             "column_id": "Action",
                         },
                         "backgroundColor": "#3D9970",
                         "color": "white",
                     },
                 ],
             ),
         ], ),
 ]),
 # update interval
 dcc.Interval(id="interval-container", interval=10000, n_intervals=0),
 html.P(),
 # graphs
 dbc.Row([
     # margin graph
     dbc.Col([
         # html.Div(id='margin-current'),
         daq.Gauge(
             label="Current Margins",
             id="margin-current",
             color={
                 "gradient": True,
                 "ranges": {
                     "#99413d": [-35, -20],
                     "#F1C232": [-20, 20],
                     "#3D9970": [20, 35],
Ejemplo n.º 18
0
                'display': 'inline-block'
            },
        ),
        html.Div(
            children=dcc.Graph(
                id='time_calls',
                figure=plot2,
                #config={"displayModeBar": False},
            ),
            style={
                'width': '30%',
                'display': 'inline-block'
            },
        ),
        dcc.Interval(
            id='interval-component',
            interval=60 * 60 * 1000,  # in milliseconds
            n_intervals=0),
    ]))


# Multiple components can update everytime interval gets fired.
@app.callback([
    Output('total_calls', 'figure'),
    Output('time_calls', 'figure'),
    Output('gauge_time_calls', 'figure'),
    Output('gauge_meetings', 'figure'),
    Output('gauge_total_calls', 'figure')
], [Input('radio_item', 'value'),
    Input('interval-component', 'n_intervals')])
def update_graph_to_month(radio_item_val, n):
Ejemplo n.º 19
0
                        fac.AntdStatistic(
                            id='statistic-demo',
                            precision=2,
                            title='XX股份实时股价',
                            value=675.32,
                            valueStyle={
                                'color': '#cf1322'
                            },
                            prefix={
                                'mode': 'icon',
                                'content': 'antd-rise'
                            }
                        ),

                        dcc.Interval(
                            id='statistic-interval-demo',
                            n_intervals=0
                        ),

                        fac.AntdDivider(
                            '回调示例',
                            lineColor='#f0f0f0',
                            innerTextOrientation='left'
                        ),

                        fac.AntdCollapse(
                            fuc.FefferySyntaxHighlighter(
                                showLineNumbers=True,
                                showInlineLineNumbers=True,
                                language='python',
                                codeStyle='coy-without-shadows',
                                codeString='''
Ejemplo n.º 20
0
def render_connection(tab):
    """
    Callback of the tab for the connection. If server tab is active, you can access the network list for the time graphs
    and also to see if the connection is active
    :param tab:
    :return:
    """
    if tab == 'server':
        return [
            html.Div(dbc.Input(id='input-on-submit', placeholder='URL:port', type="text", className="mb-1"),
                     style={'display': 'inline-block', 'width': '69%', 'textarea:color': 'black'}),
            html.Div(children=' ', style={'display': 'inline-block', 'width': '2%'}),
            html.Div(dbc.Button("Connect", id="connect-server-button", className="mr-1"),
                     style={'display': 'inline-block', 'width': '29%'}),
            html.Br(),
            dcc.Interval(
                id='interval-time-graph',
                interval=UPDATE_TIME_GRAPH,  # in milliseconds
                n_intervals=0,
                disabled=True),
            dcc.Interval(
                id='interval-data',
                interval=UPDATE_DATA,  # in milliseconds
                n_intervals=0,
                disabled=True),
            dcc.Interval(
                id='interval-states',
                interval=UPDATE_TIME_STATES,  # in milliseconds
                n_intervals=0),
            dcc.Interval(
                id='interval-alarms',
                interval=UPDATE_TIME_ALARMS,  # in milliseconds
                n_intervals=0),
            html.Br(),
            html.H4('Time graphs stations'),
            html.Div(id='container-button-basic',
                     children=[
                             dcc.Dropdown(id='network-list-active',
                                             placeholder='Select stations for time graphs',
                                             options=network_list, multi=True),
                             html.P('Connection not active', style={'color': 'red'})
                             ]
                     ),
            dbc.RadioItems(
                id='realtime-radiobox',
                options=[
                    {'label': 'Real-Time', 'value': 'realtime'},
                    {'label': 'Data Retrieval', 'value': 'retrieval', 'disabled': True}
                ],
                value='realtime',
                inline=True
            ),
            html.Div(id='date-picker', children=[]),
            html.Br()
            ]
    elif tab == 'folder':
        return [
            html.Div(dbc.Input(id='input-on-submit', placeholder='/path/to/SDS', type="text", className="mb-1"),
                     style={'display': 'inline-block', 'width': '69%', 'textarea:color': 'white'}),
            html.Div(children=' ', style={'display': 'inline-block', 'width': '2%'}),
            html.Div(dbc.Button("Connect", id="connect-server-button", className="mr-1"),
                     style={'display': 'inline-block', 'width': '29%'}),
            html.Br(),
            dcc.Interval(
                id='interval-time-graph',
                interval=UPDATE_TIME_GRAPH,  # in milliseconds
                n_intervals=0,
                disabled=True),
            dcc.Interval(
                id='interval-data',
                interval=UPDATE_DATA,  # in milliseconds
                n_intervals=0,
                disabled=True),
            dcc.Interval(
                id='interval-states',
                interval=UPDATE_TIME_STATES,  # in milliseconds
                n_intervals=0),
            dcc.Interval(
                id='interval-alarms',
                interval=UPDATE_TIME_ALARMS,  # in milliseconds
                n_intervals=0),
            html.Br(),

            html.H4('Time graphs stations'),
            html.Div(id='container-button-basic',
                     children=[
                             dcc.Dropdown(id='network-list-active',
                                             placeholder='Select stations for time graphs',
                                             options=network_list, multi=True, style={'color': 'black'}),
                             html.P('Folder not active', style={'color': 'red'})
                             ]
                     ),
            dbc.RadioItems(
                id='realtime-radiobox',
                options=[
                    {'label': 'Real-Time', 'value': 'realtime'},
                    {'label': 'Data Retrieval', 'value': 'retrieval', 'disabled': True}
                ],
                value='realtime',
                inline=True
            ),
            html.Div(id='date-picker', children=[]),
            html.Br()
            ]
Ejemplo n.º 21
0
import dash_bootstrap_components as dbc
from dash import Input, Output, dcc, html

progress = html.Div([
    dcc.Interval(id="progress-interval", n_intervals=0, interval=500),
    dbc.Progress(id="progress"),
])


@app.callback(
    [Output("progress", "value"),
     Output("progress", "label")],
    [Input("progress-interval", "n_intervals")],
)
def update_progress(n):
    # check progress of some background process, in this example we'll just
    # use n_intervals constrained to be in 0-100
    progress = min(n % 110, 100)
    # only add text after 5% progress to ensure text isn't squashed too much
    return progress, f"{progress} %" if progress >= 5 else ""
Ejemplo n.º 22
0
                        module._outputs for module in _modules
                        if module._outputs is not None
                    ],
                    style={'visibility': 'hidden'})

logout_button = dbc.Button("Logout",
                           id="logout-button",
                           style={
                               'marginRight': '10px',
                               'visibility': 'hidden'
                           }),
logout_button = html.A(href='/logout', children=logout_button)

_layout = html.Div([
    html.Div(logout_button),
    dcc.Interval(
        id="progress-interval", n_intervals=0, interval=2000, disabled=False),
    html.A(href='https://sorenwacker.github.io/ms-mint/gui/',
           children=[
               html.Button('Documentation',
                           id='B_help',
                           style={
                               'float': 'right',
                               'color': 'info'
                           })
           ],
           target="_blank"),
    html.
    A(href=
      f'https://github.com/sorenwacker/ms-mint/issues/new?body={T.get_issue_text()}',
      children=[
          html.Button('Issues',
Ejemplo n.º 23
0
def connect_update_server(n_clicks, value, tab):
    """
    Connect to the server with the EasySLC class. This is a Seedlink client which waits for the user of MONA-LISA to
    choose some stations. When one is selected, it will start to retrieve the data from the server.
    :param n_clicks:
    :param value:
    :return:
    """

    global client
    global client_thread
    global network_list
    global network_list_values
    network_list = []
    network_list_values = []

    if tab == 'server':
        if value is not None:
            try:
                pass
                client = EasySLC(value, network_list, network_list_values)
                # client = SeedLinkClient(value, network_list, network_list_values)
            except SeedLinkException:
                client.connected = 0

            if client.connected == 1:
                try:
                    client_thread.close()
                except AttributeError:
                    pass
                if client.data_retrieval is False:
                    client_thread = SLThread('Client SL Realtime', client)
                    client_thread.start()
                return [
                    dcc.Dropdown(id='network-list-active',
                                 placeholder='Select stations for time graphs',
                                 options=network_list, multi=True, style={'color': 'black'}),
                    html.P('Connection active to {}'.format(value), style={'color': 'green'}),
                    dcc.Interval(
                        id='interval-data',
                        interval=UPDATE_DATA,  # in milliseconds
                        n_intervals=0,
                        disabled=False),
                ]
            elif client.connected == -1:
                return [
                    dcc.Dropdown(id='network-list-active',
                                 placeholder='Select stations for time graphs',
                                 options=network_list, multi=True, style={'color': 'black'}),
                    html.P('Config file of server missing.', style={'color': 'red'}),
                ]
            else:
                return [
                    dcc.Dropdown(id='network-list-active',
                                 placeholder='Select stations for time graphs',
                                 options=network_list, multi=True, style={'color': 'black'}),
                    html.P('Verify the config file, no station found.', style={'color': 'red'}),
                ]
        else:
            return [
                dcc.Dropdown(id='network-list-active',
                             placeholder='Select stations for time graphs',
                             options=[], multi=True, style={'color': 'black'}),
                html.P('Connection not active', style={'color': 'red'}),
            ]
    elif tab == 'folder':
        if value is not None and os.path.isdir(value):
            connected = get_network_list('folder', network_list, network_list_values, folder_file='stations.xml')
            if connected is not None:
                if connected == 1:
                    return [
                            dcc.Dropdown(id='network-list-active',
                                         placeholder='Select stations for time graphs',
                                         options=network_list, multi=True, style={'color': 'black'}),
                            html.P('Connection active to {}'.format(value), style={'color': 'green'}),
                            dcc.Interval(
                                id='interval-data',
                                interval=UPDATE_DATA,  # in milliseconds
                                n_intervals=0,
                                disabled=False)
                        ]
                elif connected == -1:
                    return [
                        dcc.Dropdown(id='network-list-active',
                                     placeholder='Select stations for time graphs',
                                     options=network_list, multi=True, style={'color': 'black'}),
                        html.P('Config file of folder missing.', style={'color': 'red'}),
                    ]
                else:
                    return [
                        dcc.Dropdown(id='network-list-active',
                                     placeholder='Select stations for time graphs',
                                     options=network_list, multi=True, style={'color': 'black'}),
                        html.P('Verify the config file, no station found.', style={'color': 'red'}),
                    ]
        else:
            return [
                dcc.Dropdown(id='network-list-active',
                             placeholder='Select stations for time graphs',
                             options=[], multi=True, style={'color': 'black'}),
                html.P('Connection not active', style={'color': 'red'}),
            ]
Ejemplo n.º 24
0
def render_figures_top(tab, sta_list, n_intervals):

    if VERBOSE == 2:
        pid = os.getpid()
        python_process = psutil.Process(pid)
        memory_use = python_process.memory_info()[0]/2.**30
        print('memory use:', round(memory_use,3))

    gc.collect()

    if tab == 'server':
        global client
        global time_graphs_names
        global time_graphs
        global fig_list
        global interval_time_graphs
        if sta_list is None:
            time_graphs_names = []
            time_graphs = []
            fig_list = []
        else:
            for i, name in enumerate(time_graphs_names):
                if name not in sta_list:
                    time_graphs_names.pop(i)
                    time_graphs.pop(i)
                    fig_list.pop(i)

            for station in sta_list:
                # ADDING NEW STATION TO THE GRAPH LIST

                if station not in time_graphs_names:
                    if os.path.isdir(BUFFER_DIR) is not True:
                        os.mkdir(BUFFER_DIR)

                    try:
                        data_sta = pd.read_feather(BUFFER_DIR+'/'+station+'.data')
                    except FileNotFoundError:
                        data_sta = pd.DataFrame({'Date': [pd.to_datetime(UTCDateTime().timestamp, unit='s')], 'Data_Sta': [0]})

                    date_x = data_sta['Date'].values
                    data_sta_y = data_sta['Data_Sta'].values

                    fig = go.Figure(go.Scattergl(x=date_x, y=data_sta_y, mode='lines', showlegend=False,
                                                 line=dict(color=COLOR_TIME_GRAPH),
                                                 hovertemplate='<b>Date:</b> %{x}<br>' +
                                                               '<b>Val:</b> %{y}<extra></extra>'))

                    range_x = [pd.Timestamp(date_x[-1])-TIME_DELTA, pd.Timestamp(date_x[-1])]

                    fig.update_layout(template='plotly_dark', title=station,
                                      xaxis={'range': range_x},
                                      yaxis={'autorange': True},
                                      height=HEIGHT_GRAPH,
                                      margin=dict(l=LEFT_GRAPH, r=RIGHT_GRAPH, b=BOTTOM_GRAPH, t=TOP_GRAPH, pad=4))

                    fig_list.append(fig)
                    time_graphs_names.append(station)
                    time_graphs.append(dcc.Graph(figure=fig, id=station, config={'displaylogo': False}))

                    interval_time_graphs = dcc.Interval(
                        id='interval-time-graph',
                        interval=UPDATE_TIME_GRAPH,  # in milliseconds
                        n_intervals=0,
                        disabled=False)

                # UPDATING THE EXISTING GRAPHS
                else:
                    i = time_graphs_names.index(station)

                    try:
                        data_sta = pd.read_feather(BUFFER_DIR+'/'+station+'.data')
                    except FileNotFoundError:
                        data_sta = pd.DataFrame({'Date': [pd.to_datetime(UTCDateTime().timestamp, unit='s')], 'Data_Sta': [0]})

                    date_x = data_sta['Date'].values
                    data_sta_y = data_sta['Data_Sta'].values

                    fig_list[i].data = []
                    fig_list[i].add_trace(go.Scattergl(x=date_x, y=data_sta_y, mode='lines', showlegend=False,
                                                       line=dict(color=COLOR_TIME_GRAPH),
                                                       hovertemplate='<b>Date:</b> %{x}<br>' +
                                                                     '<b>Val:</b> %{y}<extra></extra>'))
                    try:
                        if client.data_retrieval is False:
                            range_x = [pd.Timestamp(date_x[-1]) - TIME_DELTA, pd.Timestamp(date_x[-1])]
                            fig_list[i].update_xaxes(range=range_x)
                        else:
                            range_x = [pd.Timestamp(date_x[0]), pd.Timestamp(date_x[-1])]
                            fig_list[i].update_xaxes(range=range_x)
                    except AttributeError:
                        range_x = [pd.Timestamp(date_x[-1]) - TIME_DELTA, pd.Timestamp(date_x[-1])]
                        fig_list[i].update_xaxes(range=range_x)

        return html.Div([
            # html.H6('Connection server tab active'),
            html.Div(children=time_graphs),
            html.Div(children=interval_time_graphs)
        ])
Ejemplo n.º 25
0
def test_grva005_graph_extend_trace(dash_dcc, is_eager):
    app = Dash(__name__, eager_loading=is_eager)

    def generate_with_id(id, data=None):
        if data is None:
            data = [{"x": [0, 1, 2, 3, 4], "y": [0, 0.5, 1, 0.5, 0]}]

        return html.Div([
            html.P(id),
            dcc.Graph(id=id, figure=dict(data=data)),
            html.Div(id="output_{}".format(id)),
        ])

    figs = [
        "trace_will_extend",
        "trace_will_extend_with_no_indices",
        "trace_will_extend_with_max_points",
    ]

    layout = [generate_with_id(id) for id in figs]

    figs.append("trace_will_allow_repeated_extend")
    data = [{"y": [0, 0, 0]}]
    layout.append(generate_with_id(figs[-1], data))

    figs.append("trace_will_extend_selectively")
    data = [
        {
            "x": [0, 1, 2, 3, 4],
            "y": [0, 0.5, 1, 0.5, 0]
        },
        {
            "x": [0, 1, 2, 3, 4],
            "y": [1, 1, 1, 1, 1]
        },
    ]
    layout.append(generate_with_id(figs[-1], data))

    layout.append(
        dcc.Interval(
            id="interval_extendablegraph_update",
            interval=10,
            n_intervals=0,
            max_intervals=1,
        ))

    layout.append(
        dcc.Interval(
            id="interval_extendablegraph_extendtwice",
            interval=500,
            n_intervals=0,
            max_intervals=2,
        ))

    app.layout = html.Div(layout)

    @app.callback(
        Output("trace_will_allow_repeated_extend", "extendData"),
        [Input("interval_extendablegraph_extendtwice", "n_intervals")],
    )
    def trace_will_allow_repeated_extend(n_intervals):
        if n_intervals is None or n_intervals < 1:
            raise PreventUpdate

        return dict(y=[[0.1, 0.2, 0.3, 0.4, 0.5]])

    @app.callback(
        Output("trace_will_extend", "extendData"),
        [Input("interval_extendablegraph_update", "n_intervals")],
    )
    def trace_will_extend(n_intervals):
        if n_intervals is None or n_intervals < 1:
            raise PreventUpdate

        x_new = [5, 6, 7, 8, 9]
        y_new = [0.1, 0.2, 0.3, 0.4, 0.5]
        return dict(x=[x_new], y=[y_new]), [0]

    @app.callback(
        Output("trace_will_extend_selectively", "extendData"),
        [Input("interval_extendablegraph_update", "n_intervals")],
    )
    def trace_will_extend_selectively(n_intervals):
        if n_intervals is None or n_intervals < 1:
            raise PreventUpdate

        x_new = [5, 6, 7, 8, 9]
        y_new = [0.1, 0.2, 0.3, 0.4, 0.5]
        return dict(x=[x_new], y=[y_new]), [1]

    @app.callback(
        Output("trace_will_extend_with_no_indices", "extendData"),
        [Input("interval_extendablegraph_update", "n_intervals")],
    )
    def trace_will_extend_with_no_indices(n_intervals):
        if n_intervals is None or n_intervals < 1:
            raise PreventUpdate

        x_new = [5, 6, 7, 8, 9]
        y_new = [0.1, 0.2, 0.3, 0.4, 0.5]
        return dict(x=[x_new], y=[y_new])

    @app.callback(
        Output("trace_will_extend_with_max_points", "extendData"),
        [Input("interval_extendablegraph_update", "n_intervals")],
    )
    def trace_will_extend_with_max_points(n_intervals):
        if n_intervals is None or n_intervals < 1:
            raise PreventUpdate

        x_new = [5, 6, 7, 8, 9]
        y_new = [0.1, 0.2, 0.3, 0.4, 0.5]
        return dict(x=[x_new], y=[y_new]), [0], 7

    for id in figs:

        @app.callback(
            Output("output_{}".format(id), "children"),
            [Input(id, "extendData")],
            [State(id, "figure")],
        )
        def display_data(trigger, fig):
            return json.dumps(fig["data"])

    dash_dcc.start_server(app)

    comparison = json.dumps([
        dict(
            x=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
            y=[0, 0.5, 1, 0.5, 0, 0.1, 0.2, 0.3, 0.4, 0.5],
        )
    ])
    dash_dcc.wait_for_text_to_equal("#output_trace_will_extend", comparison)
    dash_dcc.wait_for_text_to_equal(
        "#output_trace_will_extend_with_no_indices", comparison)
    comparison = json.dumps([
        dict(x=[0, 1, 2, 3, 4], y=[0, 0.5, 1, 0.5, 0]),
        dict(
            x=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
            y=[1, 1, 1, 1, 1, 0.1, 0.2, 0.3, 0.4, 0.5],
        ),
    ])
    dash_dcc.wait_for_text_to_equal("#output_trace_will_extend_selectively",
                                    comparison)

    comparison = json.dumps(
        [dict(
            x=[3, 4, 5, 6, 7, 8, 9],
            y=[0.5, 0, 0.1, 0.2, 0.3, 0.4, 0.5],
        )])
    dash_dcc.wait_for_text_to_equal(
        "#output_trace_will_extend_with_max_points", comparison)

    comparison = json.dumps(
        [dict(y=[0, 0, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.1, 0.2, 0.3, 0.4, 0.5])])
    dash_dcc.wait_for_text_to_equal("#output_trace_will_allow_repeated_extend",
                                    comparison)

    assert dash_dcc.get_logs() == []
Ejemplo n.º 26
0
from dash.dependencies import Input, Output

from pyorbital.orbital import Orbital
satellite = Orbital('TERRA')

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div(
    html.Div([
        html.H4('TERRA Satellite Live Feed'),
        html.Div(id='live-update-text'),
        dcc.Graph(id='live-update-graph'),
        dcc.Interval(
            id='interval-component',
            interval=2 * 1000,
            n_intervals=0,
        )
    ]))


@app.callback(Output('live-update-text', 'children'),
              Input('interval-component', 'n_intervals'))
def update_metrics(n):
    lon, lat, alt = satellite.get_lonlatalt(datetime.datetime.now())
    style = {'padding': '5px', 'fontSize': '16px'}
    return [
        html.Span('Longitude: {0:.2f}'.format(lon), style=style),
        html.Span('Latitude: {0:.2f}'.format(lat), style=style),
        html.Span('Altitude: {0:0.2f}'.format(alt), style=style),
        html.Span('Intervals: {0:0.2f}'.format(n), style=style),
Ejemplo n.º 27
0
                          'type': 'scatter3d',
                          'x': [],
                          'y': [],
                          'z': []}
                         ],
                'layout': {'template': pio.templates['plotly'],
                           'height': 650,
                           'uirevision': 'no_change'
                           }
            },
        ),

        dbc.Row([
            dcc.Interval(
                id='buffer-interval',
                interval=2000,  # in milliseconds
                disabled=False,
                n_intervals=0
            ),
            dbc.Col(
                dbc.Progress(id='buffer',
                             value=0,
                             color='info',
                             style={'height': '2px',
                                    'margin-top': 0,
                                    'margin-bottom': 5,
                                    'margin-left': 25,
                                    'margin-right': 25},
                             className='mb-3'), width=12),
            dbc.Col(dcc.Slider(
                id='slider-frame',
                step=1,
Ejemplo n.º 28
0
def generate_tab_flow():
    return html.Div([
        html.Div(children=[
            dcc.Interval(id="tab-flow-default-interval",
                         interval=1 * 2000,
                         n_intervals=0),
            html.Div(children=[
                dt.DataTable(
                    id='table-info',
                    columns=[{
                        'id': c.lower(),
                        'name': c,
                        'editable': False
                    } for c in ['Name', 'Total']],
                    style_header={
                        'backgroundColor': '#082233',
                        'color': 'white'
                    },
                    style_data={
                        'backgroundColor': '#082244',
                        'color': 'white'
                    },
                )
            ],
                     style={
                         'display': 'flex',
                         'flex-direction': 'row'
                     }),
            html.Div(children=[
                dcc.Graph(
                    id='piechart-flows',
                    config={
                        'displayModeBar': False,
                    },
                    figure=build_piechart([
                        'Detected', 'Guessed', 'Not-Detected', 'Unclassified'
                    ], [0, 0, 0, 0], COLOR_MAP['piechart-flows']),
                ),
            ],
                     style={
                         'padding': 10,
                         'flex': 1
                     }),
            html.Div(children=[
                dcc.Graph(
                    id='piechart-midstream-flows',
                    config={
                        'displayModeBar': False,
                    },
                    figure=build_piechart(
                        ['Midstream', 'Not Midstream'], [0, 0],
                        COLOR_MAP['piechart-midstream-flows']),
                ),
            ],
                     style={
                         'padding': 10,
                         'flex': 1
                     }),
            html.Div(children=[
                dcc.Graph(
                    id='piechart-risky-flows',
                    config={
                        'displayModeBar': False,
                    },
                    figure=build_piechart(['Risky', 'Not Risky'], [0, 0],
                                          COLOR_MAP['piechart-risky-flows']),
                ),
            ],
                     style={
                         'padding': 10,
                         'flex': 1
                     }),
        ],
                 style=generate_box()),
        html.Div(children=[
            dcc.Interval(id="tab-flow-graph-interval",
                         interval=4 * 1000,
                         n_intervals=0),
            dcc.Store(id="graph-traces"),
            html.Div(children=[
                dcc.Graph(
                    id="graph-flows",
                    config={
                        'displayModeBar': True,
                        'displaylogo': False,
                    },
                    style={'height': '60vh'},
                ),
            ],
                     style={
                         'padding': 10,
                         'flex': 1
                     })
        ],
                 style=generate_box())
    ])
Ejemplo n.º 29
0
app.layout = html.Div(
    style={
        "backgroundColor": COLORS["background"],
        "height": "100vh",
        "width": "100%",
    },
    children=[
        html.H1(
            children="💰 Zamal's Morlingue 💰",
            style={
                "textAlign": "center",
                "color": COLORS["text"]
            },
        ),
        dcc.Interval(id="interval-component",
                     interval=HOUR * 1000,
                     n_intervals=0),
        html.Div(
            children="Assets summary in €",
            style={
                "textAlign": "center",
                "color": COLORS["text"]
            },
        ),
        dcc.Graph(id="total-graph"),
        html.Div(
            children="Sliding window",
            style={
                "textAlign": "center",
                "color": COLORS["text"]
            },
Ejemplo n.º 30
0
                  This project is an implementation of 
                  [Conway's Game of Life](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life),
                  a population simulation governed by a small set of rules:

                1. *Any live cell with {GameOfLife._min_neighbors} or {GameOfLife._max_neighbors} live neighbours survives.*
                2. *Any dead cell with {GameOfLife._pop_neighbors} live neighbours becomes a live cell.*
                2. *All other live cells die in the next generation. Similarly, all other dead cells stay dead.*

                The neighborhood of a cell comprises the eight adjacent cells.
            """),
        ]),
    ]),
    dcc.Interval(
        id="interval-gol",
        interval=100,
        disabled=True,
    ),
    dcc.Store(
        id="store-gol",
        data={},
    ),
    dbc.Card([
        dbc.CardHeader([
            dcc.Markdown("""
                ### The Simulation
                ***
            """),
            dbc.InputGroup(
                size="sm",
                children=[