You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by vi...@apache.org on 2020/01/04 19:52:18 UTC

[incubator-superset] 17/22: fix: default missing values to zero on area chart (#8678)

This is an automated email from the ASF dual-hosted git repository.

villebro pushed a commit to branch 0.35
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git

commit 8e47b1120e279a996953bbbedbf7ee0531ca698f
Author: Ville Brofeldt <33...@users.noreply.github.com>
AuthorDate: Mon Dec 2 18:53:21 2019 +0200

    fix: default missing values to zero on area chart (#8678)
    
    * Add fill_value to area chart pivot
    
    * Only fill for area chart
    
    * Linting
---
 superset/viz.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/superset/viz.py b/superset/viz.py
index 0d11a9d..d1c4ddd 100644
--- a/superset/viz.py
+++ b/superset/viz.py
@@ -1085,6 +1085,7 @@ class NVD3TimeSeriesViz(NVD3Viz):
     verbose_name = _("Time Series - Line Chart")
     sort_series = False
     is_timeseries = True
+    pivot_fill_value: Optional[int] = None
 
     def to_series(self, df, classed="", title_suffix=""):
         cols = []
@@ -1157,7 +1158,10 @@ class NVD3TimeSeriesViz(NVD3Viz):
             )
         else:
             df = df.pivot_table(
-                index=DTTM_ALIAS, columns=fd.get("groupby"), values=self.metric_labels
+                index=DTTM_ALIAS,
+                columns=fd.get("groupby"),
+                values=self.metric_labels,
+                fill_value=self.pivot_fill_value,
             )
 
         rule = fd.get("resample_rule")
@@ -1443,6 +1447,7 @@ class NVD3TimeSeriesStackedViz(NVD3TimeSeriesViz):
     viz_type = "area"
     verbose_name = _("Time Series - Stacked")
     sort_series = True
+    pivot_fill_value = 0
 
 
 class DistributionPieViz(NVD3Viz):