Skip to content

Commit

Permalink
Switch from Dropdown to Select (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hans Kallekleiv authored Apr 30, 2020
1 parent d58c502 commit 69e2fda
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 116 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"pillow>=6.1",
"pyscal>=0.4.1",
"scipy>=1.2",
"webviz-config>=0.0.48",
"webviz-config>=0.0.55",
"webviz-subsurface-components>=0.0.23",
"xtgeo>=2.8",
],
Expand Down
54 changes: 27 additions & 27 deletions webviz_subsurface/plugins/_inplace_volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,28 +230,25 @@ def selector_dropdowns(self):
dropdowns = []
for selector in self.selectors:
elements = list(self.volumes[selector].unique())
multi = True

if selector in ["ENSEMBLE", "SOURCE"]:
value = elements[0]
else:
value = elements

dropdowns.append(
html.Div(
children=[
html.Details(
open=True,
children=[
html.Summary(selector.lower().capitalize()),
dcc.Dropdown(
wcc.Select(
id=self.selectors_id[selector],
options=[
{"label": i, "value": i} for i in elements
],
value=value,
multi=multi,
clearable=False,
multi=True,
size=min(20, len(elements)),
),
],
)
Expand Down Expand Up @@ -343,26 +340,26 @@ def layout(self):
style={"height": 400},
children=wcc.Graph(id=self.ids("graph")),
),
html.Div(
children=[
html.Div(
id=self.ids("table_title"),
style={"textAlign": "center"},
children="",
),
DataTable(
id=self.ids("table"),
sort_action="native",
filter_action="native",
page_action="native",
page_size=10,
),
],
),
],
),
],
),
html.Div(
children=[
html.Div(
id=self.ids("table_title"),
style={"textAlign": "center"},
children="",
),
DataTable(
id=self.ids("table"),
sort_action="native",
filter_action="native",
page_action="native",
page_size=10,
),
],
),
]
)

Expand Down Expand Up @@ -430,36 +427,39 @@ def _render_vol_chart(*args):
[
Output(self.selectors_id["ENSEMBLE"], "multi"),
Output(self.selectors_id["ENSEMBLE"], "value"),
Output(self.selectors_id["ENSEMBLE"], "size"),
],
[Input(self.ids("group"), "value")],
)
def _set_iteration_selector(group_by):
"""If iteration is selected as group by set the iteration
selector to allow multiple selections, else use single selection
"""
selectors = list(self.volumes["ENSEMBLE"].unique())
if group_by == "ENSEMBLE":
return True, list(self.volumes["ENSEMBLE"].unique())
return True, selectors, len(selectors)

return False, list(self.volumes["ENSEMBLE"].unique())[0]
return False, selectors[0], 1

if "SOURCE" in self.selectors:

@app.callback(
[
Output(self.selectors_id["SOURCE"], "multi"),
Output(self.selectors_id["SOURCE"], "value"),
Output(self.selectors_id["SOURCE"], "size"),
],
[Input(self.ids("group"), "value")],
)
def _set_source_selector(group_by):
"""If iteration is selected as group by set the iteration
selector to allow multiple selections, else use single selection
"""

selectors = list(self.volumes["SOURCE"].unique())
if group_by == "SOURCE" and "SOURCE" in self.selectors:
return True, list(self.volumes["SOURCE"].unique())
return True, selectors, len(selectors)

return False, list(self.volumes["SOURCE"].unique())[0]
return False, selectors[0], 1


@CACHE.memoize(timeout=CACHE.TIMEOUT)
Expand Down
54 changes: 30 additions & 24 deletions webviz_subsurface/plugins/_inplace_volumes_onebyone.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ def add_webvizstore(self):

