From f94bda01b43d0b50ca9297cb3facbc08ac7c132b Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Thu, 20 Sep 2018 21:42:40 -0700 Subject: [PATCH] [bugfix] metrics issue in 'Periodicity Pivot' (#5931) --- .../assets/src/explore/components/controls/MetricsControl.jsx | 4 +++- superset/assets/src/explore/visTypes.jsx | 3 +++ superset/viz.py | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/superset/assets/src/explore/components/controls/MetricsControl.jsx b/superset/assets/src/explore/components/controls/MetricsControl.jsx index 0b2d14ca93974..40f73da820527 100644 --- a/superset/assets/src/explore/components/controls/MetricsControl.jsx +++ b/superset/assets/src/explore/components/controls/MetricsControl.jsx @@ -27,11 +27,13 @@ const propTypes = { columns: PropTypes.arrayOf(columnType), savedMetrics: PropTypes.arrayOf(savedMetricType), multi: PropTypes.bool, + clearable: PropTypes.bool, datasourceType: PropTypes.string, }; const defaultProps = { onChange: () => {}, + clearable: true, }; function isDictionaryForAdhocMetric(value) { @@ -250,7 +252,7 @@ export default class MetricsControl extends React.PureComponent { value={this.props.multi ? this.state.value : this.state.value[0]} labelKey="label" valueKey="optionName" - clearable + clearable={this.props.clearable} closeOnSelect onChange={this.onChange} optionRenderer={this.optionRenderer} diff --git a/superset/assets/src/explore/visTypes.jsx b/superset/assets/src/explore/visTypes.jsx index 936da0eb80049..8037ce4eee5aa 100644 --- a/superset/assets/src/explore/visTypes.jsx +++ b/superset/assets/src/explore/visTypes.jsx @@ -332,6 +332,9 @@ export const visTypes = { choices: D3_TIME_FORMAT_OPTIONS, default: 'smart_date', }, + metric: { + clearable: false, + }, }, }, diff --git a/superset/viz.py b/superset/viz.py index 679c4d80cc3c5..46cd158369a49 100644 --- a/superset/viz.py +++ b/superset/viz.py @@ -1133,12 +1133,12 @@ def process_data(self, df, aggregate=False): df = df.pivot_table( index=DTTM_ALIAS, columns=fd.get('groupby'), - values=utils.get_metric_names(fd.get('metrics'))) + values=self.metric_labels) else: df = df.pivot_table( index=DTTM_ALIAS, columns=fd.get('groupby'), - values=utils.get_metric_names(fd.get('metrics')), + values=self.metric_labels, fill_value=0, aggfunc=sum)