From 94d20168dab4b85fc3f2d2172a2ae899de5aa2ba Mon Sep 17 00:00:00 2001 From: vera-liu Date: Wed, 11 Jan 2017 10:07:30 -0800 Subject: [PATCH] Change fields for dual_line to match with new SelectField structure (#1932) --- superset/assets/javascripts/explorev2/stores/fields.js | 6 +++++- superset/viz.py | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) 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: