MCPcopy Create free account
hub / github.com/breck7/scroll / formatRounded

Function formatRounded

external/.d3.js:9609–9617  ·  view source on GitHub ↗
(x, p)

Source from the content-addressed store, hash-verified

9607}
9608
9609function formatRounded(x, p) {
9610 var d = formatDecimalParts(x, p);
9611 if (!d) return x + "";
9612 var coefficient = d[0],
9613 exponent = d[1];
9614 return exponent < 0 ? "0." + new Array(-exponent).join("0") + coefficient
9615 : coefficient.length > exponent + 1 ? coefficient.slice(0, exponent + 1) + "." + coefficient.slice(exponent + 1)
9616 : coefficient + new Array(exponent - coefficient.length + 2).join("0");
9617}
9618
9619var formatTypes = {
9620 "%": (x, p) => (x * 100).toFixed(p),

Callers 1

.d3.jsFile · 0.85

Calls 3

formatDecimalPartsFunction · 0.85
sliceMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected