Ejemplo n.º 1
0
                         dcc.Graph(id='timeseries',
                                   config={'displayModeBar': False},
                                   animate=True)
                     ]),
            html.Div(className='eight columns div-for-charts bg-grey',
                     children=[
                         dcc.Graph(id='timeseries1',
                                   config={'displayModeBar': False},
                                   animate=True)
                     ])
        ],
    )
])


@app.callback(Output('timeseries', 'figure'),
              [Input('lovbruddstype', 'value'),
               Input('years', 'value')])
def update_graph(lovbruddstyper, years):
    trace1 = []
    df_sub = df1
    for lovbrudd in lovbruddstyper:
        trace1.append(
            go.Line(
                x=df_sub[df_sub['lovbruddstype'] == lovbrudd]
                ['år'].sort_values(axis=0, ascending=True).unique(),
                y=df_sub[df_sub['lovbruddstype'] == lovbrudd]['value'],
                mode='x',
                #opacity=0.9,
                name='lovbruddstype',
                textposition='bottom center'))
Ejemplo n.º 2
0
                    'font-family': 'Sans-Serif',
                    'color': "rgba(117, 117, 117, 0.95)"
                }),
    dcc.Tabs(id="tabs-example",
             value='tab-1-example',
             children=[
                 dcc.Tab(label='Overview', value='tab-1-example'),
                 dcc.Tab(label='In/Out', value='tab-2-example'),
                 dcc.Tab(label='Test', value='tab-3-example'),
             ]),
    dbc.Row(html.H1('')),
    html.Div(id='tabs-content-example')
])


@app.callback(Output('tabs-content-example', 'children'),
              [Input('tabs-example', 'value')])
def render_content(tab):
    if tab == 'tab-1-example':

        return html.Div([
            dbc.Row([
                dbc.Col([
                    html.H1('Overall balance'),
                    simple_data_table.visual_simple_data_table(overview),
                ]),
                dbc.Col([
                    html.H1('Balance over time'),
                    dbc.Row(
                        multi_line_chart.visual_dropdown(
                            'my-dropdown',
Ejemplo n.º 3
0
    	'color': colors['text']
    	}
    ),

    html.Div(children='What happens when you self-teach python and work in marketing', style={
    	'textAlign': 'center',
    	'color': colors['text']
    	}),

    dcc.Graph(id='main_graph'),

    dcc.Interval(
        id="query_update",interval=6000,n_intervals=0),

])
@app.callback(Output('main_graph', 'figure'),Input('query_update', 'n_intervals'))
def update_figure(n):
    df = read_and_plot()
    fig = px.bar(df, x='Word', y='Frequency')
    fig.update_layout(
    font_family="Courier New",
    font_color="black",
    title_font_family="Times New Roman",
    title_font_color="black")
    fig.update_traces(marker_color='MediumPurple')
    return fig


if __name__ == '__main__':
    app.run_server(debug=True, host='0.0.0.0',port=8080)
Ejemplo n.º 4
0
app.layout = dbc.Container([
    dcc.Store(id="store"),
    dcc.Interval(id="interval", interval=500),
    html.H2("Redis / RQ demo", className="display-4"),
    html.P(EXPLAINER),
    html.Hr(),
    dbc.Textarea(id="text", className="mb-3"),
    dbc.Button("Upper case", id="button", color="primary", className="mb-3"),
    dbc.Collapse(dbc.Progress(id="progress", className="mb-3"), id="collapse"),
    html.P(id="output"),
])


@app.callback(
    Output("store", "data"),
    [Input("button", "n_clicks")],
    [State("text", "value")],
)
def submit(n_clicks, text):
    if n_clicks:
        id_ = uuid.uuid4()

        # queue the task
        queue.enqueue(slow_loop, text, id_, job_id=str(id_))

        # record queuing in the database
        result = Result(id=id_, queued=datetime.datetime.now())
        db.session.add(result)
        db.session.commit()
Ejemplo n.º 5
0
                                       'find the most relevant movies and/or tv series that will absolutely delight you! So, lets go!!',
                              style={
                                  'textAlign': 'center',
                                  'color': colors['text']
                              }
                              ),
                          dcc.Tabs(id="tabs-example", value='tab-1',
                                   children=[
                                       dcc.Tab(label='Personal Choice Based Recommendation', value='tab-1'),
                                       dcc.Tab(label='Genre/Time Based Recommendation', value='tab-2'),
                                   ]),
                          html.Div(id='tabs-content-display')
                      ])


@app.callback(Output('tabs-content-display', 'children'),
              [Input('tabs-example', 'value')])

def render_content(tab):
    if tab == 'tab-1':
        return tab1.tab1_layout
    elif tab == 'tab-2':
        return tab2.tab2_layout


# Tab 1 callback
@app.callback(Output('my-table', 'children'), [Input('movie_list_input', 'value')])
def update_table(selected_movie):
    movie_list = nmr.userchoice_based_movie_recommendation(selected_movie)
    return nmr.generate_table(movie_list)
        html.Br(),

        # Choropleth map
        html.Div([dcc.Graph(id="att_level_map", figure={})],
                 style={
                     "padding-left": "25%",
                     "padding-right": "25%"
                 })
    ])

