Skip to content

Commit

Permalink
handle percentage case for tooltips (#2570)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alanna Scott authored Apr 11, 2017
1 parent 412634c commit ab0bc5a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions superset/assets/visualizations/nvd3_vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ function nvd3Vis(slice, payload) {
chart.labelThreshold(0.05) // Configure the minimum slice size for labels to show up
.labelType(fd.pie_label_type);
chart.cornerRadius(true);

if (fd.pie_label_type === 'percent') {
let total = 0;
payload.data.forEach((d) => { total += d.y; });
chart.tooltip.valueFormatter(d => `${((d / total) * 100).toFixed()}%`);
}

break;

case 'column':
Expand Down

0 comments on commit ab0bc5a

Please sign in to comment.