Skip to content

Commit

Permalink
[bugfix] metrics issue in 'Periodicity Pivot' (apache#5931)
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch authored and betodealmeida committed Oct 12, 2018
1 parent 1e01e4a commit b947958
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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}
Expand Down
3 changes: 3 additions & 0 deletions superset/assets/src/explore/visTypes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,9 @@ export const visTypes = {
choices: D3_TIME_FORMAT_OPTIONS,
default: 'smart_date',
},
metric: {
clearable: false,
},
},
},

Expand Down
4 changes: 2 additions & 2 deletions superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit b947958

Please sign in to comment.