Skip to content

Commit

Permalink
Merge pull request #22 from DataShades/SXLLCAXAAD-9
Browse files Browse the repository at this point in the history
SXLLCAXAAD-9 / passing tests
  • Loading branch information
alexmorev authored Nov 26, 2024
2 parents 569112e + 756465e commit 92d609b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 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 @@ -241,10 +241,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
3 changes: 1 addition & 2 deletions ckanext/charts/tests/test_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ def test_build_scatter(self, data_frame):
"x": "name",
"y": "age",
"size": "age",
"size_max": 10

"size_max": 100,
},
data_frame,
)
Expand Down

0 comments on commit 92d609b

Please sign in to comment.