def username_in_layout(id): oauth_token = flask.request.cookies['plotly_oauth_token'] base_url = 'https://plotly.charleyferrari.com/v2' endpoint = '/users/current' headers = { 'plotly-client-platform': 'dash-auth', 'content-type': 'application/json', 'Authorization': 'Bearer {}'.format(oauth_token) } r = requests.get(url=base_url + endpoint, headers=headers, verify=False) username = r.json()['username'] return html.Div(className='container', children=[ Header('Hello {}'.format(username)), Row([ Column(width=4, children=[ dcc.Dropdown( id='dropdown', options=[{ 'label': i, 'value': i } for i in ['LA', 'NYC', 'MTL']], value='LA') ]), Column(width=8, children=[dcc.Graph(id='graph')]) ]) ])
def initiate_containers(self): for i in range(len(self.field)): self.squares.append(Square(i // 3 * 3, i % 3 * 3, self.field)) self.rows.append(Row(i, self.field)) self.columns.append(Column(i, self.field)) self.update_all()
app = dash.Dash(__name__) server = app.server # Expose the server variable for deployments # Standard Dash app code below app.layout = html.Div(className='container', children=[ Header('Sample App'), Row([ Column(width=4, children=[ dcc.Dropdown( id='dropdown', options=[{ 'label': i, 'value': i } for i in ['LA', 'NYC', 'MTL']], value='LA') ]), Column(width=8, children=[dcc.Graph(id='graph')]) ]) ]) @app.callback(Output('graph', 'figure'), [Input('dropdown', 'value')]) def update_graph(value): return { 'data': [{ 'x': [1, 2, 3, 4, 5, 6], 'y': [3, 1, 2, 3, 5, 6]
# Start layout app = dash.Dash(__name__) server = app.server # Expose the server variable for deployments # Standard Dash app code below app.layout = html.Div( className='container', children=[ Header('Arxiv Assistant', app), Row([ dcc.Input(id='input-url', placeholder='Enter URL...', type='text', value='', style={ 'width': '80%', 'margin-right': '20px' }), html.Button('Submit', id='button-update') ]), Row([ Column(width=6, children=[ dcc.Markdown(id='markdown-article', style=card_style()), dcc.Markdown(id='markdown-recommendations', style=card_style('#e5ecf6', '#626efa')) ]), Column(width=6, children=[ dcc.Graph(id='graph-topics', style={'height': '40%'}),
children=html.Div(className='control-tab', children=[ Row(style={'display': 'flex', 'align-items': 'center', 'justify-content': 'center'}, children=[ Column(children=[ html.Strong("X Axis",), dcc.Dropdown( id='x-axis-dropdown', value='return_1yr', multi=False, options=get_axis_dropwdown() ),] , width=3), Column(children=[ html.Strong("Y Axis"), dcc.Dropdown( id='y-axis-dropdown', value='fee', multi=False, options=get_axis_dropwdown() ),] , width=3), Column(children=[ html.Strong("Colour By"), dcc.Dropdown( id='color-dropdown', value='superfund_type', multi=False, options=get_color_dropdown() ),] , width=3) ]), html.Br(),
server = app.server # Expose the server variable for deployments options = [{'label': i, 'value': i} for i in ['LA', 'NYC', 'MTL']] # Standard Dash app code below app.layout = html.Div(className='container', children=[ Header('Sample App', app), Row([ Column(width=4, children=[ dcc.Dropdown( id='dropdown', options=options, value='LA' ) ]), Column(width=8, children=[ dcc.Graph(id='graph') ]) ]) ]) @app.callback(Output('title', 'children'), [Input('title', 'id')]) def give_name(title): username = auth.get_username() if username: return '{}\'s Sample App'.format(username) return 'Anonymous Sample App'
Row([ Column(width=6, children=[ dcc.Dropdown(id='dealer-dropdown', options=[{ 'label': f"{name_map[i]} ({i})", 'value': str(i) } for i in dealer_list], value=dealer_list[0]), dcc.DatePickerRange( id='date-picker-range', display_format='Y-M-D', min_date_allowed=dt(2017, 1, 1), max_date_allowed=dt(2020, 1, 1), start_date=dt(2017, 1, 1), end_date=dt(2020, 1, 1), ), dcc.RadioItems(id='lead-radio-items', options=[{ 'label': i.replace('_', ' ').title(), 'value': i } for i in ['lead_type', 'lead_status']], labelStyle={'display': 'inline-block'}, value='lead_type'), dcc.Graph(id='lead-graph') ]), Column(width=6, children=[ dcc.Dropdown(id='stats-dropdown', options=[{ 'label': i.replace('_', ' ').title(), 'value': i } for i in stats], value=stats[0]), dcc.Dropdown(id='website-id-dropdown', options=[{ 'label': f"Website #{i}", 'value': str(i) } for i in website_ids], value=str(website_ids[0])), dcc.Graph(id='website-stats-graph') ]) ])