diff --git a/superset/assets/javascripts/explorev2/stores/fields.js b/superset/assets/javascripts/explorev2/stores/fields.js index f8c7fcb36cb43..14ea9a70d7611 100644 --- a/superset/assets/javascripts/explorev2/stores/fields.js +++ b/superset/assets/javascripts/explorev2/stores/fields.js @@ -85,6 +85,9 @@ export const fields = { choices: [], default: [], description: 'Choose a metric for right axis', + mapStateToProps: (state) => ({ + choices: (state.datasource) ? state.datasource.metrics_combo : [], + }), }, stacked_style: { @@ -711,7 +714,8 @@ export const fields = { }, y_axis_2_format: { - type: 'FreeFormSelectField', + type: 'SelectField', + freeForm: true, label: 'Right axis format', default: '.3s', choices: D3_TIME_FORMAT_OPTIONS, diff --git a/superset/viz.py b/superset/viz.py index b4270580f8c89..532e629ecd960 100755 --- a/superset/viz.py +++ b/superset/viz.py @@ -1328,6 +1328,13 @@ def get_df(self, query_obj=None): return df + def query_obj(self): + d = super(NVD3DualLineViz, self).query_obj() + if self.form_data.get('metric') == self.form_data.get('metric_2'): + raise Exception("Please choose different metrics" + " on left and right axis") + return d + def to_series(self, df, classed=''): cols = [] for col in df.columns: