diff --git a/draftlogs/8139_fix.md b/draftlogs/8139_fix.md new file mode 100644 index 00000000000..792e8ca201b --- /dev/null +++ b/draftlogs/8139_fix.md @@ -0,0 +1 @@ + - Fix funnel `percentTotal` text formatting to display formatted percentages instead of raw ratios [[#8139](https://github.com/plotly/plotly.js/pull/8139)], with thanks to @ORITOMI for the contribution! diff --git a/src/traces/bar/plot.js b/src/traces/bar/plot.js index 60f7154cf73..2612f9a7614 100644 --- a/src/traces/bar/plot.js +++ b/src/traces/bar/plot.js @@ -1107,7 +1107,7 @@ function calcTexttemplate(fullLayout, cd, index, xa, ya) { obj.percentPrevious = cdi.difR; obj.percentPreviousLabel = Lib.formatPercent(cdi.difR); obj.percentTotal = cdi.sumR; - obj.percenTotalLabel = Lib.formatPercent(cdi.sumR); + obj.percentTotalLabel = Lib.formatPercent(cdi.sumR); } var customdata = Lib.castOption(trace, cdi.i, 'customdata'); diff --git a/test/jasmine/tests/funnel_test.js b/test/jasmine/tests/funnel_test.js index 0506aba9da3..e7c21a33a9d 100644 --- a/test/jasmine/tests/funnel_test.js +++ b/test/jasmine/tests/funnel_test.js @@ -1271,6 +1271,7 @@ describe('A funnel plot', function() { textinfo: 'value+percent initial+percent previous+percent total', }], 'text.bartext', [ ['txt: %{value}', ['txt: 3', 'txt: 2', 'txt: 1']], + ['%{percentTotal}', ['50%', '33%', '17%']], ['%{value}-%{percentInitial}-%{percentPrevious}-%{percentTotal:0.3f}', ['3-100%-100%-0.500', '2-67%-67%-0.333', '1-33%-50%-0.167']] ]); });