-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient_side_callbacks.py
77 lines (64 loc) · 2.17 KB
/
client_side_callbacks.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
from dash import (Input, Output,
clientside_callback, MATCH,
ClientsideFunction,
)
def drawer_sidebar_togle():
clientside_callback(
ClientsideFunction(
namespace='layout_callbacks',
function_name='drawer_sidebar_togle'
),
Output("drawer-sidebar-button", "children"),
Output("drawer-sidebar-button", "style"),
Input("drawer-sidebar-button", "n_clicks")
)
def theme_switcher_callback():
clientside_callback(
ClientsideFunction(
namespace='theme',
function_name='theme_switcher_callback'
),
Output("mantine-provider", "theme"),
Output("mantine-provider", "forceColorScheme"),
Output("color-scheme-toggle", "children"),
Input("color-scheme-toggle", "n_clicks")
)
clientside_callback(
"""function update_badge_count(value) {
const no_update = window.dash_clientside.no_update
const objectLength = value ? Object.keys(value).length : 0;
return objectLength
}
""",
Output({"type": "badge-num-filters", "index": MATCH}, "children"),
Input({"type": "checkbox-options", "index": MATCH}, "value"),
)
clientside_callback(
"""function maximize_chart(n_clicks) {
const no_update = window.dash_clientside.no_update
let ctx = window.dash_clientside.callback_context;
if (ctx.triggered.length !=1 ) {
return no_update
}
const triggered_id = JSON.parse(ctx.triggered[0]['prop_id'].split(".")[0])
if (n_clicks % 2 === 1) {
return {'height':'100%', 'position':'relative' }
}
return {'height':'50%', 'position':'relative' }
}
""",
Output({"type": "maximize-graph", "index": MATCH}, "style"),
Input({"type": "action-maximize-graph", "index": MATCH}, "n_clicks"),
prevent_intial_call = True
)
clientside_callback(
ClientsideFunction(
namespace='maps',
function_name='map_renderer'
),
Output('states-check-data', "children"),
Output('legend', "children"),
Output('select-all-states', "checked"),
Input('map-select-product', "value"),
Input('map-data', "data"),
)