From f554aa4496f7219fa641ab61a441ef90a47703cd Mon Sep 17 00:00:00 2001 From: alexmorev Date: Tue, 26 Nov 2024 19:38:29 +0200 Subject: [PATCH] SXLLCAXAAD-9 / passing tests --- ckanext/charts/chart_builders/plotly.py | 7 ++++--- ckanext/charts/tests/test_builders.py | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ckanext/charts/chart_builders/plotly.py b/ckanext/charts/chart_builders/plotly.py index 8ad1ace..2ed89c2 100644 --- a/ckanext/charts/chart_builders/plotly.py +++ b/ckanext/charts/chart_builders/plotly.py @@ -246,10 +246,11 @@ def build_scatter_chart(self) -> Any: if self.settings.get("skip_null_values"): self.df = self.df.loc[self.df[self.settings["y"]] != 0] - if self.df[self.settings["size"]].dtype not in ["int64", "float64"]: + size_column = self.df[self.settings.get("size", self.df.columns[0])] + is_numeric = pd.api.types.is_numeric_dtype(size_column) + if not is_numeric: raise exception.ChartBuildError( - """The 'size' source should be a field of positive integer - or float type.""" + "The 'Size' source should be a field of numeric type.", ) fig = px.scatter( diff --git a/ckanext/charts/tests/test_builders.py b/ckanext/charts/tests/test_builders.py index 640f1e7..d52f247 100644 --- a/ckanext/charts/tests/test_builders.py +++ b/ckanext/charts/tests/test_builders.py @@ -85,6 +85,8 @@ def test_build_scatter(self, data_frame): "engine": "plotly", "x": "name", "y": "age", + "size": "age", + "size_max": 100, }, data_frame, )