Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'order'

  • Loading branch information...
commit 05d871b71628fc55b0507031f3268372aa0961c5 2 parents fe671a7 + b3848af
Mike Bostock authored
1  Makefile
@@ -99,6 +99,7 @@ d3.core.js: \
99 99
 	src/core/selection-data.js \
100 100
 	src/core/selection-filter.js \
101 101
 	src/core/selection-map.js \
  102
+	src/core/selection-order.js \
102 103
 	src/core/selection-sort.js \
103 104
 	src/core/selection-on.js \
104 105
 	src/core/selection-each.js \
7  d3.geo.js
@@ -652,6 +652,7 @@ function d3_geo_bounds(o, f) {
652 652
 var d3_geo_boundsTypes = {
653 653
   Feature: d3_geo_boundsFeature,
654 654
   FeatureCollection: d3_geo_boundsFeatureCollection,
  655
+  GeometryCollection: d3_geo_boundsGeometryCollection,
655 656
   LineString: d3_geo_boundsLineString,
656 657
   MultiLineString: d3_geo_boundsMultiLineString,
657 658
   MultiPoint: d3_geo_boundsLineString,
@@ -670,6 +671,12 @@ function d3_geo_boundsFeatureCollection(o, f) {
670 671
   }
671 672
 }
672 673
 
  674
+function d3_geo_boundsGeometryCollection(o, f) {
  675
+  for (var a = o.geometries, i = 0, n = a.length; i < n; i++) {
  676
+    d3_geo_bounds(a[i], f);
  677
+  }
  678
+}
  679
+
673 680
 function d3_geo_boundsLineString(o, f) {
674 681
   for (var a = o.coordinates, i = 0, n = a.length; i < n; i++) {
675 682
     f.apply(null, a[i]);
2  d3.geo.min.js
... ...
@@ -1 +1 @@
1  
-(function(){function b(a,b){return function(c){return c&&c.type in a?a[c.type](c):b}}function c(a){return"m0,"+a+"a"+a+","+a+" 0 1,1 0,"+ -2*a+"a"+a+","+a+" 0 1,1 0,"+2*a+"z"}function d(a,b){a.type in e&&e[a.type](a,b)}function f(a,b){d(a.geometry,b)}function g(a,b){for(var c=a.features,e=0,f=c.length;e<f;e++)d(c[e].geometry,b)}function h(a,b){for(var c=a.coordinates,d=0,e=c.length;d<e;d++)b.apply(null,c[d])}function i(a,b){for(var c=a.coordinates,d=0,e=c.length;d<e;d++)for(var f=c[d],g=0,h=f.length;g<h;g++)b.apply(null,f[g])}function j(a,b){for(var c=a.coordinates,d=0,e=c.length;d<e;d++)for(var f=c[d][0],g=0,h=f.length;g<h;g++)b.apply(null,f[g])}function k(a,b){b.apply(null,a.coordinates)}function l(a,b){for(var c=a.coordinates[0],d=0,e=c.length;d<e;d++)b.apply(null,c[d])}function m(a){return a.source}function n(a){return a.target}function o(b,c){function r(b){var c=Math.sin(p-(b*=p))/q,d=Math.sin(b)/q,g=c*h*e+d*n*k,j=c*h*f+d*n*l,m=c*i+d*o;return[Math.atan2(j,g)/a,Math.atan2(m,Math.sqrt(g*g+j*j))/a]}var d=b[0]*a,e=Math.cos(d),f=Math.sin(d),g=b[1]*a,h=Math.cos(g),i=Math.sin(g),j=c[0]*a,k=Math.cos(j),l=Math.sin(j),m=c[1]*a,n=Math.cos(m),o=Math.sin(m),p=r.d=Math.acos(Math.max(-1,Math.min(1,i*o+h*n*Math.cos(j-d)))),q=Math.sin(p);return r}d3.geo={};var a=Math.PI/180;d3.geo.azimuthal=function(){function j(c){var g=c[0]*a-f,j=c[1]*a,k=Math.cos(g),l=Math.sin(g),m=Math.cos(j),n=Math.sin(j),o=b!=="orthographic"?i*n+h*m*k:null,p,q=b==="stereographic"?1/(1+o):b==="gnomonic"?1/o:b==="equidistant"?(p=Math.acos(o),p?p/Math.sin(p):0):b==="equalarea"?Math.sqrt(2/(1+o)):1,r=q*m*l,s=q*(i*m*k-h*n);return[d*r+e[0],d*s+e[1]]}var b="orthographic",c,d=200,e=[480,250],f,g,h,i;return j.invert=function(c){var g=(c[0]-e[0])/d,j=(c[1]-e[1])/d,k=Math.sqrt(g*g+j*j),l=b==="stereographic"?2*Math.atan(k):b==="gnomonic"?Math.atan(k):b==="equidistant"?k:b==="equalarea"?2*Math.asin(.5*k):Math.asin(k),m=Math.sin(l),n=Math.cos(l);return[(f+Math.atan2(g*m,k*h*n+j*i*m))/a,Math.asin(n*i-(k?j*m*h/k:0))/a]},j.mode=function(a){return arguments.length?(b=a+"",j):b},j.origin=function(b){return arguments.length?(c=b,f=c[0]*a,g=c[1]*a,h=Math.cos(g),i=Math.sin(g),j):c},j.scale=function(a){return arguments.length?(d=+a,j):d},j.translate=function(a){return arguments.length?(e=[+a[0],+a[1]],j):e},j.origin([0,0])},d3.geo.albers=function(){function j(b){var c=g*(a*b[0]-f),j=Math.sqrt(h-2*g*Math.sin(a*b[1]))/g;return[d*j*Math.sin(c)+e[0],d*(j*Math.cos(c)-i)+e[1]]}function k(){var d=a*c[0],e=a*c[1],k=a*b[1],l=Math.sin(d),m=Math.cos(d);return f=a*b[0],g=.5*(l+Math.sin(e)),h=m*m+2*g*l,i=Math.sqrt(h-2*g*Math.sin(k))/g,j}var b=[-98,38],c=[29.5,45.5],d=1e3,e=[480,250],f,g,h,i;return j.invert=function(b){var c=(b[0]-e[0])/d,j=(b[1]-e[1])/d,k=i+j,l=Math.atan2(c,k),m=Math.sqrt(c*c+k*k);return[(f+l/g)/a,Math.asin((h-m*m*g*g)/(2*g))/a]},j.origin=function(a){return arguments.length?(b=[+a[0],+a[1]],k()):b},j.parallels=function(a){return arguments.length?(c=[+a[0],+a[1]],k()):c},j.scale=function(a){return arguments.length?(d=+a,j):d},j.translate=function(a){return arguments.length?(e=[+a[0],+a[1]],j):e},k()},d3.geo.albersUsa=function(){function e(e){var f=e[0],g=e[1];return(g>50?b:f<-140?c:g<21?d:a)(e)}var a=d3.geo.albers(),b=d3.geo.albers().origin([-160,60]).parallels([55,65]),c=d3.geo.albers().origin([-160,20]).parallels([8,18]),d=d3.geo.albers().origin([-60,10]).parallels([8,18]);return e.scale=function(f){return arguments.length?(a.scale(f),b.scale(f*.6),c.scale(f),d.scale(f*1.5),e.translate(a.translate())):a.scale()},e.translate=function(f){if(!arguments.length)return a.translate();var g=a.scale()/1e3,h=f[0],i=f[1];return a.translate(f),b.translate([h-400*g,i+170*g]),c.translate([h-190*g,i+200*g]),d.translate([h+580*g,i+430*g]),e},e.scale(a.scale())},d3.geo.bonne=function(){function h(h){var i=h[0]*a-d,j=h[1]*a-e;if(f){var k=g+f-j,l=i*Math.cos(j)/k;i=k*Math.sin(l),j=k*Math.cos(l)-g}else i*=Math.cos(j),j*=-1;return[b*i+c[0],b*j+c[1]]}var b=200,c=[480,250],d,e,f,g;return h.invert=function(e){var h=(e[0]-c[0])/b,i=(e[1]-c[1])/b;if(f){var j=g+i,k=Math.sqrt(h*h+j*j);i=g+f-k,h=d+k*Math.atan2(h,j)/Math.cos(i)}else i*=-1,h/=Math.cos(i);return[h/a,i/a]},h.parallel=function(b){return arguments.length?(g=1/Math.tan(f=b*a),h):f/a},h.origin=function(b){return arguments.length?(d=b[0]*a,e=b[1]*a,h):[d/a,e/a]},h.scale=function(a){return arguments.length?(b=+a,h):b},h.translate=function(a){return arguments.length?(c=[+a[0],+a[1]],h):c},h.origin([0,0]).parallel(45)},d3.geo.equirectangular=function(){function c(c){var d=c[0]/360,e=-c[1]/360;return[a*d+b[0],a*e+b[1]]}var a=500,b=[480,250];return c.invert=function(c){var d=(c[0]-b[0])/a,e=(c[1]-b[1])/a;return[360*d,-360*e]},c.scale=function(b){return arguments.length?(a=+b,c):a},c.translate=function(a){return arguments.length?(b=[+a[0],+a[1]],c):b},c},d3.geo.mercator=function(){function d(d){var e=d[0]/360,f=-(Math.log(Math.tan(Math.PI/4+d[1]*a/2))/a)/360;return[b*e+c[0],b*Math.max(-0.5,Math.min(.5,f))+c[1]]}var b=500,c=[480,250];return d.invert=function(d){var e=(d[0]-c[0])/b,f=(d[1]-c[1])/b;return[360*e,2*Math.atan(Math.exp(-360*f*a))/a-90]},d.scale=function(a){return arguments.length?(b=+a,d):b},d.translate=function(a){return arguments.length?(c=[+a[0],+a[1]],d):c},d},d3.geo.path=function(){function f(b,e){return typeof a=="function"&&(d=c(a.apply(this,arguments))),h(b)||null}function g(a){return e(a).join(",")}function j(a){var b=m(a[0]),c=0,d=a.length;while(++c<d)b-=m(a[c]);return b}function k(a){var b=d3.geom.polygon(a[0].map(e)),c=b.area(),d=b.centroid(c<0?(c*=-1,1):-1),f=d[0],g=d[1],h=c,i=0,j=a.length;while(++i<j)b=d3.geom.polygon(a[i].map(e)),c=b.area(),d=b.centroid(c<0?(c*=-1,1):-1),f-=d[0],g-=d[1],h-=c;return[f,g,6*h]}function m(a){return Math.abs(d3.geom.polygon(a.map(e)).area())}var a=4.5,d=c(a),e=d3.geo.albersUsa(),h=b({FeatureCollection:function(a){var b=[],c=a.features,d=-1,e=c.length;while(++d<e)b.push(h(c[d].geometry));return b.join("")},Feature:function(a){return h(a.geometry)},Point:function(a){return"M"+g(a.coordinates)+d},MultiPoint:function(a){var b=[],c=a.coordinates,e=-1,f=c.length;while(++e<f)b.push("M",g(c[e]),d);return b.join("")},LineString:function(a){var b=["M"],c=a.coordinates,d=-1,e=c.length;while(++d<e)b.push(g(c[d]),"L");return b.pop(),b.join("")},MultiLineString:function(a){var b=[],c=a.coordinates,d=-1,e=c.length,f,h,i;while(++d<e){f=c[d],h=-1,i=f.length,b.push("M");while(++h<i)b.push(g(f[h]),"L");b.pop()}return b.join("")},Polygon:function(a){var b=[],c=a.coordinates,d=-1,e=c.length,f,h,i;while(++d<e){f=c[d],h=-1;if((i=f.length-1)>0){b.push("M");while(++h<i)b.push(g(f[h]),"L");b[b.length-1]="Z"}}return b.join("")},MultiPolygon:function(a){var b=[],c=a.coordinates,d=-1,e=c.length,f,h,i,j,k,l;while(++d<e){f=c[d],h=-1,i=f.length;while(++h<i){j=f[h],k=-1;if((l=j.length-1)>0){b.push("M");while(++k<l)b.push(g(j[k]),"L");b[b.length-1]="Z"}}}return b.join("")},GeometryCollection:function(a){var b=[],c=a.geometries,d=-1,e=c.length;while(++d<e)b.push(h(c[d]));return b.join("")}}),i=f.area=b({FeatureCollection:function(a){var b=0,c=a.features,d=-1,e=c.length;while(++d<e)b+=i(c[d]);return b},Feature:function(a){return i(a.geometry)},Polygon:function(a){return j(a.coordinates)},MultiPolygon:function(a){var b=0,c=a.coordinates,d=-1,e=c.length;while(++d<e)b+=j(c[d]);return b},GeometryCollection:function(a){var b=0,c=a.geometries,d=-1,e=c.length;while(++d<e)b+=i(c[d]);return b}},0),l=f.centroid=b({Feature:function(a){return l(a.geometry)},Polygon:function(a){var b=k(a.coordinates);return[b[0]/b[2],b[1]/b[2]]},MultiPolygon:function(a){var b=0,c=a.coordinates,d,e=0,f=0,g=0,h=-1,i=c.length;while(++h<i)d=k(c[h]),e+=d[0],f+=d[1],g+=d[2];return[e/g,f/g]}});return f.projection=function(a){return e=a,f},f.pointRadius=function(b){return typeof b=="function"?a=b:(a=+b,d=c(a)),f},f},d3.geo.bounds=function(a){var b=Infinity,c=Infinity,e=-Infinity,f=-Infinity;return d(a,function(a,d){a<b&&(b=a),a>e&&(e=a),d<c&&(c=d),d>f&&(f=d)}),[[b,c],[e,f]]};var e={Feature:f,FeatureCollection:g,LineString:h,MultiLineString:i,MultiPoint:h,MultiPolygon:j,Point:k,Polygon:l};d3.geo.circle=function(){function g(){}function h(a){return f.distance(a)<e}function j(a){var b=-1,c=a.length,d=[],g,h,i,j,l;while(++b<c)l=f.distance(i=a[b]),l<e?(h&&d.push(o(h,i)((j-e)/(j-l))),d.push(i),g=h=null):(h=i,!g&&d.length&&(d.push(o(d[d.length-1],h)((e-j)/(l-j))),g=h)),j=l;return h&&d.length&&(l=f.distance(i=d[0]),d.push(o(h,i)((j-e)/(j-l)))),k(d)}function k(a){var b=0,c=a.length,d,e,g=c?[a[0]]:a,h,i=f.source();while(++b<c){h=f.source(a[b-1])(a[b]).coordinates;for(d=0,e=h.length;++d<e;)g.push(h[d])}return f.source(i),g}var c=[0,0],d=89.99,e=d*a,f=d3.geo.greatArc().target(Object);g.clip=function(a){return f.source(typeof c=="function"?c.apply(this,arguments):c),i(a)};var i=b({FeatureCollection:function(a){var b=a.features.map(i).filter(Object);return b&&(a=Object.create(a),a.features=b,a)},Feature:function(a){var b=i(a.geometry);return b&&(a=Object.create(a),a.geometry=b,a)},Point:function(a){return h(a.coordinates)&&a},MultiPoint:function(a){var b=a.coordinates.filter(h);return b.length&&{type:a.type,coordinates:b}},LineString:function(a){var b=j(a.coordinates);return b.length&&(a=Object.create(a),a.coordinates=b,a)},MultiLineString:function(a){var b=a.coordinates.map(j).filter(function(a){return a.length});return b.length&&(a=Object.create(a),a.coordinates=b,a)},Polygon:function(a){var b=a.coordinates.map(j);return b[0].length&&(a=Object.create(a),a.coordinates=b,a)},MultiPolygon:function(a){var b=a.coordinates.map(function(a){return a.map(j)}).filter(function(a){return a[0].length});return b.length&&(a=Object.create(a),a.coordinates=b,a)},GeometryCollection:function(a){var b=a.geometries.map(i).filter(Object);return b.length&&(a=Object.create(a),a.geometries=b,a)}});return g.origin=function(a){return arguments.length?(c=a,g):c},g.angle=function(b){return arguments.length?(e=(d=+b)*a,g):d},g.precision=function(a){return arguments.length?(f.precision(a),g):f.precision()},g},d3.geo.greatArc=function(){function e(){var a=typeof b=="function"?b.apply(this,arguments):b,e=typeof c=="function"?c.apply(this,arguments):c,f=o(a,e),g=d/f.d,h=0,i=[a];while((h+=g)<1)i.push(f(h));return i.push(e),{type:"LineString",coordinates:i}}var b=m,c=n,d=6*a;return e.distance=function(){var a=typeof b=="function"?b.apply(this,arguments):b,d=typeof c=="function"?c.apply(this,arguments):c;return o(a,d).d},e.source=function(a){return arguments.length?(b=a,e):b},e.target=function(a){return arguments.length?(c=a,e):c},e.precision=function(b){return arguments.length?(d=b*a,e):d/a},e},d3.geo.greatCircle=d3.geo.circle})();
  1
+(function(){function b(a,b){return function(c){return c&&c.type in a?a[c.type](c):b}}function c(a){return"m0,"+a+"a"+a+","+a+" 0 1,1 0,"+ -2*a+"a"+a+","+a+" 0 1,1 0,"+2*a+"z"}function d(a,b){a.type in e&&e[a.type](a,b)}function f(a,b){d(a.geometry,b)}function g(a,b){for(var c=a.features,e=0,f=c.length;e<f;e++)d(c[e].geometry,b)}function h(a,b){for(var c=a.geometries,e=0,f=c.length;e<f;e++)d(c[e],b)}function i(a,b){for(var c=a.coordinates,d=0,e=c.length;d<e;d++)b.apply(null,c[d])}function j(a,b){for(var c=a.coordinates,d=0,e=c.length;d<e;d++)for(var f=c[d],g=0,h=f.length;g<h;g++)b.apply(null,f[g])}function k(a,b){for(var c=a.coordinates,d=0,e=c.length;d<e;d++)for(var f=c[d][0],g=0,h=f.length;g<h;g++)b.apply(null,f[g])}function l(a,b){b.apply(null,a.coordinates)}function m(a,b){for(var c=a.coordinates[0],d=0,e=c.length;d<e;d++)b.apply(null,c[d])}function n(a){return a.source}function o(a){return a.target}function p(b,c){function r(b){var c=Math.sin(p-(b*=p))/q,d=Math.sin(b)/q,g=c*h*e+d*n*k,j=c*h*f+d*n*l,m=c*i+d*o;return[Math.atan2(j,g)/a,Math.atan2(m,Math.sqrt(g*g+j*j))/a]}var d=b[0]*a,e=Math.cos(d),f=Math.sin(d),g=b[1]*a,h=Math.cos(g),i=Math.sin(g),j=c[0]*a,k=Math.cos(j),l=Math.sin(j),m=c[1]*a,n=Math.cos(m),o=Math.sin(m),p=r.d=Math.acos(Math.max(-1,Math.min(1,i*o+h*n*Math.cos(j-d)))),q=Math.sin(p);return r}d3.geo={};var a=Math.PI/180;d3.geo.azimuthal=function(){function j(c){var g=c[0]*a-f,j=c[1]*a,k=Math.cos(g),l=Math.sin(g),m=Math.cos(j),n=Math.sin(j),o=b!=="orthographic"?i*n+h*m*k:null,p,q=b==="stereographic"?1/(1+o):b==="gnomonic"?1/o:b==="equidistant"?(p=Math.acos(o),p?p/Math.sin(p):0):b==="equalarea"?Math.sqrt(2/(1+o)):1,r=q*m*l,s=q*(i*m*k-h*n);return[d*r+e[0],d*s+e[1]]}var b="orthographic",c,d=200,e=[480,250],f,g,h,i;return j.invert=function(c){var g=(c[0]-e[0])/d,j=(c[1]-e[1])/d,k=Math.sqrt(g*g+j*j),l=b==="stereographic"?2*Math.atan(k):b==="gnomonic"?Math.atan(k):b==="equidistant"?k:b==="equalarea"?2*Math.asin(.5*k):Math.asin(k),m=Math.sin(l),n=Math.cos(l);return[(f+Math.atan2(g*m,k*h*n+j*i*m))/a,Math.asin(n*i-(k?j*m*h/k:0))/a]},j.mode=function(a){return arguments.length?(b=a+"",j):b},j.origin=function(b){return arguments.length?(c=b,f=c[0]*a,g=c[1]*a,h=Math.cos(g),i=Math.sin(g),j):c},j.scale=function(a){return arguments.length?(d=+a,j):d},j.translate=function(a){return arguments.length?(e=[+a[0],+a[1]],j):e},j.origin([0,0])},d3.geo.albers=function(){function j(b){var c=g*(a*b[0]-f),j=Math.sqrt(h-2*g*Math.sin(a*b[1]))/g;return[d*j*Math.sin(c)+e[0],d*(j*Math.cos(c)-i)+e[1]]}function k(){var d=a*c[0],e=a*c[1],k=a*b[1],l=Math.sin(d),m=Math.cos(d);return f=a*b[0],g=.5*(l+Math.sin(e)),h=m*m+2*g*l,i=Math.sqrt(h-2*g*Math.sin(k))/g,j}var b=[-98,38],c=[29.5,45.5],d=1e3,e=[480,250],f,g,h,i;return j.invert=function(b){var c=(b[0]-e[0])/d,j=(b[1]-e[1])/d,k=i+j,l=Math.atan2(c,k),m=Math.sqrt(c*c+k*k);return[(f+l/g)/a,Math.asin((h-m*m*g*g)/(2*g))/a]},j.origin=function(a){return arguments.length?(b=[+a[0],+a[1]],k()):b},j.parallels=function(a){return arguments.length?(c=[+a[0],+a[1]],k()):c},j.scale=function(a){return arguments.length?(d=+a,j):d},j.translate=function(a){return arguments.length?(e=[+a[0],+a[1]],j):e},k()},d3.geo.albersUsa=function(){function e(e){var f=e[0],g=e[1];return(g>50?b:f<-140?c:g<21?d:a)(e)}var a=d3.geo.albers(),b=d3.geo.albers().origin([-160,60]).parallels([55,65]),c=d3.geo.albers().origin([-160,20]).parallels([8,18]),d=d3.geo.albers().origin([-60,10]).parallels([8,18]);return e.scale=function(f){return arguments.length?(a.scale(f),b.scale(f*.6),c.scale(f),d.scale(f*1.5),e.translate(a.translate())):a.scale()},e.translate=function(f){if(!arguments.length)return a.translate();var g=a.scale()/1e3,h=f[0],i=f[1];return a.translate(f),b.translate([h-400*g,i+170*g]),c.translate([h-190*g,i+200*g]),d.translate([h+580*g,i+430*g]),e},e.scale(a.scale())},d3.geo.bonne=function(){function h(h){var i=h[0]*a-d,j=h[1]*a-e;if(f){var k=g+f-j,l=i*Math.cos(j)/k;i=k*Math.sin(l),j=k*Math.cos(l)-g}else i*=Math.cos(j),j*=-1;return[b*i+c[0],b*j+c[1]]}var b=200,c=[480,250],d,e,f,g;return h.invert=function(e){var h=(e[0]-c[0])/b,i=(e[1]-c[1])/b;if(f){var j=g+i,k=Math.sqrt(h*h+j*j);i=g+f-k,h=d+k*Math.atan2(h,j)/Math.cos(i)}else i*=-1,h/=Math.cos(i);return[h/a,i/a]},h.parallel=function(b){return arguments.length?(g=1/Math.tan(f=b*a),h):f/a},h.origin=function(b){return arguments.length?(d=b[0]*a,e=b[1]*a,h):[d/a,e/a]},h.scale=function(a){return arguments.length?(b=+a,h):b},h.translate=function(a){return arguments.length?(c=[+a[0],+a[1]],h):c},h.origin([0,0]).parallel(45)},d3.geo.equirectangular=function(){function c(c){var d=c[0]/360,e=-c[1]/360;return[a*d+b[0],a*e+b[1]]}var a=500,b=[480,250];return c.invert=function(c){var d=(c[0]-b[0])/a,e=(c[1]-b[1])/a;return[360*d,-360*e]},c.scale=function(b){return arguments.length?(a=+b,c):a},c.translate=function(a){return arguments.length?(b=[+a[0],+a[1]],c):b},c},d3.geo.mercator=function(){function d(d){var e=d[0]/360,f=-(Math.log(Math.tan(Math.PI/4+d[1]*a/2))/a)/360;return[b*e+c[0],b*Math.max(-0.5,Math.min(.5,f))+c[1]]}var b=500,c=[480,250];return d.invert=function(d){var e=(d[0]-c[0])/b,f=(d[1]-c[1])/b;return[360*e,2*Math.atan(Math.exp(-360*f*a))/a-90]},d.scale=function(a){return arguments.length?(b=+a,d):b},d.translate=function(a){return arguments.length?(c=[+a[0],+a[1]],d):c},d},d3.geo.path=function(){function f(b,e){return typeof a=="function"&&(d=c(a.apply(this,arguments))),h(b)||null}function g(a){return e(a).join(",")}function j(a){var b=m(a[0]),c=0,d=a.length;while(++c<d)b-=m(a[c]);return b}function k(a){var b=d3.geom.polygon(a[0].map(e)),c=b.area(),d=b.centroid(c<0?(c*=-1,1):-1),f=d[0],g=d[1],h=c,i=0,j=a.length;while(++i<j)b=d3.geom.polygon(a[i].map(e)),c=b.area(),d=b.centroid(c<0?(c*=-1,1):-1),f-=d[0],g-=d[1],h-=c;return[f,g,6*h]}function m(a){return Math.abs(d3.geom.polygon(a.map(e)).area())}var a=4.5,d=c(a),e=d3.geo.albersUsa(),h=b({FeatureCollection:function(a){var b=[],c=a.features,d=-1,e=c.length;while(++d<e)b.push(h(c[d].geometry));return b.join("")},Feature:function(a){return h(a.geometry)},Point:function(a){return"M"+g(a.coordinates)+d},MultiPoint:function(a){var b=[],c=a.coordinates,e=-1,f=c.length;while(++e<f)b.push("M",g(c[e]),d);return b.join("")},LineString:function(a){var b=["M"],c=a.coordinates,d=-1,e=c.length;while(++d<e)b.push(g(c[d]),"L");return b.pop(),b.join("")},MultiLineString:function(a){var b=[],c=a.coordinates,d=-1,e=c.length,f,h,i;while(++d<e){f=c[d],h=-1,i=f.length,b.push("M");while(++h<i)b.push(g(f[h]),"L");b.pop()}return b.join("")},Polygon:function(a){var b=[],c=a.coordinates,d=-1,e=c.length,f,h,i;while(++d<e){f=c[d],h=-1;if((i=f.length-1)>0){b.push("M");while(++h<i)b.push(g(f[h]),"L");b[b.length-1]="Z"}}return b.join("")},MultiPolygon:function(a){var b=[],c=a.coordinates,d=-1,e=c.length,f,h,i,j,k,l;while(++d<e){f=c[d],h=-1,i=f.length;while(++h<i){j=f[h],k=-1;if((l=j.length-1)>0){b.push("M");while(++k<l)b.push(g(j[k]),"L");b[b.length-1]="Z"}}}return b.join("")},GeometryCollection:function(a){var b=[],c=a.geometries,d=-1,e=c.length;while(++d<e)b.push(h(c[d]));return b.join("")}}),i=f.area=b({FeatureCollection:function(a){var b=0,c=a.features,d=-1,e=c.length;while(++d<e)b+=i(c[d]);return b},Feature:function(a){return i(a.geometry)},Polygon:function(a){return j(a.coordinates)},MultiPolygon:function(a){var b=0,c=a.coordinates,d=-1,e=c.length;while(++d<e)b+=j(c[d]);return b},GeometryCollection:function(a){var b=0,c=a.geometries,d=-1,e=c.length;while(++d<e)b+=i(c[d]);return b}},0),l=f.centroid=b({Feature:function(a){return l(a.geometry)},Polygon:function(a){var b=k(a.coordinates);return[b[0]/b[2],b[1]/b[2]]},MultiPolygon:function(a){var b=0,c=a.coordinates,d,e=0,f=0,g=0,h=-1,i=c.length;while(++h<i)d=k(c[h]),e+=d[0],f+=d[1],g+=d[2];return[e/g,f/g]}});return f.projection=function(a){return e=a,f},f.pointRadius=function(b){return typeof b=="function"?a=b:(a=+b,d=c(a)),f},f},d3.geo.bounds=function(a){var b=Infinity,c=Infinity,e=-Infinity,f=-Infinity;return d(a,function(a,d){a<b&&(b=a),a>e&&(e=a),d<c&&(c=d),d>f&&(f=d)}),[[b,c],[e,f]]};var e={Feature:f,FeatureCollection:g,GeometryCollection:h,LineString:i,MultiLineString:j,MultiPoint:i,MultiPolygon:k,Point:l,Polygon:m};d3.geo.circle=function(){function g(){}function h(a){return f.distance(a)<e}function j(a){var b=-1,c=a.length,d=[],g,h,i,j,l;while(++b<c)l=f.distance(i=a[b]),l<e?(h&&d.push(p(h,i)((j-e)/(j-l))),d.push(i),g=h=null):(h=i,!g&&d.length&&(d.push(p(d[d.length-1],h)((e-j)/(l-j))),g=h)),j=l;return h&&d.length&&(l=f.distance(i=d[0]),d.push(p(h,i)((j-e)/(j-l)))),k(d)}function k(a){var b=0,c=a.length,d,e,g=c?[a[0]]:a,h,i=f.source();while(++b<c){h=f.source(a[b-1])(a[b]).coordinates;for(d=0,e=h.length;++d<e;)g.push(h[d])}return f.source(i),g}var c=[0,0],d=89.99,e=d*a,f=d3.geo.greatArc().target(Object);g.clip=function(a){return f.source(typeof c=="function"?c.apply(this,arguments):c),i(a)};var i=b({FeatureCollection:function(a){var b=a.features.map(i).filter(Object);return b&&(a=Object.create(a),a.features=b,a)},Feature:function(a){var b=i(a.geometry);return b&&(a=Object.create(a),a.geometry=b,a)},Point:function(a){return h(a.coordinates)&&a},MultiPoint:function(a){var b=a.coordinates.filter(h);return b.length&&{type:a.type,coordinates:b}},LineString:function(a){var b=j(a.coordinates);return b.length&&(a=Object.create(a),a.coordinates=b,a)},MultiLineString:function(a){var b=a.coordinates.map(j).filter(function(a){return a.length});return b.length&&(a=Object.create(a),a.coordinates=b,a)},Polygon:function(a){var b=a.coordinates.map(j);return b[0].length&&(a=Object.create(a),a.coordinates=b,a)},MultiPolygon:function(a){var b=a.coordinates.map(function(a){return a.map(j)}).filter(function(a){return a[0].length});return b.length&&(a=Object.create(a),a.coordinates=b,a)},GeometryCollection:function(a){var b=a.geometries.map(i).filter(Object);return b.length&&(a=Object.create(a),a.geometries=b,a)}});return g.origin=function(a){return arguments.length?(c=a,g):c},g.angle=function(b){return arguments.length?(e=(d=+b)*a,g):d},g.precision=function(a){return arguments.length?(f.precision(a),g):f.precision()},g},d3.geo.greatArc=function(){function e(){var a=typeof b=="function"?b.apply(this,arguments):b,e=typeof c=="function"?c.apply(this,arguments):c,f=p(a,e),g=d/f.d,h=0,i=[a];while((h+=g)<1)i.push(f(h));return i.push(e),{type:"LineString",coordinates:i}}var b=n,c=o,d=6*a;return e.distance=function(){var a=typeof b=="function"?b.apply(this,arguments):b,d=typeof c=="function"?c.apply(this,arguments):c;return p(a,d).d},e.source=function(a){return arguments.length?(b=a,e):b},e.target=function(a){return arguments.length?(c=a,e):c},e.precision=function(b){return arguments.length?(d=b*a,e):d/a},e},d3.geo.greatCircle=d3.geo.circle})();
38  d3.js
@@ -10,7 +10,7 @@ try {
10 10
     d3_style_setProperty.call(this, name, value + "", priority);
11 11
   };
12 12
 }
13  
-d3 = {version: "2.6.1"}; // semver
  13
+d3 = {version: "2.7.0"}; // semver
14 14
 var d3_array = d3_arraySlice; // conversion for NodeLists
15 15
 
16 16
 function d3_arrayCopy(pseudoarray) {
@@ -1346,12 +1346,16 @@ function d3_selection(groups) {
1346 1346
 }
1347 1347
 
1348 1348
 var d3_select = function(s, n) { return n.querySelector(s); },
1349  
-    d3_selectAll = function(s, n) { return n.querySelectorAll(s); };
  1349
+    d3_selectAll = function(s, n) { return n.querySelectorAll(s); },
  1350
+    d3_selectRoot = document.documentElement,
  1351
+    d3_selectMatcher = d3_selectRoot.matchesSelector || d3_selectRoot.webkitMatchesSelector || d3_selectRoot.mozMatchesSelector || d3_selectRoot.msMatchesSelector || d3_selectRoot.oMatchesSelector,
  1352
+    d3_selectMatches = function(n, s) { return d3_selectMatcher.call(n, s); };
1350 1353
 
1351 1354
 // Prefer Sizzle, if available.
1352 1355
 if (typeof Sizzle === "function") {
1353 1356
   d3_select = function(s, n) { return Sizzle(s, n)[0]; };
1354 1357
   d3_selectAll = function(s, n) { return Sizzle.uniqueSort(Sizzle(s, n)); };
  1358
+  d3_selectMatches = Sizzle.matchesSelector;
1355 1359
 }
1356 1360
 
1357 1361
 var d3_selectionPrototype = [];
@@ -1735,13 +1739,14 @@ d3_selectionPrototype.data = function(data, join) {
1735 1739
 function d3_selection_dataNode(data) {
1736 1740
   return {__data__: data};
1737 1741
 }
1738  
-// TODO preserve null elements to maintain index?
1739 1742
 d3_selectionPrototype.filter = function(filter) {
1740 1743
   var subgroups = [],
1741 1744
       subgroup,
1742 1745
       group,
1743 1746
       node;
1744 1747
 
  1748
+  if (typeof filter !== "function") filter = d3_selection_filter(filter);
  1749
+
1745 1750
   for (var j = 0, m = this.length; j < m; j++) {
1746 1751
     subgroups.push(subgroup = []);
1747 1752
     subgroup.parentNode = (group = this[j]).parentNode;
@@ -1754,24 +1759,33 @@ d3_selectionPrototype.filter = function(filter) {
1754 1759
 
1755 1760
   return d3_selection(subgroups);
1756 1761
 };
  1762
+
  1763
+function d3_selection_filter(selector) {
  1764
+  return function() {
  1765
+    return d3_selectMatches(this, selector);
  1766
+  };
  1767
+}
1757 1768
 d3_selectionPrototype.map = function(map) {
1758 1769
   return this.each(function() {
1759 1770
     this.__data__ = map.apply(this, arguments);
1760 1771
   });
1761 1772
 };
1762  
-d3_selectionPrototype.sort = function(comparator) {
1763  
-  comparator = d3_selection_sortComparator.apply(this, arguments);
1764  
-  for (var j = 0, m = this.length; j < m; j++) {
1765  
-    for (var group = this[j].sort(comparator), i = 1, n = group.length, prev = group[0]; i < n; i++) {
1766  
-      var node = group[i];
1767  
-      if (node) {
1768  
-        if (prev) prev.parentNode.insertBefore(node, prev.nextSibling);
1769  
-        prev = node;
  1773
+d3_selectionPrototype.order = function() {
  1774
+  for (var j = -1, m = this.length; ++j < m;) {
  1775
+    for (var group = this[j], i = group.length - 1, next = group[i], node; --i >= 0;) {
  1776
+      if (node = group[i]) {
  1777
+        if (next) next.parentNode.insertBefore(node, next);
  1778
+        next = node;
1770 1779
       }
1771 1780
     }
1772 1781
   }
1773 1782
   return this;
1774 1783
 };
  1784
+d3_selectionPrototype.sort = function(comparator) {
  1785
+  comparator = d3_selection_sortComparator.apply(this, arguments);
  1786
+  for (var j = -1, m = this.length; ++j < m;) this[j].sort(comparator);
  1787
+  return this.order();
  1788
+};
1775 1789
 
1776 1790
 function d3_selection_sortComparator(comparator) {
1777 1791
   if (!arguments.length) comparator = d3.ascending;
@@ -1863,7 +1877,7 @@ d3_selectionPrototype.transition = function() {
1863 1877
 };
1864 1878
 var d3_selectionRoot = d3_selection([[document]]);
1865 1879
 
1866  
-d3_selectionRoot[0].parentNode = document.documentElement;
  1880
+d3_selectionRoot[0].parentNode = d3_selectRoot;
1867 1881
 
1868 1882
 // TODO fast singleton implementation!
1869 1883
 // TODO select(function)
4  d3.min.js
2 additions, 2 deletions not shown
25  examples/hello-world/hello-order.html
... ...
@@ -0,0 +1,25 @@
  1
+<!DOCTYPE html>
  2
+<html>
  3
+  <head>
  4
+    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
  5
+  </head>
  6
+  <body>
  7
+    <script type="text/javascript" src="../../d3.js"></script>
  8
+    <script type="text/javascript">
  9
+
  10
+var div = d3.select("body").selectAll("div")
  11
+    .data(["a", "b", "f"])
  12
+  .enter().append("div")
  13
+    .text(String);
  14
+
  15
+var div = d3.select("body").selectAll("div")
  16
+    .data(["a", "b", "c", "d", "e", "f"], String);
  17
+
  18
+div.enter().append("div")
  19
+    .text(String);
  20
+
  21
+div.order();
  22
+
  23
+    </script>
  24
+  </body>
  25
+</html>
2  package.json
... ...
@@ -1,6 +1,6 @@
1 1
 {
2 2
   "name": "d3",
3  
-  "version": "2.6.1",
  3
+  "version": "2.7.0",
4 4
   "description": "A small, free JavaScript library for manipulating documents based on data.",
5 5
   "keywords": [
6 6
     "dom",
2  src/core/core.js
... ...
@@ -1 +1 @@
1  
-d3 = {version: "2.6.1"}; // semver
  1
+d3 = {version: "2.7.0"}; // semver
9  src/core/selection-filter.js
... ...
@@ -1,10 +1,11 @@
1  
-// TODO preserve null elements to maintain index?
2 1
 d3_selectionPrototype.filter = function(filter) {
3 2
   var subgroups = [],
4 3
       subgroup,
5 4
       group,
6 5
       node;
7 6
 
  7
+  if (typeof filter !== "function") filter = d3_selection_filter(filter);
  8
+
8 9
   for (var j = 0, m = this.length; j < m; j++) {
9 10
     subgroups.push(subgroup = []);
10 11
     subgroup.parentNode = (group = this[j]).parentNode;
@@ -17,3 +18,9 @@ d3_selectionPrototype.filter = function(filter) {
17 18
 
18 19
   return d3_selection(subgroups);
19 20
 };
  21
+
  22
+function d3_selection_filter(selector) {
  23
+  return function() {
  24
+    return d3_selectMatches(this, selector);
  25
+  };
  26
+}
11  src/core/selection-order.js
... ...
@@ -0,0 +1,11 @@
  1
+d3_selectionPrototype.order = function() {
  2
+  for (var j = -1, m = this.length; ++j < m;) {
  3
+    for (var group = this[j], i = group.length - 1, next = group[i], node; --i >= 0;) {
  4
+      if (node = group[i]) {
  5
+        if (next) next.parentNode.insertBefore(node, next);
  6
+        next = node;
  7
+      }
  8
+    }
  9
+  }
  10
+  return this;
  11
+};
2  src/core/selection-root.js
... ...
@@ -1,6 +1,6 @@
1 1
 var d3_selectionRoot = d3_selection([[document]]);
2 2
 
3  
-d3_selectionRoot[0].parentNode = document.documentElement;
  3
+d3_selectionRoot[0].parentNode = d3_selectRoot;
4 4
 
5 5
 // TODO fast singleton implementation!
6 6
 // TODO select(function)
12  src/core/selection-sort.js
... ...
@@ -1,15 +1,7 @@
1 1
 d3_selectionPrototype.sort = function(comparator) {
2 2
   comparator = d3_selection_sortComparator.apply(this, arguments);
3  
-  for (var j = 0, m = this.length; j < m; j++) {
4  
-    for (var group = this[j].sort(comparator), i = 1, n = group.length, prev = group[0]; i < n; i++) {
5  
-      var node = group[i];
6  
-      if (node) {
7  
-        if (prev) prev.parentNode.insertBefore(node, prev.nextSibling);
8  
-        prev = node;
9  
-      }
10  
-    }
11  
-  }
12  
-  return this;
  3
+  for (var j = -1, m = this.length; ++j < m;) this[j].sort(comparator);
  4
+  return this.order();
13 5
 };
14 6
 
15 7
 function d3_selection_sortComparator(comparator) {
6  src/core/selection.js
@@ -4,12 +4,16 @@ function d3_selection(groups) {
4 4
 }
5 5
 
6 6
 var d3_select = function(s, n) { return n.querySelector(s); },
7  
-    d3_selectAll = function(s, n) { return n.querySelectorAll(s); };
  7
+    d3_selectAll = function(s, n) { return n.querySelectorAll(s); },
  8
+    d3_selectRoot = document.documentElement,
  9
+    d3_selectMatcher = d3_selectRoot.matchesSelector || d3_selectRoot.webkitMatchesSelector || d3_selectRoot.mozMatchesSelector || d3_selectRoot.msMatchesSelector || d3_selectRoot.oMatchesSelector,
  10
+    d3_selectMatches = function(n, s) { return d3_selectMatcher.call(n, s); };
8 11
 
9 12
 // Prefer Sizzle, if available.
10 13
 if (typeof Sizzle === "function") {
11 14
   d3_select = function(s, n) { return Sizzle(s, n)[0]; };
12 15
   d3_selectAll = function(s, n) { return Sizzle.uniqueSort(Sizzle(s, n)); };
  16
+  d3_selectMatches = Sizzle.matchesSelector;
13 17
 }
14 18
 
15 19
 var d3_selectionPrototype = [];
7  src/geo/bounds.js
@@ -25,6 +25,7 @@ function d3_geo_bounds(o, f) {
25 25
 var d3_geo_boundsTypes = {
26 26
   Feature: d3_geo_boundsFeature,
27 27
   FeatureCollection: d3_geo_boundsFeatureCollection,
  28
+  GeometryCollection: d3_geo_boundsGeometryCollection,
28 29
   LineString: d3_geo_boundsLineString,
29 30
   MultiLineString: d3_geo_boundsMultiLineString,
30 31
   MultiPoint: d3_geo_boundsLineString,
@@ -43,6 +44,12 @@ function d3_geo_boundsFeatureCollection(o, f) {
43 44
   }
44 45
 }
45 46
 
  47
+function d3_geo_boundsGeometryCollection(o, f) {
  48
+  for (var a = o.geometries, i = 0, n = a.length; i < n; i++) {
  49
+    d3_geo_bounds(a[i], f);
  50
+  }
  51
+}
  52
+
46 53
 function d3_geo_boundsLineString(o, f) {
47 54
   for (var a = o.coordinates, i = 0, n = a.length; i < n; i++) {
48 55
     f.apply(null, a[i]);
7  test/core/selection-filter-test.js
@@ -54,6 +54,13 @@ suite.addBatch({
54 54
       assert.isTrue(some[0][0] === span[0][3]);
55 55
       assert.equal(some.length, 1);
56 56
     },
  57
+    "can be specified as a selector": function(span) {
  58
+      span.classed("foo", function(d, i) { return d & 1; });
  59
+      var some = span.filter(".foo");
  60
+      assert.equal(some.length, 2);
  61
+      assert.equal(some[0].length, 1);
  62
+      assert.equal(some[1].length, 1);
  63
+    },
57 64
     "returns a new selection": function(span) {
58 65
       assert.isFalse(span.filter(function() { return 1; }) === span);
59 66
     }
32  test/core/selection-order-test.js
... ...
@@ -0,0 +1,32 @@
  1
+require("../env");
  2
+require("../../d3");
  3
+
  4
+var vows = require("vows"),
  5
+    assert = require("assert");
  6
+
  7
+var suite = vows.describe("selection.order");
  8
+
  9
+suite.addBatch({
  10
+  "selectAll(div)": {
  11
+    topic: function() {
  12
+      return d3.select("body").html("").selectAll("div")
  13
+          .data([1, 2, 10, 20])
  14
+        .enter().append("div")
  15
+          .attr("id", String);
  16
+    },
  17
+    "orders elements by data": function(div) {
  18
+      div = div.data([1, 10, 20, 2], String).order();
  19
+      assert.domNull(div[0][0].previousSibling);
  20
+      assert.domEqual(div[0][1].previousSibling, div[0][0]);
  21
+      assert.domEqual(div[0][2].previousSibling, div[0][1]);
  22
+      assert.domEqual(div[0][3].previousSibling, div[0][2]);
  23
+      assert.domNull(div[0][3].nextSibling);
  24
+    },
  25
+    "returns the current selection": function(span) {
  26
+      span = d3.select("body"); // https://github.com/tmpvar/jsdom/issues/277
  27
+      assert.isTrue(span.order() === span);
  28
+    }
  29
+  }
  30
+});
  31
+
  32
+suite.export(module);

0 notes on commit 05d871b

Please sign in to comment.
Something went wrong with that request. Please try again.