Skip to content

Commit 5a31238

Browse files
Create app.py
1 parent c839377 commit 5a31238

File tree

1 file changed

+135
-0
lines changed

1 file changed

+135
-0
lines changed

Diff for: dash-layout-tutorial/app.py

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
from dash import Dash, html, dcc
2+
import dash_bootstrap_components as dbc
3+
4+
import plotly.graph_objects as go
5+
import numpy as np
6+
import random
7+
8+
app = Dash(__name__, external_stylesheets=[dbc.themes.FLATLY])
9+
10+
fig = go.Figure(
11+
go.Scattergl(
12+
x = np.random.randn(1000),
13+
y = np.random.randn(1000),
14+
mode='markers',
15+
marker=dict(color=random.sample(['#ecf0f1']*500 + ["#3498db"]*500, 1000), line_width=1)
16+
)
17+
)
18+
fig.update_layout(plot_bgcolor='#010103', width=790, height=730,
19+
xaxis_visible=False, yaxis_visible=False, showlegend=False, margin=dict(l=0,r=0,t=0,b=0))
20+
21+
app.layout = dbc.Container([
22+
html.Div([
23+
html.Div([
24+
html.H1([
25+
html.Span("Welcome"),
26+
html.Br(),
27+
html.Span("to my beautiful dashboard!")
28+
]),
29+
html.
30+
P("This dashboard prototype shows how to create an effective layout."
31+
)
32+
],
33+
style={"vertical-alignment": "top", "height": 260}),
34+
html.Div([
35+
html.Div(
36+
dbc.RadioItems(
37+
className='btn-group',
38+
inputClassName='btn-check',
39+
labelClassName="btn btn-outline-light",
40+
labelCheckedClassName="btn btn-light",
41+
options=[
42+
{"label": "Graph", "value": 1},
43+
{"label": "Table", "value": 2}
44+
],
45+
value=1,
46+
style={'width': '100%'}
47+
), style={'width': 206}
48+
),
49+
html.Div(
50+
dbc.Button(
51+
"About",
52+
className="btn btn-info",
53+
n_clicks=0
54+
), style={'width': 104})
55+
], style={'margin-left': 15, 'margin-right': 15, 'display': 'flex'}),
56+
html.Div([
57+
html.Div([
58+
html.H2('Unclearable Dropdown:'),
59+
dcc.Dropdown(
60+
options=[
61+
{'label': 'Option A', 'value': 1},
62+
{'label': 'Option B', 'value': 2},
63+
{'label': 'Option C', 'value': 3}
64+
],
65+
value=1,
66+
clearable=False,
67+
optionHeight=40,
68+
className='customDropdown'
69+
)
70+
]),
71+
html.Div([
72+
html.H2('Unclearable Dropdown:'),
73+
dcc.Dropdown(
74+
options=[
75+
{'label': 'Option A', 'value': 1},
76+
{'label': 'Option B', 'value': 2},
77+
{'label': 'Option C', 'value': 3}
78+
],
79+
value=2,
80+
clearable=False,
81+
optionHeight=40,
82+
className='customDropdown'
83+
)
84+
]),
85+
html.Div([
86+
html.H2('Clearable Dropdown:'),
87+
dcc.Dropdown(
88+
options=[
89+
{'label': 'Option A', 'value': 1},
90+
{'label': 'Option B', 'value': 2},
91+
{'label': 'Option C', 'value': 3}
92+
],
93+
clearable=True,
94+
optionHeight=40,
95+
className='customDropdown'
96+
)
97+
])
98+
], style={'margin-left': 15, 'margin-right': 15, 'margin-top': 30}),
99+
html.Div(
100+
html.Img(src='assets/image.svg',
101+
style={'margin-left': 15, 'margin-right': 15, 'margin-top': 30, 'width': 310})
102+
)
103+
], style={
104+
'width': 340,
105+
'margin-left': 35,
106+
'margin-top': 35,
107+
'margin-bottom': 35
108+
}),
109+
html.Div(
110+
[
111+
html.Div(
112+
dcc.Graph(
113+
figure=fig
114+
),
115+
style={'width': 790}),
116+
html.Div([
117+
html.H2('Output 1:'),
118+
html.Div(className='Output'),
119+
html.H2('Output 2:'),
120+
html.Div(html.H3("Selected Value"), className='Output')
121+
], style={'width': 198})
122+
],
123+
style={
124+
'width': 990,
125+
'margin-top': 35,
126+
'margin-right': 35,
127+
'margin-bottom': 35,
128+
'display': 'flex'
129+
})
130+
],
131+
fluid=True,
132+
style={'display': 'flex'},
133+
className='dashboard-container')
134+
if __name__ == "__main__":
135+
app.run_server(debug=True)

0 commit comments

Comments
 (0)