-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathusage.py
45 lines (38 loc) · 960 Bytes
/
usage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import dash
import time
import random
from dash import html, dcc
import feffery_antd_charts as fact
from dash.dependencies import Input, Output
from feffery_dash_utils.style_utils import style
app = dash.Dash(__name__)
app.layout = html.Div(
[
html.Button('更新', id='update'),
dcc.Loading(
fact.AntdLine(
id='chart-demo',
data=[
{
'date': f'2020-0{i}',
'y': random.randint(50, 100),
}
for i in range(1, 10)
],
xField='date',
yField='y',
)
),
],
style=style(padding=50),
)
@app.callback(
Output('chart-demo', 'key'),
Input('update', 'n_clicks'),
prevent_initial_call=True,
)
def update(n_clicks):
time.sleep(2)
return str(n_clicks)
if __name__ == '__main__':
app.run(debug=True)