From 961cde579c93f22c3337b215e0fe566f843fd770 Mon Sep 17 00:00:00 2001 From: richradics Date: Mon, 10 Jul 2017 11:42:41 +0200 Subject: [PATCH] Add 'show/hide totals' option to pivot table vis --- superset/assets/javascripts/explore/stores/controls.jsx | 8 ++++++++ superset/assets/javascripts/explore/stores/visTypes.js | 2 +- superset/viz.py | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/superset/assets/javascripts/explore/stores/controls.jsx b/superset/assets/javascripts/explore/stores/controls.jsx index 794c9ee0cd9de..cbee620829be3 100644 --- a/superset/assets/javascripts/explore/stores/controls.jsx +++ b/superset/assets/javascripts/explore/stores/controls.jsx @@ -217,6 +217,14 @@ export const controls = { description: null, }, + pivot_margins: { + type: 'CheckboxControl', + label: 'Show totals', + renderTrigger: false, + default: true, + description: 'Display total row/column', + }, + show_markers: { type: 'CheckboxControl', label: 'Show Markers', diff --git a/superset/assets/javascripts/explore/stores/visTypes.js b/superset/assets/javascripts/explore/stores/visTypes.js index 85aeff6e59a61..38c6771347127 100644 --- a/superset/assets/javascripts/explore/stores/visTypes.js +++ b/superset/assets/javascripts/explore/stores/visTypes.js @@ -338,7 +338,7 @@ const visTypes = { controlSetRows: [ ['groupby', 'columns'], ['metrics', 'pandas_aggfunc'], - ['number_format'], + ['number_format', 'pivot_margins'], ], }, ], diff --git a/superset/viz.py b/superset/viz.py index a8cf3bfe5b605..361571e74401d 100755 --- a/superset/viz.py +++ b/superset/viz.py @@ -394,7 +394,7 @@ def get_data(self, df): columns=self.form_data.get('columns'), values=self.form_data.get('metrics'), aggfunc=self.form_data.get('pandas_aggfunc'), - margins=True, + margins=self.form_data.get('pivot_margins'), ) return dict( columns=list(df.columns),