#------------------------------------------------
# Connect Plotly graphs with Dash components


@app.callback([
    Output(component_id="output_container", component_property="children"),
    Output(component_id="att_level_map", component_property="figure")
], [Input(component_id="dt_pick_single", component_property="date")])
def update_graph(date_picked):
    print(date_picked)
    print(type(date_picked))
    # Print Date selected
    container = f"Date selected: {date_picked[:10]}"

    # Because date_picked is of type str, need to conver to int
    date_picked = int(date_picked[8:10])

    # FIGURE
    # center of map
    lat = 42.355753
    lng = -83.076760
Ejemplo n.º 7
0
                             fluid=True,
                             dark=True,
                             color="primary")
        ],
                width=12)
    ]),
    dcc.Location(id="url", refresh=False, pathname="/apps/welcome"),
    html.Div(id='page-content', children=[]),
    dbc.Row(
        dbc.Col(
            html.Div(
                "(c) CAD Group 6 - Keele University -  Built by Dash on Flask",
                style={"text-align": "center"})))
])


@app.callback(Output('page-content', 'children'), [Input('url', 'pathname')])
def display_page(pathname):
    if pathname == '/apps/seminars':
        return seminars.layout
    if pathname == '/apps/exhibitions':
        return exhibitions.layout
    if pathname == '/apps/discussions':
        return discussions.layout
    else:
        return welcome.layout


if __name__ == '__main__':
    app.run_server(debug=False)
Ejemplo n.º 8
0
from dash.dependencies import Input, Output, State
import re

# df = pd.read_csv(
#     'https://gist.githubusercontent.com/chriddyp/' +
#     '5d1ea79569ed194d432e56108a04d188/raw/' +
#     'a9f9e8076b837d541398e999dcbac2b2826a81f8/'+
#     'gdp-life-exp-2007.csv')
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(children='电影数据散点图')], style={'padding-bottom': '20px'}),
    html.Div(id='scatter'),
    ])

@app.callback(Output('scatter','children'),
              )
def update_output_scatter_marker(Input):
    client = pymongo.MongoClient('mongodb://127.0.0.1:27017/')
    db = client.douban
    collection = db.detail
    pattern = re.compile('20')
    result = collection.find({'release_time': pattern})
    data_initial = pd.DataFrame(list(result))
    #X轴
    release_date = data_initial['release_time']
    release_date_list = []
    for i in release_date:
        release_date_list.append(i)
    scatter_x = pd.Series(data=release_date_list)
    #Y轴
        html.Div([
            dcc.Dropdown(
                id='yaxis-column',
                options=[{'label': i, 'value': i}
                         for i in available_indicators],
                value='RH'
            ),
        ], style={'width': '48%', 'float': 'right', 'display': 'inline-block'})
    ]),

    dcc.Graph(id='indicator-graphic'),
])


@app.callback(
    Output('indicator-graphic', 'figure'),
    [Input('xaxis-column', 'value'),
     Input('yaxis-column', 'value'),])
