Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename clientside functions #661

Merged
merged 1 commit into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [UNRELEASED] - YYYY-MM-DD

### Changed
- [#661](https://github.com/equinor/webviz-subsurface/pull/661) - Moved existing clientside function to a general dash_clientside file to facilitate adding more functions later on.

## [0.2.3] - 2021-06-07

### Changed
Expand Down
13 changes: 13 additions & 0 deletions webviz_subsurface/_assets/js/clientside_functions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
window.dash_clientside = Object.assign({}, window.dash_clientside, {
clientside: {
set_dcc_figure: function (layout, data) {
/*
Can be used in a dash callback to update
the `figure` prop on a dcc.Graph component,
e.g. to update the `layout` clientside without
sending the `data` from the backend.
*/
return { data: data, layout: layout };
},
},
});
7 changes: 0 additions & 7 deletions webviz_subsurface/_assets/js/update_plotly_figure.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def _update_plot_layout(initial_layout: dict, update_layout: dict) -> Dict:
return fig["layout"]

app.clientside_callback(
ClientsideFunction(namespace="clientside", function_name="update_figure"),
ClientsideFunction(namespace="clientside", function_name="set_dcc_figure"),
Output(get_uuid("graph"), "figure"),
Input(
{"id": get_uuid("clientside"), "plotly_attribute": "plotly_layout"}, "data"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def __init__(
Path(webviz_subsurface.__file__).parent
/ "_assets"
/ "js"
/ "update_plotly_figure.js"
/ "clientside_functions.js"
)

self._colors: Dict = unique_colors(self._ensemble_names, webviz_settings.theme)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def _store_intersection_layout(
# Store intersection data and layout to the plotly figure
# Done clientside for performance
app.clientside_callback(
ClientsideFunction(namespace="clientside", function_name="update_figure"),
ClientsideFunction(namespace="clientside", function_name="set_dcc_figure"),
Output(get_uuid("intersection-graph"), "figure"),
Input(get_uuid("intersection-graph-layout"), "data"),
State(get_uuid("intersection-graph-data"), "data"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def __init__(
Path(webviz_subsurface.__file__).parent
/ "_assets"
/ "js"
/ "update_plotly_figure.js"
/ "clientside_functions.js"
)
self._calculate_percentiles = calculate_percentiles
self._wellfolder = wellfolder
Expand Down