Skip to content

Commit

Permalink
Change fields for dual_line to match with new SelectField structure (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
vera-liu authored Jan 11, 2017
1 parent 2d866e3 commit 94d2016
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion superset/assets/javascripts/explorev2/stores/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 94d2016

Please sign in to comment.