Skip to content

Commit

Permalink
Handling comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed May 31, 2017
1 parent 10fdad5 commit 6e80e89
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
Expand Up @@ -51,10 +51,10 @@ export default class BoundsControl extends React.Component {
const mm = this.state.minMax;
const errors = [];
if (mm[0] && isNaN(mm[0])) {
errors.push('`From` value should be numeric or empty');
errors.push('`Min` value should be numeric or empty');
}
if (mm[1] && isNaN(mm[1])) {
errors.push('`To` value should be numeric or empty');
errors.push('`Max` value should be numeric or empty');
}
if (errors.length === 0) {
this.props.onChange([parseFloat(mm[0]), parseFloat(mm[1])], errors);
Expand All @@ -66,20 +66,20 @@ export default class BoundsControl extends React.Component {
return (
<div>
<ControlHeader {...this.props} />
<FormGroup controlId="formInlineName" bsSize="small">
<FormGroup bsSize="small">
<Row>
<Col xs={6} key="from">
<Col xs={6}>
<FormControl
type="text"
placeholder="From"
placeholder="Min"
onChange={this.onMinChange}
value={this.state.minMax[0]}
/>
</Col>
<Col xs={6} key="to">
<Col xs={6}>
<FormControl
type="text"
placeholder="To"
placeholder="Max"
onChange={this.onMaxChange}
value={this.state.minMax[1]}
/>
Expand Down
15 changes: 11 additions & 4 deletions superset/assets/javascripts/explore/stores/store.js
Expand Up @@ -19,6 +19,16 @@ export function getControlNames(vizType, datasourceType) {
return controlNames;
}

function handleDeprecatedControls(formData) {
// Reacffectation / handling of deprecated controls
/* eslint-disable no-param-reassign */

// y_axis_zero was a boolean forcing 0 to be part of the Y Axis
if (formData.y_axis_zero) {
formData.y_axis_bounds = [0, null];
}
}

export function getControlsState(state, form_data) {
/*
* Gets a new controls object to put in the state. The controls object
Expand All @@ -32,10 +42,7 @@ export function getControlsState(state, form_data) {
const formData = Object.assign({}, form_data);
const vizType = formData.viz_type || 'table';

// Control reacffectation for deprecation
if (formData.y_axis_zero) {
formData.y_axis_bounds = [0, null];
}
handleDeprecatedControls(formData);

const controlNames = getControlNames(vizType, state.datasource.type);

Expand Down
3 changes: 1 addition & 2 deletions superset/assets/visualizations/nvd3_vis.js
Expand Up @@ -306,8 +306,7 @@ function nvd3Vis(slice, payload) {
if ((vizType === 'line' || vizType === 'area') && fd.rich_tooltip) {
chart.useInteractiveGuideline(true);
}
if (
chart.forceY &&
if (chart.forceY &&
fd.y_axis_bounds &&
(fd.y_axis_bounds[0] !== null || fd.y_axis_bounds[1] !== null)) {
chart.forceY(fd.y_axis_bounds);
Expand Down

0 comments on commit 6e80e89

Please sign in to comment.