forked from equinor/webviz-core-components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
usage.py
116 lines (110 loc) · 4.02 KB
/
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
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import dash
from dash.dependencies import Input, Output, State
import dash_html_components as html
import webviz_core_components as wcc
app = dash.Dash(__name__)
app.layout = html.Div(
[
wcc.WebvizPluginPlaceholder(id="plugin", children=["Hello world"]),
wcc.WebvizPluginPlaceholder(
children=[
wcc.FlexBox(
children=[
html.Div(
"First element (before break)",
style={"background-color": "rgba(0, 255, 255, 0.2)"},
),
html.Div(style={"height": "0px", "width": "100%"}),
html.Div(
"Second",
style={
"width": "20%",
"background-color": "rgba(255, 0, 0, 0.2)",
},
),
html.Div(
"Third",
style={
"width": "40%",
"background-color": "rgba(0, 255, 0, 0.2)",
},
),
html.Div(
"Fourth",
style={
"width": "40%",
"background-color": "rgba(0, 0, 255, 0.2)",
},
),
]
)
]
),
wcc.WebvizPluginPlaceholder(
id="some-other-plugin",
children=[
wcc.ColorScales(id="colorscale"),
wcc.Graph(
id="example-graph",
figure={
"data": [
{
"x": [1, 2, 3],
"y": [4, 1, 2],
"type": "bar",
"name": "a",
},
{
"x": [1, 2, 3],
"y": [2, 4, 5],
"type": "bar",
"name": "b",
},
{
"x": [1, 2, 3],
"y": [1, 4, 5],
"type": "bar",
"name": "c",
},
{
"x": [1, 2, 3],
"y": [2, 3, 5],
"type": "bar",
"name": "d",
},
{
"x": [1, 2, 3],
"y": [2, 2, 5],
"type": "bar",
"name": "e",
},
{
"x": [1, 2, 3],
"y": [2, 4, 6],
"type": "bar",
"name": "f",
},
{
"x": [1, 2, 3],
"y": [2, 4, 1],
"type": "bar",
"name": "g",
},
],
"layout": {"title": "Dash Data Visualization", "height": 1200},
},
),
],
),
]
)
@app.callback(
Output("example-graph", "figure"),
[Input("colorscale", "colorscale")],
[State("example-graph", "figure")],
)
def update_colors(colorscale, figure):
figure["layout"]["colorway"] = colorscale
return figure
if __name__ == "__main__":
app.run_server(debug=True)