This is an automated email from the ASF dual-hosted git repository.
villebro 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 5e6662a fix: suburst chart when secondary metric is defined (#9343)
5e6662a is described below
commit 5e6662ab12e4b5d3c392e8cc1bfd37afc5b20b63
Author: Ville Brofeldt <[email protected]>
AuthorDate: Sun Mar 22 22:31:05 2020 +0200
fix: suburst chart when secondary metric is defined (#9343)
---
superset/viz.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/superset/viz.py b/superset/viz.py
index afdfa9f..b121133 100644
--- a/superset/viz.py
+++ b/superset/viz.py
@@ -1673,12 +1673,15 @@ class SunburstViz(BaseViz):
def get_data(self, df: pd.DataFrame) -> VizData:
fd = self.form_data
cols = fd.get("groupby") or []
+ cols.extend(["m1", "m2"])
metric = utils.get_metric_name(fd.get("metric"))
secondary_metric = utils.get_metric_name(fd.get("secondary_metric"))
if metric == secondary_metric or secondary_metric is None:
df.rename(columns={df.columns[-1]: "m1"}, inplace=True)
df["m2"] = df["m1"]
- cols.extend(["m1", "m2"])
+ else:
+ df.rename(columns={df.columns[-2]: "m1"}, inplace=True)
+ df.rename(columns={df.columns[-1]: "m2"}, inplace=True)
# Re-order the columns as the query result set column ordering may
differ from
# that listed in the hierarchy.