diff --git a/package-lock.json b/package-lock.json index c5de9f2764f..a68c53dbe6d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6772,9 +6772,9 @@ "dev": true }, "karma-jasmine-spec-tags": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/karma-jasmine-spec-tags/-/karma-jasmine-spec-tags-1.1.0.tgz", - "integrity": "sha512-uhGYcGV1jmUSe2QZ6D/pmVehnggQaB8LCaG17EWetYJnGGu6C7LUcPkVNeMXMiewwa5V6g8RxOG8LP8Jh1ZBsQ==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/karma-jasmine-spec-tags/-/karma-jasmine-spec-tags-1.0.1.tgz", + "integrity": "sha1-Mz7WJZKSMG81Dez3f5uNxcOVQhI=", "dev": true }, "karma-spec-reporter": { diff --git a/package.json b/package.json index c3494f755ba..2df682168f2 100644 --- a/package.json +++ b/package.json @@ -142,7 +142,7 @@ "karma-firefox-launcher": "^1.0.1", "karma-ie-launcher": "^1.0.0", "karma-jasmine": "^1.1.2", - "karma-jasmine-spec-tags": "^1.1.0", + "karma-jasmine-spec-tags": "^1.0.1", "karma-spec-reporter": "0.0.32", "karma-verbose-reporter": "0.0.6", "karma-viewport": "^1.0.4", diff --git a/src/plots/cartesian/axes.js b/src/plots/cartesian/axes.js index cb2a114ca1f..151328a0b63 100644 --- a/src/plots/cartesian/axes.js +++ b/src/plots/cartesian/axes.js @@ -1317,7 +1317,14 @@ function numFormat(v, ax, fmtoverride, hover) { if(ax.hoverformat) tickformat = ax.hoverformat; } - if(tickformat) return ax._numFormat(tickformat)(v).replace(/-/g, MINUS_SIGN); + if(tickformat) { + if(tickformat === 'p') { + tickRound -= 2; + exponent = 0; + } else { + return ax._numFormat(tickformat)(v).replace(/-/g, MINUS_SIGN); + } + } // 'epsilon' - rounding increment var e = Math.pow(10, -tickRound) / 2; @@ -1385,7 +1392,10 @@ function numFormat(v, ax, fmtoverride, hover) { // put sign back in and return // replace standard minus character (which is technically a hyphen) // with a true minus sign - if(isNeg) return MINUS_SIGN + v; + if(isNeg) v = MINUS_SIGN + v; + + if(tickformat === 'p') v = (v * 100) + '%'; + return v; } diff --git a/test/image/baselines/tickformat_percent.png b/test/image/baselines/tickformat_percent.png new file mode 100644 index 00000000000..6323aa015f3 Binary files /dev/null and b/test/image/baselines/tickformat_percent.png differ diff --git a/test/image/mocks/tickformat_percent.json b/test/image/mocks/tickformat_percent.json new file mode 100644 index 00000000000..c9b1af45639 --- /dev/null +++ b/test/image/mocks/tickformat_percent.json @@ -0,0 +1,33 @@ +{ + "data": [{ + "y": [0, 1] + }, { + "y": [1, 0], + "yaxis": "y4" + }, { + "y": [0, 0.0001], + "yaxis": "y2" + }, { + "y": [0.0001, 0], + "yaxis": "y5" + }, { + "y": [0, 1.000121321321321], + "yaxis": "y3" + }, { + "y": [1.0001321321321121, 0], + "yaxis": "y6" + }], + "layout": { + "grid": {"rows": 3, "columns": 1}, + "title": {"text": "left: 'p' tickformat | right dflt tickformat"}, + "showlegend": false, + + "yaxis": {"tickformat": "p"}, + "yaxis2": {"tickformat": "p"}, + "yaxis3": {"tickformat": "p"}, + + "yaxis4": {"overlaying": "y", "side": "right"}, + "yaxis5": {"overlaying": "y2", "side": "right"}, + "yaxis6": {"overlaying": "y3", "side": "right"} + } +}