This is an automated email from the ASF dual-hosted git repository. maximebeauchemin pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push: new 9bbe50f [explore] forcing .1% number format when using 'Period Ratio' (#4774) 9bbe50f is described below commit 9bbe50f2f690b2084863df3e87a06f8550117542 Author: Maxime Beauchemin <maximebeauche...@gmail.com> AuthorDate: Mon Apr 9 14:02:43 2018 -0700 [explore] forcing .1% number format when using 'Period Ratio' (#4774) --- .../javascripts/explore/components/ControlHeader.jsx | 14 ++++++++++++++ .../explore/components/controls/SelectControl.jsx | 3 +++ superset/assets/javascripts/explore/stores/controls.jsx | 5 +++++ superset/assets/visualizations/nvd3_vis.js | 7 ++++++- 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/superset/assets/javascripts/explore/components/ControlHeader.jsx b/superset/assets/javascripts/explore/components/ControlHeader.jsx index ce00a9d..3dd884c 100644 --- a/superset/assets/javascripts/explore/components/ControlHeader.jsx +++ b/superset/assets/javascripts/explore/components/ControlHeader.jsx @@ -15,6 +15,7 @@ const propTypes = { hovered: PropTypes.bool, tooltipOnClick: PropTypes.func, warning: PropTypes.string, + danger: PropTypes.string, }; const defaultProps = { @@ -84,6 +85,19 @@ export default class ControlHeader extends React.Component { <Tooltip id={'error-tooltip'}>{this.props.warning}</Tooltip> } > + <i className="fa fa-exclamation-circle text-warning" /> + </OverlayTrigger> + {' '} + </span> + } + {(this.props.danger) && + <span> + <OverlayTrigger + placement="top" + overlay={ + <Tooltip id={'error-tooltip'}>{this.props.danger}</Tooltip> + } + > <i className="fa fa-exclamation-circle text-danger" /> </OverlayTrigger> {' '} diff --git a/superset/assets/javascripts/explore/components/controls/SelectControl.jsx b/superset/assets/javascripts/explore/components/controls/SelectControl.jsx index 8b78fc0..16cb95e 100644 --- a/superset/assets/javascripts/explore/components/controls/SelectControl.jsx +++ b/superset/assets/javascripts/explore/components/controls/SelectControl.jsx @@ -11,6 +11,7 @@ const propTypes = { choices: PropTypes.array, clearable: PropTypes.bool, description: PropTypes.string, + disabled: PropTypes.bool, freeForm: PropTypes.bool, isLoading: PropTypes.bool, label: PropTypes.string, @@ -31,6 +32,7 @@ const defaultProps = { choices: [], clearable: true, description: null, + disabled: false, freeForm: false, isLoading: false, label: null, @@ -123,6 +125,7 @@ export default class SelectControl extends React.PureComponent { optionRenderer: VirtualizedRendererWrap(this.props.optionRenderer), valueRenderer: this.props.valueRenderer, selectComponent: this.props.freeForm ? Creatable : Select, + disabled: this.props.disabled, }; return ( <div> diff --git a/superset/assets/javascripts/explore/stores/controls.jsx b/superset/assets/javascripts/explore/stores/controls.jsx index b675b03..7e82e07 100644 --- a/superset/assets/javascripts/explore/stores/controls.jsx +++ b/superset/assets/javascripts/explore/stores/controls.jsx @@ -1199,6 +1199,11 @@ export const controls = { default: '.3s', choices: D3_FORMAT_OPTIONS, description: D3_FORMAT_DOCS, + mapStateToProps: state => ({ + warning: state.controls && state.controls.num_period_compare.value !== '' ? + t('When `Period Ratio` is set, the Y Axis Format is forced to `.1%`') : null, + disabled: state.controls && state.controls.num_period_compare.value !== '', + }), }, y_axis_2_format: { diff --git a/superset/assets/visualizations/nvd3_vis.js b/superset/assets/visualizations/nvd3_vis.js index b479c68..5887d79 100644 --- a/superset/assets/visualizations/nvd3_vis.js +++ b/superset/assets/visualizations/nvd3_vis.js @@ -379,7 +379,12 @@ export default function nvd3Vis(slice, payload) { const yAxisFormatter = d3FormatPreset(fd.y_axis_format); if (chart.yAxis && chart.yAxis.tickFormat) { - chart.yAxis.tickFormat(yAxisFormatter); + if (fd.num_period_compare) { + // When computing a "Period Ratio", we force a percentage format + chart.yAxis.tickFormat(d3.format('.1%')); + } else { + chart.yAxis.tickFormat(yAxisFormatter); + } } if (chart.y2Axis && chart.y2Axis.tickFormat) { chart.y2Axis.tickFormat(yAxisFormatter); -- To stop receiving notification emails like this one, please contact maximebeauche...@apache.org.