3 scale: function(scaleType) {
4 return d3_fisheye_scale(scaleType(), 3, 0);
14 var dx = d.x - focus[0],
16 dd = Math.sqrt(dx * dx + dy * dy);
17 if (!dd || dd >= radius) return {x: d.x, y: d.y, z: 1};
18 var k = k0 * (1 - Math.exp(-dd * k1)) / dd * .75 + .25;
19 return {x: focus[0] + dx * k, y: focus[1] + dy * k, z: Math.min(k, 10)};
23 k0 = Math.exp(distortion);
24 k0 = k0 / (k0 - 1) * radius;
25 k1 = distortion / radius;
29 fisheye.radius = function(_) {
30 if (!arguments.length) return radius;
35 fisheye.distortion = function(_) {
36 if (!arguments.length) return distortion;
41 fisheye.focus = function(_) {
42 if (!arguments.length) return focus;
51 function d3_fisheye_scale(scale, d, a) {
57 range = d3.extent(scale.range()),
60 m = left ? a - min : max - a;
61 if (m == 0) m = max - min;
62 return (left ? -1 : 1) * m * (d + 1) / (d + (m / Math.abs(x - a))) + a;
65 fisheye.distortion = function(_) {
66 if (!arguments.length) return d;
71 fisheye.focus = function(_) {
72 if (!arguments.length) return a;
77 fisheye.copy = function() {
78 return d3_fisheye_scale(scale.copy(), d, a);
81 fisheye.nice = scale.nice;
82 fisheye.ticks = scale.ticks;
83 fisheye.tickFormat = scale.tickFormat;
84 return d3.rebind(fisheye, scale, "domain", "range");