Sha256: e450216bae2c1700483aede9a3f501f8fa28d8bd8a2e703dc0b6bed368ca184e

Contents?: true

Size: 680 Bytes

Versions: 4

Compression:

Stored size: 680 Bytes

Contents

import "../arrays/bisect";
import "scale";

d3.scale.threshold = function() {
  return d3_scale_threshold([.5], [0, 1]);
};

function d3_scale_threshold(domain, range) {

  function scale(x) {
    if (x <= x) return range[d3.bisect(domain, x)];
  }

  scale.domain = function(_) {
    if (!arguments.length) return domain;
    domain = _;
    return scale;
  };

  scale.range = function(_) {
    if (!arguments.length) return range;
    range = _;
    return scale;
  };

  scale.invertExtent = function(y) {
    y = range.indexOf(y);
    return [domain[y - 1], domain[y]];
  };

  scale.copy = function() {
    return d3_scale_threshold(domain, range);
  };

  return scale;
};

Version data entries

4 entries across 4 versions & 2 rubygems

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