Sha256: 0022d2fe7b243542996a5967b7c29d322a2ae2a5c2b2920d2b1f0836473bbe9d

Contents?: true

Size: 1.23 KB

Versions: 31

Compression:

Stored size: 1.23 KB

Contents

d3.scale.pow = function() {
  return d3_scale_pow(d3.scale.linear(), 1);
};

function d3_scale_pow(linear, exponent) {
  var powp = d3_scale_powPow(exponent),
      powb = d3_scale_powPow(1 / exponent);

  function scale(x) {
    return linear(powp(x));
  }

  scale.invert = function(x) {
    return powb(linear.invert(x));
  };

  scale.domain = function(x) {
    if (!arguments.length) return linear.domain().map(powb);
    linear.domain(x.map(powp));
    return scale;
  };

  scale.ticks = function(m) {
    return d3_scale_linearTicks(scale.domain(), m);
  };

  scale.tickFormat = function(m) {
    return d3_scale_linearTickFormat(scale.domain(), m);
  };

  scale.nice = function() {
    return scale.domain(d3_scale_nice(scale.domain(), d3_scale_linearNice));
  };

  scale.exponent = function(x) {
    if (!arguments.length) return exponent;
    var domain = scale.domain();
    powp = d3_scale_powPow(exponent = x);
    powb = d3_scale_powPow(1 / exponent);
    return scale.domain(domain);
  };

  scale.copy = function() {
    return d3_scale_pow(linear.copy(), exponent);
  };

  return d3_scale_linearRebind(scale, linear);
};

function d3_scale_powPow(e) {
  return function(x) {
    return x < 0 ? -Math.pow(-x, e) : Math.pow(x, e);
  };
}

Version data entries

31 entries across 31 versions & 2 rubygems

Version Path
picky-statistics-4.5.0 lib/picky-statistics/application/javascripts/d3/src/scale/pow.js
picky-statistics-4.4.2 lib/picky-statistics/application/javascripts/d3/src/scale/pow.js
picky-statistics-4.4.1 lib/picky-statistics/application/javascripts/d3/src/scale/pow.js
picky-statistics-4.4.0 lib/picky-statistics/application/javascripts/d3/src/scale/pow.js
picky-statistics-4.3.2 lib/picky-statistics/application/javascripts/d3/src/scale/pow.js
picky-statistics-4.3.1 lib/picky-statistics/application/javascripts/d3/src/scale/pow.js
picky-statistics-4.3.0 lib/picky-statistics/application/javascripts/d3/src/scale/pow.js
picky-statistics-4.2.4 lib/picky-statistics/application/javascripts/d3/src/scale/pow.js
picky-statistics-4.2.3 lib/picky-statistics/application/javascripts/d3/src/scale/pow.js
picky-statistics-4.2.2 lib/picky-statistics/application/javascripts/d3/src/scale/pow.js
picky-statistics-4.2.1 lib/picky-statistics/application/javascripts/d3/src/scale/pow.js
picky-statistics-4.2.0 lib/picky-statistics/application/javascripts/d3/src/scale/pow.js
picky-statistics-4.1.0 lib/picky-statistics/application/javascripts/d3/src/scale/pow.js
picky-statistics-4.0.9 lib/picky-statistics/application/javascripts/d3/src/scale/pow.js
picky-statistics-4.0.8 lib/picky-statistics/application/javascripts/d3/src/scale/pow.js
picky-statistics-4.0.7 lib/picky-statistics/application/javascripts/d3/src/scale/pow.js
picky-statistics-4.0.6 lib/picky-statistics/application/javascripts/d3/src/scale/pow.js
picky-statistics-4.0.5 lib/picky-statistics/application/javascripts/d3/src/scale/pow.js
picky-statistics-4.0.4 lib/picky-statistics/application/javascripts/d3/src/scale/pow.js
picky-statistics-4.0.3 lib/picky-statistics/application/javascripts/d3/src/scale/pow.js