From ad75a8439add5c022179cd6c1066d16eba195134 Mon Sep 17 00:00:00 2001 From: Rob Poll Date: Mon, 19 Oct 2020 16:08:28 +0200 Subject: [PATCH 1/8] pie chart plot type added to table_plotter --- webviz_config/generic_plugins/_table_plotter.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/webviz_config/generic_plugins/_table_plotter.py b/webviz_config/generic_plugins/_table_plotter.py index d4ac06e6..745a474b 100644 --- a/webviz_config/generic_plugins/_table_plotter.py +++ b/webviz_config/generic_plugins/_table_plotter.py @@ -96,6 +96,7 @@ def plots(self) -> dict: "histnorm", ], "bar": ["x", "y", "color", "facet_col", "barmode"], + "pie": ["values"], "scatter_3d": ["x", "y", "z", "size", "color"], "line": ["x", "y", "color", "line_group", "facet_col"], "line_3d": ["x", "y", "z", "color"], @@ -130,6 +131,12 @@ def plot_args(self) -> dict: "multi": False, "clearable": False, }, + "values":{ + "options": self.numeric_columns, + "value": self.plot_options.get("values", None), + "multi": False, + "clearable": False, + }, "size": { "options": self.numeric_columns, "value": self.plot_options.get("size", None), From a48b11f5d3243c047e714c77816fb07ef275f58d Mon Sep 17 00:00:00 2001 From: Rob Poll Date: Mon, 19 Oct 2020 16:10:51 +0200 Subject: [PATCH 2/8] pie chart plot type added to tableplotter --- webviz_config/generic_plugins/_table_plotter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webviz_config/generic_plugins/_table_plotter.py b/webviz_config/generic_plugins/_table_plotter.py index 745a474b..53949362 100644 --- a/webviz_config/generic_plugins/_table_plotter.py +++ b/webviz_config/generic_plugins/_table_plotter.py @@ -135,7 +135,7 @@ def plot_args(self) -> dict: "options": self.numeric_columns, "value": self.plot_options.get("values", None), "multi": False, - "clearable": False, + "clearable": True, }, "size": { "options": self.numeric_columns, From a9af00cef7a1ef01d8bfa45be76f524c5677962e Mon Sep 17 00:00:00 2001 From: Rob Poll Date: Mon, 19 Oct 2020 16:32:12 +0200 Subject: [PATCH 3/8] code formatted with black --- webviz_config/generic_plugins/_table_plotter.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/webviz_config/generic_plugins/_table_plotter.py b/webviz_config/generic_plugins/_table_plotter.py index 53949362..ff7685f5 100644 --- a/webviz_config/generic_plugins/_table_plotter.py +++ b/webviz_config/generic_plugins/_table_plotter.py @@ -131,7 +131,7 @@ def plot_args(self) -> dict: "multi": False, "clearable": False, }, - "values":{ + "values": { "options": self.numeric_columns, "value": self.plot_options.get("values", None), "multi": False, @@ -297,7 +297,8 @@ def plot_option_layout(self) -> List[html.Div]: dcc.Dropdown( id=self.uuid(f"dropdown-{key}"), clearable=arg["clearable"], - options=[{"label": i, "value": i} for i in arg["options"]], + options=[{"label": i, "value": i} + for i in arg["options"]], value=arg["value"], multi=arg["multi"], ), @@ -333,7 +334,8 @@ def layout(self) -> html.Div: id=self.uuid("graph-id"), style={"height": "80vh", "width": "60%"}, ), - html.Div(style={"width": "15%"}, children=self.filter_layout()), + html.Div(style={"width": "15%"}, + children=self.filter_layout()), ], ) ] @@ -389,15 +391,16 @@ def _update_output(*args: Any) -> tuple: data = self.data # Filter dataframe if filter columns are available if self.use_filter: - plot_inputs = args[1 : -len(self.filter_cols)] - filter_inputs = args[-len(self.filter_cols) :] + plot_inputs = args[1: -len(self.filter_cols)] + filter_inputs = args[-len(self.filter_cols):] data = filter_dataframe(data, self.filter_cols, filter_inputs) else: plot_inputs = args[1:] for name, plot_arg in zip(self.plot_args.keys(), plot_inputs): if plot_type in ["parallel_coordinates"] and name == "dimensions": # This plot type only accepts numerical data - plot_arg = [val for val in plot_arg if val in self.numeric_columns] + plot_arg = [ + val for val in plot_arg if val in self.numeric_columns] if name in self.plots[plot_type]: plotargs[name] = plot_arg div_style.append(self.style_options_div) From fdf7d98d0511c2c6c52dccae93fa37ee967d6f52 Mon Sep 17 00:00:00 2001 From: Rob Poll Date: Mon, 19 Oct 2020 16:35:30 +0200 Subject: [PATCH 4/8] tableplotter formatted with black --- webviz_config/generic_plugins/_table_plotter.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/webviz_config/generic_plugins/_table_plotter.py b/webviz_config/generic_plugins/_table_plotter.py index ff7685f5..198876ba 100644 --- a/webviz_config/generic_plugins/_table_plotter.py +++ b/webviz_config/generic_plugins/_table_plotter.py @@ -297,8 +297,7 @@ def plot_option_layout(self) -> List[html.Div]: dcc.Dropdown( id=self.uuid(f"dropdown-{key}"), clearable=arg["clearable"], - options=[{"label": i, "value": i} - for i in arg["options"]], + options=[{"label": i, "value": i} for i in arg["options"]], value=arg["value"], multi=arg["multi"], ), @@ -334,8 +333,7 @@ def layout(self) -> html.Div: id=self.uuid("graph-id"), style={"height": "80vh", "width": "60%"}, ), - html.Div(style={"width": "15%"}, - children=self.filter_layout()), + html.Div(style={"width": "15%"}, children=self.filter_layout()), ], ) ] @@ -391,16 +389,15 @@ def _update_output(*args: Any) -> tuple: data = self.data # Filter dataframe if filter columns are available if self.use_filter: - plot_inputs = args[1: -len(self.filter_cols)] - filter_inputs = args[-len(self.filter_cols):] + plot_inputs = args[1 : -len(self.filter_cols)] + filter_inputs = args[-len(self.filter_cols) :] data = filter_dataframe(data, self.filter_cols, filter_inputs) else: plot_inputs = args[1:] for name, plot_arg in zip(self.plot_args.keys(), plot_inputs): if plot_type in ["parallel_coordinates"] and name == "dimensions": # This plot type only accepts numerical data - plot_arg = [ - val for val in plot_arg if val in self.numeric_columns] + plot_arg = [val for val in plot_arg if val in self.numeric_columns] if name in self.plots[plot_type]: plotargs[name] = plot_arg div_style.append(self.style_options_div) From 90a0510a54eebca5745b6f4861339610f0f7bbf3 Mon Sep 17 00:00:00 2001 From: Rob Poll Date: Mon, 19 Oct 2020 18:55:25 +0200 Subject: [PATCH 5/8] added label to to piechart --- webviz_config/generic_plugins/_table_plotter.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/webviz_config/generic_plugins/_table_plotter.py b/webviz_config/generic_plugins/_table_plotter.py index 198876ba..ea4544e2 100644 --- a/webviz_config/generic_plugins/_table_plotter.py +++ b/webviz_config/generic_plugins/_table_plotter.py @@ -96,7 +96,7 @@ def plots(self) -> dict: "histnorm", ], "bar": ["x", "y", "color", "facet_col", "barmode"], - "pie": ["values"], + "pie": ["values", "names"], "scatter_3d": ["x", "y", "z", "size", "color"], "line": ["x", "y", "color", "line_group", "facet_col"], "line_3d": ["x", "y", "z", "color"], @@ -137,6 +137,18 @@ def plot_args(self) -> dict: "multi": False, "clearable": True, }, + "names": { + "options": self.columns, + "value": self.plot_options.get("names", self.columns[0]), + "multi": False, + "clearable": False, + }, + "labels": { + "options": self.columns, + "value": self.plot_options.get("labels", self.columns[0]), + "multi": False, + "clearable": True, + }, "size": { "options": self.numeric_columns, "value": self.plot_options.get("size", None), From b01e6125a2893aa1dfad7cf05092a97657490b5d Mon Sep 17 00:00:00 2001 From: Rob Poll Date: Tue, 20 Oct 2020 09:45:46 +0200 Subject: [PATCH 6/8] unused labels deleted, names fixed --- webviz_config/generic_plugins/_table_plotter.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/webviz_config/generic_plugins/_table_plotter.py b/webviz_config/generic_plugins/_table_plotter.py index ea4544e2..48107492 100644 --- a/webviz_config/generic_plugins/_table_plotter.py +++ b/webviz_config/generic_plugins/_table_plotter.py @@ -139,13 +139,7 @@ def plot_args(self) -> dict: }, "names": { "options": self.columns, - "value": self.plot_options.get("names", self.columns[0]), - "multi": False, - "clearable": False, - }, - "labels": { - "options": self.columns, - "value": self.plot_options.get("labels", self.columns[0]), + "value": self.plot_options.get("names", None), "multi": False, "clearable": True, }, From 0cccc9c942f922d5835641cdc6ecff8d2bc349fa Mon Sep 17 00:00:00 2001 From: robpoll <37448609+robpoll@users.noreply.github.com> Date: Wed, 21 Oct 2020 12:13:17 +0200 Subject: [PATCH 7/8] pie chart default value set to the first available numeric column Co-authored-by: Asgeir Nyvoll <47146384+asnyv@users.noreply.github.com> --- webviz_config/generic_plugins/_table_plotter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webviz_config/generic_plugins/_table_plotter.py b/webviz_config/generic_plugins/_table_plotter.py index 48107492..4d40db25 100644 --- a/webviz_config/generic_plugins/_table_plotter.py +++ b/webviz_config/generic_plugins/_table_plotter.py @@ -133,7 +133,7 @@ def plot_args(self) -> dict: }, "values": { "options": self.numeric_columns, - "value": self.plot_options.get("values", None), + "value": self.plot_options.get("values", self.numeric_columns[0]), "multi": False, "clearable": True, }, From 81b6a5243e65babb175ff866b71525ce21922600 Mon Sep 17 00:00:00 2001 From: Rob Poll Date: Wed, 21 Oct 2020 13:16:35 +0200 Subject: [PATCH 8/8] changelog updated; piechart option added to tableplotter --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d25d4561..edeb4f23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ shipped plugins install themselves through the `webviz_config_plugins` entrypoin ad-hoc plugins as this is costly to maintain. Also, the `module.PluginName` notation in configuration files can then in future be used fo distinguish between multiple plugin packages using the same plugin name. +- [#330](https://github.com/equinor/webviz-config/pull/330) - Pie chart plot type now +available in table plotter. ### Fixed - [#325](https://github.com/equinor/webviz-config/pull/325) - Support plugin projects