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

[axis formatting] Override the valueformat to be percentage when contribution is selected #4866

Merged
Merged
Changes from 2 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
7 changes: 6 additions & 1 deletion superset/assets/src/visualizations/nvd3_vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export default function nvd3Vis(slice, payload) {

const vizType = fd.viz_type;
const formatter = d3.format('.3s');
const percentageFormatter = d3.format('.1%');
const reduceXTicks = fd.reduce_x_ticks || false;
let stacked = false;
let row;
Expand Down Expand Up @@ -252,7 +253,7 @@ export default function nvd3Vis(slice, payload) {
case 'pie':
chart = nv.models.pieChart();
colorKey = 'x';
chart.valueFormat(f);
chart.valueFormat(formatter);
if (fd.donut) {
chart.donut(true);
}
Expand Down Expand Up @@ -332,6 +333,10 @@ export default function nvd3Vis(slice, payload) {
throw new Error('Unrecognized visualization for nvd3' + vizType);
}

if (fd.contribution) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out line 393 where you could handle this.

chart.valueFormat(percentageFormatter);
}

if (chart.xAxis && chart.xAxis.staggerLabels) {
chart.xAxis.staggerLabels(staggerLabels);
}
Expand Down