betodealmeida closed pull request #5931: [bugfix] metrics issue in 'Periodicity 
Pivot'
URL: https://github.com/apache/incubator-superset/pull/5931
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/superset/assets/src/explore/components/controls/MetricsControl.jsx 
b/superset/assets/src/explore/components/controls/MetricsControl.jsx
index 0b2d14ca93..40f73da820 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 936da0eb80..8037ce4eee 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 d0158c0ea0..728d39a576 100644
--- a/superset/viz.py
+++ b/superset/viz.py
@@ -1122,12 +1122,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)
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to