|
1 | 1 | d3 = function() { |
2 | 2 | var π = Math.PI, ε = 1e-6, d3 = { |
3 | | - version: "3.0.6" |
| 3 | + version: "3.0.8" |
4 | 4 | }, d3_radians = π / 180, d3_degrees = 180 / π, d3_document = document, d3_window = window; |
5 | 5 | function d3_target(d) { |
6 | 6 | return d.target; |
@@ -124,7 +124,7 @@ d3 = function() { |
124 | 124 | function d3_rebind(target, source, method) { |
125 | 125 | return function() { |
126 | 126 | var value = method.apply(source, arguments); |
127 | | - return arguments.length ? target : value; |
| 127 | + return value === source ? target : value; |
128 | 128 | }; |
129 | 129 | } |
130 | 130 | d3.ascending = function(a, b) { |
@@ -5794,9 +5794,15 @@ d3 = function() { |
5794 | 5794 | function d3_geo_clipPolygon(segments, interpolate, listener) { |
5795 | 5795 | var subject = [], clip = []; |
5796 | 5796 | segments.forEach(function(segment) { |
5797 | | - var n = segment.length; |
5798 | | - if (n <= 1) return; |
5799 | | - var p0 = segment[0], p1 = segment[n - 1], a = { |
| 5797 | + if ((n = segment.length) <= 1) return; |
| 5798 | + var n, p0 = segment[0], p1 = segment[n - 1]; |
| 5799 | + if (d3_geo_sphericalEqual(p0, p1)) { |
| 5800 | + listener.lineStart(); |
| 5801 | + for (var i = 0; i < n; ++i) listener.point((p0 = segment[i])[0], p0[1]); |
| 5802 | + listener.lineEnd(); |
| 5803 | + return; |
| 5804 | + } |
| 5805 | + var a = { |
5800 | 5806 | point: p0, |
5801 | 5807 | points: segment, |
5802 | 5808 | other: null, |
@@ -6130,15 +6136,20 @@ d3 = function() { |
6130 | 6136 | }); |
6131 | 6137 | }; |
6132 | 6138 | } |
| 6139 | + function d3_geo_haversin(x) { |
| 6140 | + return (x = Math.sin(x / 2)) * x; |
| 6141 | + } |
6133 | 6142 | d3.geo.interpolate = function(source, target) { |
6134 | 6143 | return d3_geo_interpolate(source[0] * d3_radians, source[1] * d3_radians, target[0] * d3_radians, target[1] * d3_radians); |
6135 | 6144 | }; |
6136 | 6145 | function d3_geo_interpolate(x0, y0, x1, y1) { |
6137 | | - var cy0 = Math.cos(y0), sy0 = Math.sin(y0), cy1 = Math.cos(y1), sy1 = Math.sin(y1), kx0 = cy0 * Math.cos(x0), ky0 = cy0 * Math.sin(x0), kx1 = cy1 * Math.cos(x1), ky1 = cy1 * Math.sin(x1), d = Math.acos(Math.max(-1, Math.min(1, sy0 * sy1 + cy0 * cy1 * Math.cos(x1 - x0)))), k = 1 / Math.sin(d); |
6138 | | - function interpolate(t) { |
| 6146 | + var cy0 = Math.cos(y0), sy0 = Math.sin(y0), cy1 = Math.cos(y1), sy1 = Math.sin(y1), kx0 = cy0 * Math.cos(x0), ky0 = cy0 * Math.sin(x0), kx1 = cy1 * Math.cos(x1), ky1 = cy1 * Math.sin(x1), d = 2 * Math.asin(Math.sqrt(d3_geo_haversin(y1 - y0) + cy0 * cy1 * d3_geo_haversin(x1 - x0))), k = 1 / Math.sin(d); |
| 6147 | + var interpolate = d ? function(t) { |
6139 | 6148 | var B = Math.sin(t *= d) * k, A = Math.sin(d - t) * k, x = A * kx0 + B * kx1, y = A * ky0 + B * ky1, z = A * sy0 + B * sy1; |
6140 | | - return [ Math.atan2(y, x) / d3_radians, Math.atan2(z, Math.sqrt(x * x + y * y)) / d3_radians ]; |
6141 | | - } |
| 6149 | + return [ Math.atan2(y, x) * d3_degrees, Math.atan2(z, Math.sqrt(x * x + y * y)) * d3_degrees ]; |
| 6150 | + } : function() { |
| 6151 | + return [ x0 * d3_degrees, y0 * d3_degrees ]; |
| 6152 | + }; |
6142 | 6153 | interpolate.distance = d; |
6143 | 6154 | return interpolate; |
6144 | 6155 | } |
@@ -7517,7 +7528,7 @@ d3 = function() { |
7517 | 7528 | return format; |
7518 | 7529 | }; |
7519 | 7530 | var d3_time_formatIso = d3.time.format.utc("%Y-%m-%dT%H:%M:%S.%LZ"); |
7520 | | - d3.time.format.iso = Date.prototype.toISOString ? d3_time_formatIsoNative : d3_time_formatIso; |
| 7531 | + d3.time.format.iso = Date.prototype.toISOString && +new Date("2000-01-01T00:00:00.000Z") ? d3_time_formatIsoNative : d3_time_formatIso; |
7521 | 7532 | function d3_time_formatIsoNative(date) { |
7522 | 7533 | return date.toISOString(); |
7523 | 7534 | } |
|
0 commit comments