def update_graph(xaxis_column_name, yaxis_column_name):
    
    fig = px.scatter(x=df[xaxis_column_name],
                     y=df[yaxis_column_name], color=df['PM High'])

    fig.update_layout(
        margin={'l': 40, 'b': 40, 't': 10, 'r': 0}, hovermode='closest')

    fig.update_xaxes(title=labels[xaxis_column_name])

    fig.update_yaxes(title=labels[yaxis_column_name])

    return fig
Ejemplo n.º 10
0
                               {
                                   'label': 'No',
                                   'value': 0
                               },
                           ],
                           value=0,
                           labelStyle={
                               'display': 'inline-block',
                               'fontSize': 24
                           })),
    ])
])


@app.callback(
    Output('feature-graphic', 'figure'),
    [Input('mu', 'value'),
     Input('sd', 'value'),
     Input('z', 'value')])
def update_graph(mu, sd, z):
    x = np.linspace(mu - (4 * sd), mu + (4 * sd), 1001)
    y = [norm.pdf(i, mu, sd) for i in x]
    zx = [
        mu - (3 * sd), mu - (2 * sd), mu - sd, mu + sd, mu + (2 * sd),
        mu + (3 * sd)
    ]
    zy = [norm.pdf(i, mu, sd) for i in zx]
    trace0 = go.Scatter(x=x, y=y, mode='lines', hoverinfo='none')
    trace1 = go.Bar(x=zx,
                    y=zy,
                    text=['Z=-3', 'Z=-2', 'Z=-1', 'Z=1', 'Z=2', 'Z=3'],
Ejemplo n.º 11
0
                                                     value='True',
                                                 )
                                             ],
                                             style={'display': 'none'})
                                ])
                    ])
        ])


# App Layout
app.layout = html.Div(children=[side_bar(), html.Div(id='layout')])


# CALLBACKS
@app.callback([
    Output("fighter-a", "valid"),
    Output("fighter-a", "invalid"),
    Output("fighter-b", "valid"),
    Output("fighter-b", "invalid"),
    Output("submit", "disabled")
], [Input("fighter-a", "value"),
    Input("fighter-b", "value")], [
        State("fighter-a", "valid"),
        State("fighter-b", "valid"),
        State("fighter-a", "invalid"),
        State("fighter-b", "invalid"),
        State("submit", "disabled")
    ],
              prevent_initial_call=True)
def check_name(a_name, b_name, a_curr_val, b_curr_val, a_curr_inv, b_curr_inv,
               b_dis):
Ejemplo n.º 12
0
                      config={
                          'displayModeBar': False,
                          'scrollZoom': True
                      },
                      style={
                          'padding-bottom': '2px',
                          'padding-left': '2px',
                          'height': '90vh'
                      })
        ]),
    ]),
])


#Callback
@app.callback(Output('graph', 'figure'), [
    Input('boro_name', 'value'),
    Input('cuisine_name', 'value'),
    Input('grade_name', 'value')
])
def update_figure(boro_name, cuisine_name, grade_name):
    dff = df[(df['BORO'].isin(boro_name)) & (df['CUISINE'].isin(cuisine_name))
             & (df['GRADE'].isin(grade_name))]

    #create figure
    locations = [
        go.Scattermapbox(
            lon=dff['Longitude'],
            lat=dff['Latitude'],
            mode='markers',
            marker={'color': dff['Colors']},
Ejemplo n.º 13
0
                md=12,
                lg=5,
                xl=5)),
    dbc.Row(
        dbc.Col(html.H2("Patient Count",
                        className='text-center text-primary mb-4'),
                width=12)),
    dbc.Row(
        dbc.Card(
            dbc.CardImg(
                src=
                "https://raw.githubusercontent.com/AkankshKM/CapstoneImage/main/Prophet.png"
            )))
])


@app.callback(Output(component_id='my-output', component_property='children'),
              Input(component_id='time', component_property='value'),
              Input(component_id='day', component_property='value'),
              Input(component_id='duration', component_property='value'),
              Input(component_id='esi', component_property='value'),
              Input(component_id='patientcount', component_property='value'))
