MCPcopy Index your code
hub / github.com/leeoniya/uPlot / roundDec

Function roundDec

src/utils.js:362–371  ·  view source on GitHub ↗
(val, dec = 0)

Source from the content-addressed store, hash-verified

360// https://stackoverflow.com/a/48764436
361// rounds half away from zero
362export function roundDec(val, dec = 0) {
363 if (isInt(val))
364 return val;
365// else if (dec == 0)
366// return round(val);
367
368 let p = 10 ** dec;
369 let n = (val * p) * (1 + Number.EPSILON);
370 return round(n) / p;
371}
372
373// https://stackoverflow.com/questions/14879691/get-number-of-digits-with-javascript/28203456#28203456
374export function numDigits(x) {

Callers 13

syncFontSizeFunction · 0.90
drawPathFunction · 0.90
drawAxesGridFunction · 0.90
timeAxisSplitsFunction · 0.90
numAxisSplitsFunction · 0.90
logAxisSplitsFunction · 0.90
ptDiaFunction · 0.90
pointsFunction · 0.90
rangeLogFunction · 0.70
_rangeNumFunction · 0.70
fixFloatFunction · 0.70
incrRoundFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…