Skip to content

Commit

Permalink
SXLLCAXAAD-9 / passing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmorev committed Nov 26, 2024
1 parent b6289a2 commit f554aa4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ckanext/charts/chart_builders/plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions ckanext/charts/tests/test_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ def test_build_scatter(self, data_frame):
"engine": "plotly",
"x": "name",
"y": "age",
"size": "age",
"size_max": 100,
},
data_frame,
)
Expand Down

0 comments on commit f554aa4

Please sign in to comment.