def selector(self, label, id_name, column):
return html.Div(
style={"paddingBottom": "30px"},
children=html.Label(
children=[
html.Span(f"{label}:", style={"font-weight": "bold"}),
Expand Down Expand Up @@ -340,15 +339,15 @@ def filter_selectors(self):
open=True,
children=[
html.Summary(selector.lower().capitalize()),
dcc.Dropdown(
wcc.Select(
id=self.selectors_id[selector],
options=[
{"label": i, "value": i}
for i in list(self.volumes[selector].unique())
],
value=list(self.volumes[selector].unique()),
multi=True,
clearable=False,
size=min(20, len(self.volumes[selector].unique())),
),
],
)
Expand Down Expand Up @@ -391,28 +390,35 @@ def layout(self):
],
),
html.Div(
style={"flex": 3, "height": "600px"},
id=self.ids("graph-wrapper"),
),
],
),
html.Div(
children=[
html.Div(
id=self.ids("volume_title"),
style={"textAlign": "center"},
children="",
),
DataTable(
id=self.ids("table"),
sort_action="native",
filter_action="native",
page_action="native",
page_size=10,
style={"flex": 3},
children=[
html.Div(
style={"height": "600px"},
id=self.ids("graph-wrapper"),
),
html.Div(
children=[
html.Div(
id=self.ids("volume_title"),
style={
"textAlign": "center"
},
children="",
),
DataTable(
id=self.ids("table"),
sort_action="native",
filter_action="native",
page_action="native",
page_size=10,
),
],
),
],
),
],
),
],
)
]
),
html.Div(
id=self.ids("tornado-wrapper"),
Expand Down Expand Up @@ -463,7 +469,7 @@ def _render_vol_chart(plot_type, ensemble, response, source, *filters):

# Make Plotly figure
layout = {}
layout.update({"margin": {"l": 100, "b": 100}})
layout.update({"height": 600, "margin": {"l": 100, "b": 100}})
if plot_type == "Per realization":
# One bar per realization
layout.update(
Expand Down
45 changes: 29 additions & 16 deletions webviz_subsurface/plugins/_parameter_correlation.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,6 @@ def matrix_plot(self):
@property
def control_div(self):
return [
html.Div(
style={"padding": "5px"},
children=[
html.Label(
"Set ensemble in all plots:", style={"font-weight": "bold"},
),
Widgets.dropdown_from_dict(
self.ids("ensemble-all"), self.ensembles
),
],
),
html.Div(
style={"padding": "5px"},
children=[
Expand Down Expand Up @@ -132,11 +121,35 @@ def control_div(self):

@property
def layout(self):
return html.Div(
return wcc.FlexBox(
children=[
wcc.FlexBox(self.control_div),
wcc.FlexBox(
children=[self.matrix_plot, wcc.Graph(id=self.ids("scatter"))]
html.Div(
style={"flex": 1},
children=[
self.matrix_plot,
html.Div(
style={"padding": "5px"},
children=[
html.Label(
"Set ensemble in all plots:",
style={"font-weight": "bold"},
),
Widgets.dropdown_from_dict(
self.ids("ensemble-all"), self.ensembles
),
],
),
],
),
html.Div(
style={"flex": 1},
children=[
html.Div(
style={"height": "400px"},
children=[wcc.Graph(id=self.ids("scatter"))],
)
]
+ self.control_div,
),
]
)
Expand Down Expand Up @@ -293,7 +306,7 @@ def render_scatter(ens1, x_col, ens2, y_col, color, density, theme):
layout = theme_layout(
theme,
{
"margin": {"t": 20, "b": 50, "l": 200, "r": 200},
"margin": {"t": 20, "b": 100, "l": 100, "r": 10},
"bargap": 0.05,
"xaxis": {
"title": x_col,
Expand Down
19 changes: 10 additions & 9 deletions webviz_subsurface/plugins/_parameter_parallel_coordinates.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pandas as pd
from dash.dependencies import Input, Output
import dash_html_components as html
import dash_core_components as dcc
import webviz_core_components as wcc
from webviz_config import WebvizPluginABC
from webviz_config.common_cache import CACHE
Expand Down Expand Up @@ -80,14 +79,14 @@ def control_layout(self):
html.Div(
[
html.Span("Selected ensembles:", style={"font-weight": "bold"}),
dcc.Dropdown(
wcc.Select(
id=self.uuid("ensembles"),
options=[
{"label": ens, "value": ens} for ens in self.ensembles
],
clearable=False,
multi=True,
value=self.ensembles,
size=len(self.ensembles),
),
]
),
Expand All @@ -96,15 +95,16 @@ def control_layout(self):
html.Span(
"Selected parameters:", style={"font-weight": "bold"}
),
dcc.Dropdown(
wcc.Select(
id=self.uuid("parameters"),
style={"overflowX": "auto", "fontSize": "0.97rem"},
options=[
{"label": param, "value": param}
for param in self.parameters
],
clearable=False,
multi=True,
value=self.visual_parameters,
size=min(50, len(self.visual_parameters)),
),
]
),
Expand All @@ -114,12 +114,13 @@ def control_layout(self):
@property
def layout(self):
"""Main layout"""
return html.Div(
return wcc.FlexBox(
id=self.uuid("layout"),
style=self.set_grid_layout("1fr 4fr"),
children=[
self.control_layout,
html.Div(wcc.Graph(id=self.uuid("parcoords"),),),
html.Div(style={"flex": 1}, children=self.control_layout),
html.Div(
style={"flex": 3}, children=wcc.Graph(id=self.uuid("parcoords"),),
),
],
)

Expand Down
Loading

0 comments on commit 69e2fda

Please sign in to comment.