Skip to content

Commit

Permalink
Fixed bug in callback so that only layout is updated if data is uncha…
Browse files Browse the repository at this point in the history
…nged
  • Loading branch information
Øyvind Lind-Johansen committed Sep 13, 2022
1 parent 00ed1b9 commit e78f6ad
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion webviz_subsurface/plugins/_well_analysis/_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def tour_steps(self) -> List[dict]:
{
"id": self.view(self.Ids.WELL_OVERVIEW)
.view_element(WellOverviewView.Ids.VIEW_ELEMENT)
.component_unique_id(WellOverviewViewElement.Ids.CHART),
.component_unique_id(WellOverviewViewElement.Ids.GRAPH),
"content": "Shows production split on well for the various chart types",
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,9 @@ def set_callbacks(self) -> None:
@callback(
Output(
self.view_element(self.Ids.VIEW_ELEMENT)
.component_unique_id(WellOverviewViewElement.Ids.CHART)
.component_unique_id(WellOverviewViewElement.Ids.GRAPH)
.to_string(),
"children",
"figure",
),
Input(
self.settings_group(self.Ids.SETTINGS)
Expand Down Expand Up @@ -303,7 +303,7 @@ def set_callbacks(self) -> None:
),
State(
self.view_element(self.Ids.VIEW_ELEMENT)
.component_unique_id(WellOverviewViewElement.Ids.CHART)
.component_unique_id(WellOverviewViewElement.Ids.GRAPH)
.to_string(),
"figure",
),
Expand Down Expand Up @@ -356,7 +356,7 @@ def _update_graph(
datetime.datetime.strptime(prod_after_date, "%Y-%m-%d")
if prod_after_date is not None
else None,
ChartType[charttype_selected],
ChartType(charttype_selected),
wells_selected,
self._theme,
)
Expand All @@ -369,9 +369,4 @@ def _update_graph(
prod_after_date,
)

return [
wcc.Graph(
style={"height": "87vh"},
figure=fig_dict,
),
]
return fig_dict
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import webviz_core_components as wcc
from dash import html
from webviz_config.utils import StrEnum
from webviz_config.webviz_plugin_subclasses import ViewElementABC


class WellOverviewViewElement(ViewElementABC):
class Ids(StrEnum):
CHART = "chart"
GRAPH = "graph"

def __init__(self) -> None:
super().__init__()

def inner_layout(self) -> html.Div:
return html.Div(
id=self.register_component_unique_id(WellOverviewViewElement.Ids.CHART)
children=wcc.Graph(
id=self.register_component_unique_id(WellOverviewViewElement.Ids.GRAPH),
style={"height": "87vh"},
),
)

0 comments on commit e78f6ad

Please sign in to comment.