From 05b2b42633941b6cc7a8018423e92ce7fe286720 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Mon, 2 Oct 2017 10:24:13 -0700 Subject: [PATCH] [nvd3] fix single metric showing up in legend --- superset/viz.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/superset/viz.py b/superset/viz.py index 75da12932851a..22d2ea9ec3776 100644 --- a/superset/viz.py +++ b/superset/viz.py @@ -884,9 +884,15 @@ def to_series(self, df, classed='', title_suffix=''): if df[name].dtype.kind not in "biufc": continue series_title = name + if ( + isinstance(series_title, (list, tuple)) and + len(series_title) > 1 and + len(self.metrics) == 1): + # Removing metric from series name if only one metric + series_title = series_title[1:] if isinstance(series_title, string_types): series_title += title_suffix - elif title_suffix and isinstance(series_title, list): + elif title_suffix and isinstance(series_title, (list, tuple)): series_title.append(title_suffix) d = {