Sha256: a37ca560b57107d1a91eaaf959f8b344e87a99e2312e21a45299189993771e9f

Contents?: true

Size: 708 Bytes

Versions: 4

Compression:

Stored size: 708 Bytes

Contents

import "format";

var d3_formatPrefixes = ["y","z","a","f","p","n","ยต","m","","k","M","G","T","P","E","Z","Y"].map(d3_formatPrefix);

d3.formatPrefix = function(value, precision) {
  var i = 0;
  if (value) {
    if (value < 0) value *= -1;
    if (precision) value = d3.round(value, d3_format_precision(value, precision));
    i = 1 + Math.floor(1e-12 + Math.log(value) / Math.LN10);
    i = Math.max(-24, Math.min(24, Math.floor((i <= 0 ? i + 1 : i - 1) / 3) * 3));
  }
  return d3_formatPrefixes[8 + i / 3];
};

function d3_formatPrefix(d, i) {
  var k = Math.pow(10, Math.abs(8 - i) * 3);
  return {
    scale: i > 8 ? function(d) { return d / k; } : function(d) { return d * k; },
    symbol: d
  };
}

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
stripchart-0.0.3 lib/stripchart/public/components/d3/src/format/formatPrefix.js
stripmem-0.0.3 lib/stripmem/public/components/d3/src/format/formatPrefix.js
stripmem-0.0.2 lib/stripmem/public/components/d3/src/format/formatPrefix.js
stripmem-0.0.1 lib/stripmem/public/components/d3/src/format/formatPrefix.js