Skip to content

Commit

Permalink
move visualisation option to selection sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
tnatt committed Mar 14, 2024
1 parent b03ce78 commit e0cb52a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
from dash import Input, Output, State, callback, callback_context, dash_table, html
from dash import Input, Output, State, callback, dash_table, html
from dash.exceptions import PreventUpdate

from webviz_subsurface._figures import create_figure
Expand Down Expand Up @@ -32,59 +32,41 @@ def comparison_controllers(
@callback(
Output({"id": get_uuid("main-src-comp"), "wrapper": "table"}, "children"),
Input(get_uuid("selections"), "data"),
Input({"id": get_uuid("main-src-comp"), "element": "display-option"}, "value"),
State(get_uuid("page-selected"), "data"),
)
def _update_page_src_comp(
selections: dict,
display_option: str,
page_selected: str,
) -> html.Div:
ctx = callback_context.triggered[0]

def _update_page_src_comp(selections: dict, page_selected: str) -> html.Div:
if page_selected != "src-comp":
raise PreventUpdate

selections = selections[page_selected]
if not "display-option" in ctx["prop_id"]:
if not selections["update"]:
raise PreventUpdate
if not selections["update"]:
raise PreventUpdate

return comparison_callback(
compare_on="SOURCE",
volumemodel=volumemodel,
selections=selections,
display_option=display_option,
)

@callback(
Output({"id": get_uuid("main-ens-comp"), "wrapper": "table"}, "children"),
Input(get_uuid("selections"), "data"),
Input({"id": get_uuid("main-ens-comp"), "element": "display-option"}, "value"),
State(get_uuid("page-selected"), "data"),
)
def _update_page_ens_comp(
selections: dict,
display_option: str,
page_selected: str,
) -> html.Div:
ctx = callback_context.triggered[0]

def _update_page_ens_comp(selections: dict, page_selected: str) -> html.Div:
if page_selected != "ens-comp":
raise PreventUpdate

selections = selections[page_selected]
if not "display-option" in ctx["prop_id"]:
if not selections["update"]:
raise PreventUpdate
if not selections["update"]:
raise PreventUpdate

return comparison_callback(
compare_on="SENSNAME_CASE"
if selections["compare_on"] == "Sensitivity"
else "ENSEMBLE",
volumemodel=volumemodel,
selections=selections,
display_option=display_option,
)


Expand All @@ -93,11 +75,12 @@ def comparison_callback(
compare_on: str,
volumemodel: InplaceVolumesModel,
selections: dict,
display_option: str,
) -> html.Div:
if selections["value1"] == selections["value2"]:
return html.Div("Comparison between equal data")

display_option = selections["display_option"]

# Handle None in highlight criteria input
for key in ["Accept value", "Ignore <"]:
selections[key] = selections[key] if selections[key] is not None else 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,7 @@


def comparison_main_layout(uuid: str) -> html.Div:
return [
html.Div(
style={"margin-bottom": "20px"},
children=wcc.RadioItems(
inline=True,
id={"id": uuid, "element": "display-option"},
options=[
{
"label": "QC plots",
"value": "plots",
},
{
"label": "Difference table for selected response",
"value": "single-response table",
},
{
"label": "Difference table for multiple responses",
"value": "multi-response table",
},
{
"label": "Volume change analysis plot (waterfall)",
"value": "waterfall plot",
},
],
value="plots",
),
),
html.Div(id={"id": uuid, "wrapper": "table"}),
]
return html.Div(id={"id": uuid, "wrapper": "table"})


def comparison_qc_plots_layout(
Expand Down Expand Up @@ -119,7 +91,7 @@ def waterfall_plot_layout(
wcc.FlexColumn(
children=[
html.Div(
"Note: If multiple plots, the plots are order by "
"Note: If multiple plots, the plots are ordered by "
"the largest absolute difference in percent."
),
html.Div(
Expand Down Expand Up @@ -182,8 +154,37 @@ def comparison_selections(
uuid: str, volumemodel: InplaceVolumesModel, tab: str, compare_on: str
) -> html.Div:
options = comparison_options(compare_on, volumemodel)

return html.Div(
children=[
wcc.Selectors(
label="VISUALIZATION",
open_details=True,
children=[
wcc.RadioItems(
id={"id": uuid, "tab": tab, "selector": "display_option"},
options=[
{
"label": "QC plots",
"value": "plots",
},
{
"label": "Difference table for selected response",
"value": "single-response table",
},
{
"label": "Difference table for multiple responses",
"value": "multi-response table",
},
{
"label": "Volume change analysis plot (waterfall)",
"value": "waterfall plot",
},
],
value="plots",
),
],
),
wcc.Selectors(
label="CONTROLS",
open_details=True,
Expand Down

0 comments on commit e0cb52a

Please sign in to comment.