def update_output_div(time, day, duration, esi, patientcount):
    obj = Model()
    result = obj.test_model(time, day, duration, esi, patientcount)
    return 'Output: {}'.format(str(result))


if __name__ == '__main__':
    # model = joblib.load("./model.pkl")
    app.run_server(debug=True)
Ejemplo n.º 14
0
        ])
    else:
        return html.I('Oura Connected!')


def generate_oura_auth():
    return [
        html.Div(id='authorize-oura-container', className='twelve columns maincontainer',
                 children=[
                     html.H4('Oura Connection'),
                     html.Div(id='oura-auth', children=[test_oura_connection()]
                              ), ])]


# Callback for authorizing oura tokens
@dash_app.callback(Output('oura-token-refresh', 'children'),
                   [Input('url', 'search')],
                   [State('url', 'pathname')])
def update_tokens(token, pathname):
    if 'oura' in pathname:
        if token:
            auth_code = re.findall('=(?<=\=)(.*?)(?=\&)', token)[0]
            auth_client.fetch_access_token(auth_code)
            save_oura_token(auth_client.session.token)


# Main Dashboard Generation Callback
@dash_app.callback(
    Output('oura-auth-layout', 'children'),
    [Input('oura-auth-canvas', 'children')]
)
Ejemplo n.º 15
0
app.layout = html.Div([
    dcc.Graph(id='graph-with-slider'),
    dcc.Slider(
        id='year-slider',
        min=df['year'].min(),
        max=df['year'].max(),
        value=df['year'].min(),
        marks={str(year): str(year) for year in df['year'].unique()},
        step=None
    )
])


@app.callback(
    Output('graph-with-slider', 'figure'),
    [Input('year-slider', 'value')])
def update_figure(selected_year):
    filtered_df = df[df.year == selected_year]
    traces = []
    for i in filtered_df.continent.unique():
        df_by_continent = filtered_df[filtered_df['continent'] == i]
        traces.append(dict(
            x=df_by_continent['gdpPercap'],
            y=df_by_continent['lifeExp'],
            text=df_by_continent['country'],
            mode='markers',
            opacity=0.7,
            marker={
                'size': 15,
                'line': {'width': 0.5, 'color': 'white'}
Ejemplo n.º 16
0
                        ),
                        html.Br(),
                        html.Div(id="updateSuccess"),
                    ],
                    md=6,
                ),
            ]),
        ],
        className="jumbotron",
        id="pageContent",
    ),
])


#### Affiche le nom de l'utilisateur connecté
@app.callback(Output("username", "children"),
              [Input("pageContent", "children")])
def currentUserName(pageContent):
    try:
        username = current_user.username
        return username
    except AttributeError:
        return ""


#### Affiche l'adresse mail de l'utilisateur connecté
@app.callback(Output("email", "children"), [Input("pageContent", "children")])
def currentUserEmail(pageContent):
    try:
        email = current_user.email
        return email
Ejemplo n.º 17
0
    return html.Div(
        [
            html.H1("Metaswitch Tinder", className="text-center"),
            html.Br(),
            *is_signed_in_fields,
            html.Br(),
            mentee_request.layout(),
            html.Div(id="dummy-signin-{}".format(NAME), hidden=True),
        ],
        className="container",
        id="my-div",
    )


@app.callback(
    Output("my-div".format(NAME), "children"),
    [],
    [],
    [Event(mentee_request.submit_button, "click")],
)
def submit_mentee_information():
    log.debug("%s - %a clicked", NAME, mentee_request.submit_button)
    session.set_post_login_redirect(
        href(__name__, mentee_request.submit_request))


