Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[explore] forcing .1% number format when using 'Period Ratio' #4774

Merged
merged 1 commit into from
Apr 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions superset/assets/javascripts/explore/components/ControlHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const propTypes = {
hovered: PropTypes.bool,
tooltipOnClick: PropTypes.func,
warning: PropTypes.string,
danger: PropTypes.string,
};

const defaultProps = {
Expand Down Expand Up @@ -83,6 +84,19 @@ export default class ControlHeader extends React.Component {
overlay={
<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -31,6 +32,7 @@ const defaultProps = {
choices: [],
clearable: true,
description: null,
disabled: false,
freeForm: false,
isLoading: false,
label: null,
Expand Down Expand Up @@ -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>
Expand Down
5 changes: 5 additions & 0 deletions superset/assets/javascripts/explore/stores/controls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,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: {
Expand Down
7 changes: 6 additions & 1 deletion superset/assets/visualizations/nvd3_vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,12 @@ 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);
Expand Down