toolkit/javascript/d3/src/scale/polylinear.js
changeset 47 c0b4a8b5a012
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/toolkit/javascript/d3/src/scale/polylinear.js	Thu Apr 10 14:20:23 2014 +0200
@@ -0,0 +1,16 @@
+function d3_scale_polylinear(domain, range, uninterpolate, interpolate) {
+  var u = [],
+      i = [],
+      j = 0,
+      n = domain.length;
+
+  while (++j < n) {
+    u.push(uninterpolate(domain[j - 1], domain[j]));
+    i.push(interpolate(range[j - 1], range[j]));
+  }
+
+  return function(x) {
+    var j = d3.bisect(domain, x, 1, domain.length - 1) - 1;
+    return i[j](u[j](x));
+  };
+}