@app.callback(
    Output("dummy-signin-{}".format(NAME), "children"),
    [],
    [],
    [Event("signin-{}".format(NAME), "click")],
Ejemplo n.º 18
0
    def execute(self):
        """Execute the link.

        :returns: status code of execution
        :rtype: StatusCode
        """
        settings = process_manager.service(ConfigObject)
        ds = process_manager.service(DataStore)

        # --- your algorithm code goes here
        self.logger.debug('Now executing link: {link}.', link=self.name)

        app = dash.Dash(
            __name__,
            assets_folder=self.assets_folder,
        )

        figure_childs = du.figure_grid(len(self.figures),
                                       self.figures,
                                       layout_kwargs=self.layout_kwargs)

        app.layout = html.Div([
            html.Div([
                du.row([
                    du.column([
                        html.H1(self.app_title), *self.controls,
                        html.H2('Filter by:'), *self.filter_controls
                    ],
                              className="two columns"),
                    du.column(figure_childs, className='ten columns'),
                ])
            ])
        ])

        # Make the callbacks --  This needs to be done manually for each control!

        # FIGURE 1
        @app.callback(Output('fig_0', 'figure'), [
            Input('dropdown_0', 'value'),
            Input('slider_0', 'value'),
            Input('filter_dropdown', 'value')
        ])
        def update_fig1(col, bins, filter):
            return du.make_histogram(ds[self.read_key], col, bins, filter,
                                     self.layout_kwargs)

        # FIGURE 2
        @app.callback(Output('fig_1', 'figure'), [
            Input('dropdown_1', 'value'),
            Input('slider_1', 'value'),
            Input('filter_dropdown', 'value')
        ])
        def update_fig2(col, bins, filter):
            return du.make_histogram(ds[self.read_key], col, bins, filter,
                                     self.layout_kwargs)

        # FIGURE 3
        @app.callback(Output('fig_2', 'figure'), [
            Input('dropdown_2', 'value'),
            Input('dropdown_3', 'value'),
            Input('filter_dropdown', 'value')
        ])
        def update_fig3(x, y, filter):
            return du.make_scatter(ds[self.read_key], x, y, filter,
                                   self.layout_kwargs)

        # save app in datastore
        ds[self.store_key] = app

        return StatusCode.Success
Ejemplo n.º 19
0
			]),
			html.Div([
				html.Span('The last click occurred at: '),
				html.Span(id='app1-output2', children=None),
			])
			'''

		])
	])

# Modifies the 'children' property of the element with ID 'app1-output'
# The 'children' property is whatever is stored within a HTML tag: <div>children go here</div>
# Children can be a list of elements or a single element
#
@app.callback(
	Output('app1-output', 'children'),
	[Input('app1-button', 'n_clicks')])

'''
@app.callback(
	[
		Output('app1-output', 'children'),
		Output('app1-output2', 'children'),
	],
	[ Input('app1-button', 'n_clicks') ])
def update_click_count(n_clicks):
	if n_clicks == 0:
		timestamp = 'never'
	else:
		timestamp = datetime.today().strftime('%Y-%m-%d %H:%M:%S')
	return n_clicks, timestamp
                     'width': '48%',
                     'float': 'right',
                     'display': 'inline-block'
                 })
    ]),
    dcc.Graph(id='indicator-graphic'),
    html.Div([
        dcc.Markdown(
            "Are stewards (steward activity measured by the ‘steward’ variable) having an impact on the health of trees? "
        ),
        dcc.Graph(id='ind-graph')
    ])
])


@app.callback(Output('indicator-graphic', 'figure'),
              [Input('xaxis-column', 'value'),
               Input('yaxis-column', 'value')])
def update_graph(xaxis_column_name, yaxis_column_name):
    dff = df[df['boroname'] == xaxis_column_name]
    dff = df[df['spc_common'] == yaxis_column_name]

    traces = []
    for i in dff.health.unique():
        df_h = dff[dff['health'] == i]
        traces.append(
            go.Bar(
                x=df_h[df_h['spc_common'] == yaxis_column_name]['health'],
                y=df_h[df_h['boroname'] == xaxis_column_name]['percentage'],
                text=df_h[df_h['spc_common'] == yaxis_column_name]['health'],
                name=i))
Ejemplo n.º 21
0
            'width': '100%',
            'height': '60px',
            'lineHeight': '60px',
            'borderWidth': '1px',
            'borderStyle': 'dashed',
            'borderRadius': '5px',
            'textAlign': 'center',
            'margin': '10px'
        },
        multiple=False),
    html.Br(),
    html.Div(id='output-data-upload'),
    pp_graph       
])

