Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Oct 6, 2022. It is now read-only.

Commit 98ff194

Browse files
committed
MINUS_SIGN constant
1 parent 6f0bded commit 98ff194

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/constants/numerical.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,11 @@ module.exports = {
4747
/*
4848
* Are two values nearly equal? Compare to 1PPM
4949
*/
50-
ALMOST_EQUAL: 1 - 1e-6
50+
ALMOST_EQUAL: 1 - 1e-6,
51+
52+
/*
53+
* not a number, but for displaying numbers: the "minus sign" symbol is
54+
* wider than the regular ascii dash "-"
55+
*/
56+
MINUS_SIGN: '\u2212'
5157
};

src/plots/cartesian/axes.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var ONEDAY = constants.ONEDAY;
2727
var ONEHOUR = constants.ONEHOUR;
2828
var ONEMIN = constants.ONEMIN;
2929
var ONESEC = constants.ONESEC;
30+
var MINUS_SIGN = constants.MINUS_SIGN;
3031

3132
var MID_SHIFT = require('../../constants/alignment').MID_SHIFT;
3233

@@ -1304,7 +1305,7 @@ function formatLog(ax, out, hover, extraPrecision, hideexp) {
13041305
if(p === 0) out.text = 1;
13051306
else if(p === 1) out.text = '10';
13061307
else if(p > 1) out.text = '10<sup>' + p + '</sup>';
1307-
else out.text = '10<sup>\u2212' + -p + '</sup>';
1308+
else out.text = '10<sup>' + MINUS_SIGN + -p + '</sup>';
13081309

13091310
out.fontSize *= 1.25;
13101311
}
@@ -1387,7 +1388,7 @@ function numFormat(v, ax, fmtoverride, hover) {
13871388
if(ax.hoverformat) tickformat = ax.hoverformat;
13881389
}
13891390

1390-
if(tickformat) return d3.format(tickformat)(v).replace(/-/g, '\u2212');
1391+
if(tickformat) return d3.format(tickformat)(v).replace(/-/g, MINUS_SIGN);
13911392

13921393
// 'epsilon' - rounding increment
13931394
var e = Math.pow(10, -tickRound) / 2;
@@ -1437,7 +1438,7 @@ function numFormat(v, ax, fmtoverride, hover) {
14371438
// add exponent
14381439
if(exponent && exponentFormat !== 'hide') {
14391440
var signedExponent;
1440-
if(exponent < 0) signedExponent = '\u2212' + -exponent;
1441+
if(exponent < 0) signedExponent = MINUS_SIGN + -exponent;
14411442
else if(exponentFormat !== 'power') signedExponent = '+' + exponent;
14421443
else signedExponent = String(exponent);
14431444

@@ -1463,11 +1464,10 @@ function numFormat(v, ax, fmtoverride, hover) {
14631464
// put sign back in and return
14641465
// replace standard minus character (which is technically a hyphen)
14651466
// with a true minus sign
1466-
if(isNeg) return '\u2212' + v;
1467+
if(isNeg) return MINUS_SIGN + v;
14671468
return v;
14681469
}
14691470

1470-
14711471
axes.subplotMatch = /^x([0-9]*)y([0-9]*)$/;
14721472

14731473
// getSubplots - extract all combinations of axes we need to make plots for

0 commit comments

Comments
 (0)