This is an automated email from the ASF dual-hosted git repository.
erikrit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new 865a909 FilterBox,BigNumber,WorldMap: Handle empty results (#9671)
865a909 is described below
commit 865a9096906c5c564d86c422fc3bd35e9a3444bd
Author: Luca Toscano <[email protected]>
AuthorDate: Mon May 4 20:03:23 2020 +0200
FilterBox,BigNumber,WorldMap: Handle empty results (#9671)
This change avoids Pandas errors to pop up in chart when no data
is returned (confusing users). In this way a nicer
"No Results etc.." is returned.
---
superset/viz.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/superset/viz.py b/superset/viz.py
index c167329..1a176f4 100644
--- a/superset/viz.py
+++ b/superset/viz.py
@@ -1143,6 +1143,9 @@ class BigNumberViz(BaseViz):
return d
def get_data(self, df: pd.DataFrame) -> VizData:
+ if df.empty:
+ return None
+
df = df.pivot_table(
index=DTTM_ALIAS,
columns=[],
@@ -1878,6 +1881,9 @@ class WorldMapViz(BaseViz):
return qry
def get_data(self, df: pd.DataFrame) -> VizData:
+ if df.empty:
+ return None
+
from superset.examples import countries
fd = self.form_data
@@ -1952,7 +1958,7 @@ class FilterBoxViz(BaseViz):
col = flt.get("column")
metric = flt.get("metric")
df = self.dataframes.get(col)
- if df is not None:
+ if df is not None and not df.empty:
if metric:
df = df.sort_values(
utils.get_metric_name(metric), ascending=flt.get("asc")
@@ -1967,6 +1973,8 @@ class FilterBoxViz(BaseViz):
{"id": row[0], "text": row[0]}
for row in df.itertuples(index=False)
]
+ if not d:
+ return None
return d