@app.callback(Output('output-data-upload', 'children'),
            [
                Input('upload-data', 'contents'),
                Input('upload-data', 'filename')
            ])

def update_table(contents, filename):
    table = html.Div()
    if contents:
        df = parse_data(contents, filename)
        des_df = df.describe(include="all").reset_index()
        percent_missing = (df.isnull().sum() * 100 / len(df))
        miss_df = pd.DataFrame({'Column_Name': df.columns,'Percent_Missing': percent_missing}).reset_index(drop = True)
        table = html.Div([
        html.H4("Data Statistics for the Uploaded File Name:  {}".format(filename)),
		html.H6('Number of Columns: {} and Number of Rows: {}'.format(df.shape[0], df.shape[1])),
Ejemplo n.º 22
0
                    "justify-content": "center",
                    "margi-top": 10,
                },
            ),
            html.Div(id="clustering-plot", children=[clustering_scatter]),
        ],
    ),
])

##########################################################################################
#                                       CALLBACKS
##########################################################################################


@app.callback(
    Output("correlation-scatter", "figure"),
    [
        Input("correlation-x-axis-dropdown", "value"),
        Input("correlation-y-axis-dropdown", "value"),
    ],
)
def update_correlation_scatter_figure(
        x_axis_dropdown_value: str, y_axis_dropdown_value: str) -> typing.Dict:
    """
    Callback aimed to changes the Iris scatter content by selecting x and y axis data sets

    :param x_axis_dropdown_value: the name of the data that will be displayed in the x
    axis
    :param y_axis_dropdown_value: the name of the data that will be displayed in the y
    axis
    :return: the data and the layout content
Ejemplo n.º 23
0
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=1 * 1000,  # in milliseconds
            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),
    ]


# Multiple components can update everytime interval gets fired.
@app.callback(Output("live-update-graph", "figure"),
              [Input("interval-component", "n_intervals")])
def update_graph_live(n):
Ejemplo n.º 24
0
ceil_marks = list(range(500, len(route_df), 500)) + [len(route_df) - 1]
slider_marks = {f: f'{f} to {c}' for f, c in zip(floor_marks, ceil_marks)}

app.layout = html.Div(children=[
    html.H1(children='Openflights data'),
    dcc.Graph(id='world-map-graph'),
    dcc.Slider(id='flights-slider',
               min=100,
               max=len(route_df),
               value=500,
               marks=slider_marks,
               step=None)
])


@app.callback(Output('world-map-graph', 'figure'),
              [Input('flights-slider', 'value')])
def update_world_map(num_routes):
    fig = go.Figure()

    # plot the locations
    fig.add_trace(
        go.Scattergeo(lon=loc_df['longitude'],
                      lat=loc_df['latitude'],
                      hoverinfo='text',
                      text=loc_df['name'],
                      mode='markers',
                      marker=dict(size=2, color='rgb(255, 0, 0)')))

    # plot the flights
    r_df = route_df.iloc[num_routes:num_routes + 500]
Ejemplo n.º 25
0
                                    plot_bgcolor="#F4F4F8",
                                    autofill=True,
                                    margin=dict(t=75, r=50, b=100, l=50),
                                ),
                            ),
                        ),
                    ],
                ),
            ],
        ),
    ],
)


@app.callback(
    Output("county-choropleth", "figure"),
    [Input("year-select", "value")],
    [State("county-choropleth", "figure")],
)
def display_map(year, figure):
    cm = dict(zip(BINS, DEFAULT_COLORSCALE))

    data = [
        dict(
            lat=df_lat_lon["Latitude "],
            lon=df_lat_lon["Longitude"],
            text=df_lat_lon["Hover"],
            type="scattermapbox",
            hoverinfo="text",
            marker=dict(size=5, color="white", opacity=0),
        )
Ejemplo n.º 26
0
                                ]),
                                html.Br(),
                            ]),
                        ]),
                    ],
                    style={'background-color': '#CCD7EA'},
                ),
            ]),
        ]),
        html.Br(),
    ],
    className='ccontent')


@app.callback(
    Output("sma_collapse", "is_open"),
    [Input("formula_sma", "n_clicks")],
    [State("sma_collapse", "is_open")],
)
def toggle_collapse(n, is_open):
    '''
    this function is used to open collapse bar
    '''
    if n:
        return not is_open
    return is_open


@app.callback(
    Output("rsi_collapse", "is_open"),
    [Input("formula_rsi", "n_clicks")],
Ejemplo n.º 27
0
               html.P([
                   html.Label("Choose a county"),
                   dcc.Dropdown(id = 'opt_c')#, options = opt_state, value = 'The Whole State')
                       ], style = {'width': '400px',
                                   'fontSize' : '20px',
                                   'padding-left' : '100px',
                                   'display': 'inline-block'})

])



## Step 5. Add callback functions
@app.callback(
   Output('opt_c', 'options'),
   [Input('opt_s', 'value')])
def set_state_options(selected_state):
   return [{'label': i, 'value': i} for i in Dict[selected_state]]

@app.callback(
   Output('opt_c', 'value'),
   [Input('opt_c', 'options')])
def set_county_value(available_options):
   return available_options[0]['value']

@app.callback(Output('google_fig', 'figure'),
              [Input('slider', 'value'), 
               Input('opt_s', 'value')])

def update_figure(input2, selected_state):
                min = min_week, max = max_week,
                value = [max_week-4,max_week], step=1,
                marks = {ind:str(ind) for ind in range(min_week, max_week,4)})

checklist_flagtypes = dcc.Checklist(
                id = 'cl_flagtypes', 
                value=['disinformation', 'fakenews', 'unreliable', 'propaganda'],
                options= [{'label':t,'value':t} for t in flagtypes] )

radio_coronatopic = dcc.RadioItems(
                id = 'rd_coronatopic', 
                value="yes",
                options= [{'label': 'yes', 'value':"yes"},
                          {'label': 'no','value':"no"}] )
@app.callback(
    Output(component_id='show_dates', component_property='children'),
    [Input(component_id='sl_week', component_property='value')]
)
def update_output_div1(input_value):
    return('%s -> %s' % (week_day_df.loc[input_value[0]].loc['min'],
                         week_day_df.loc[input_value[1]].loc['max']))


### LAYOUT

app.layout = \
    html.Div(
        children=[
            ### hidden
            html.Div(id='filtered_json_week', style={'display': 'none'}),
            
Ejemplo n.º 29
0
app.scripts.config.serve_locally = True

year_options = []

for year in df['year'].unique():
    year_options.append({'label': str(year), 'value': year})

app.layout = html.Div([
    dcc.Graph(id='graph'),
    dcc.Dropdown(id='year-picker',
                 options=year_options,
                 value=df['year'].min())
])


@app.callback(Output('graph', 'figure'), [Input('year-picker', 'value')])
def update_figure(selected_year):

    filtered_df = df[df['year'] == selected_year]

    traces = []

    for continent_name in filtered_df['continent'].unique():
        df_by_continent = filtered_df[filtered_df['continent'] ==
                                      continent_name]
        traces.append(
            go.Scatter(x=df_by_continent['gdpPercap'],
                       y=df_by_continent['lifeExp'],
                       mode='markers',
                       opacity=0.7,
                       marker={'size': 15},
Ejemplo n.º 30
0
    ,
    # Numeric input for the trade amount
    html.Div(dcc.input(id = "trade_amount", type = 'numeric'))
    ,
    # Submit button for the trade
    html.Div(dcc.input(id = "submit", type = 'text'))



])

# Callback for what to do when submit-button is pressed
@app.callback(
    [
(
    Output(component_id='my-output', component_property='children'),
    Input(component_id='my-input', component_property='figure')
     ],
)

)
def update_candlestick_graph(n_clicks, value): # n_clicks doesn't get used, we only include it for the dependency.

    # Now we're going to save the value of currency-input as a text file.
    currency_pair = open("value.txt", "w+"),
    # Wait until ibkr_app runs the query and saves the historical prices csv
    while(ibkr.app.py):



    # Read in the historical prices