Skip to content

Commit

Permalink
fix: default missing values to zero on area chart (apache#8678)
Browse files Browse the repository at this point in the history
* Add fill_value to area chart pivot

* Only fill for area chart

* Linting
  • Loading branch information
villebro committed Jan 2, 2020
1 parent a9a424f commit b2a9ecc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -1157,7 +1158,10 @@ def process_data(self, df, aggregate=False):
)
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")
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit b2a9ecc

Please sign in to comment.