Cache d3.geo.path listeners.
This commit is contained in:
Родитель
cd1ccd3fd7
Коммит
c25939c9f5
|
@ -6239,11 +6239,10 @@
|
|||
return d3_geo_projection(d3_geo_orthographic);
|
||||
}).raw = d3_geo_orthographic;
|
||||
d3.geo.path = function() {
|
||||
var pointRadius = 4.5, pointCircle = d3_geo_pathCircle(pointRadius), projection = d3.geo.albersUsa(), context, buffer = [];
|
||||
var pointRadius = 4.5, projection = d3.geo.albersUsa(), context, buffer = [], stream = new d3_geo_pathBuffer(buffer);
|
||||
function path(object) {
|
||||
if (object == null) return;
|
||||
var radius = typeof pointRadius === "function" ? pointRadius.apply(this, arguments) : pointRadius;
|
||||
d3.geo.stream(object, projection.stream(context == null ? new d3_geo_pathBuffer(buffer, radius) : new d3_geo_pathContext(context, radius)));
|
||||
d3.geo.stream(object, projection.stream(stream.pointRadius(typeof pointRadius === "function" ? pointRadius.apply(this, arguments) : pointRadius)));
|
||||
if (buffer.length) {
|
||||
var result = buffer.join("");
|
||||
buffer = [];
|
||||
|
@ -6270,12 +6269,12 @@
|
|||
};
|
||||
path.context = function(_) {
|
||||
if (!arguments.length) return context;
|
||||
context = _;
|
||||
stream = new d3_geo_pathContext(context = _);
|
||||
return path;
|
||||
};
|
||||
path.pointRadius = function(x) {
|
||||
path.pointRadius = function(_) {
|
||||
if (!arguments.length) return pointRadius;
|
||||
if (typeof x === "function") pointRadius = x; else pointCircle = d3_geo_pathCircle(pointRadius = +x);
|
||||
pointRadius = _;
|
||||
return path;
|
||||
};
|
||||
return path;
|
||||
|
@ -6283,7 +6282,8 @@
|
|||
function d3_geo_pathCircle(radius) {
|
||||
return "m0," + radius + "a" + radius + "," + radius + " 0 1,1 0," + -2 * radius + "a" + radius + "," + radius + " 0 1,1 0," + +2 * radius + "z";
|
||||
}
|
||||
function d3_geo_pathBuffer(buffer, pointRadius) {
|
||||
function d3_geo_pathBuffer(buffer) {
|
||||
var pointCircle = d3_geo_pathCircle(4.5);
|
||||
var stream = {
|
||||
point: point,
|
||||
lineStart: function() {
|
||||
|
@ -6296,10 +6296,14 @@
|
|||
polygonEnd: function() {
|
||||
stream.lineEnd = lineEnd;
|
||||
stream.point = point;
|
||||
},
|
||||
pointRadius: function(_) {
|
||||
pointCircle = d3_geo_pathCircle(+_);
|
||||
return stream;
|
||||
}
|
||||
};
|
||||
function point(x, y) {
|
||||
buffer.push("M", x, ",", y, pointRadius);
|
||||
buffer.push("M", x, ",", y, pointCircle);
|
||||
}
|
||||
function pointLineStart(x, y) {
|
||||
buffer.push("M", x, ",", y);
|
||||
|
@ -6314,10 +6318,10 @@
|
|||
function lineEndPolygon() {
|
||||
buffer.push("Z");
|
||||
}
|
||||
pointRadius = d3_geo_pathCircle(4.5);
|
||||
return stream;
|
||||
}
|
||||
function d3_geo_pathContext(context, pointRadius) {
|
||||
function d3_geo_pathContext(context) {
|
||||
var pointRadius = 4.5;
|
||||
var stream = {
|
||||
point: point,
|
||||
lineStart: function() {
|
||||
|
@ -6330,6 +6334,10 @@
|
|||
polygonEnd: function() {
|
||||
stream.lineEnd = lineEnd;
|
||||
stream.point = point;
|
||||
},
|
||||
pointRadius: function(_) {
|
||||
pointRadius = +_;
|
||||
return stream;
|
||||
}
|
||||
};
|
||||
function point(x, y) {
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -1,4 +1,6 @@
|
|||
function d3_geo_pathBuffer(buffer, pointRadius) {
|
||||
function d3_geo_pathBuffer(buffer) {
|
||||
var pointCircle = d3_geo_pathCircle(4.5);
|
||||
|
||||
var stream = {
|
||||
point: point,
|
||||
|
||||
|
@ -8,11 +10,16 @@ function d3_geo_pathBuffer(buffer, pointRadius) {
|
|||
|
||||
// While inside a polygon, override lineEnd to closePath.
|
||||
polygonStart: function() { stream.lineEnd = lineEndPolygon; },
|
||||
polygonEnd: function() { stream.lineEnd = lineEnd; stream.point = point; }
|
||||
polygonEnd: function() { stream.lineEnd = lineEnd; stream.point = point; },
|
||||
|
||||
pointRadius: function(_) {
|
||||
pointCircle = d3_geo_pathCircle(+_);
|
||||
return stream;
|
||||
}
|
||||
};
|
||||
|
||||
function point(x, y) {
|
||||
buffer.push("M", x, ",", y, pointRadius);
|
||||
buffer.push("M", x, ",", y, pointCircle);
|
||||
}
|
||||
|
||||
function pointLineStart(x, y) {
|
||||
|
@ -32,7 +39,5 @@ function d3_geo_pathBuffer(buffer, pointRadius) {
|
|||
buffer.push("Z");
|
||||
}
|
||||
|
||||
pointRadius = d3_geo_pathCircle(4.5);
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
function d3_geo_pathContext(context, pointRadius) {
|
||||
function d3_geo_pathContext(context) {
|
||||
var pointRadius = 4.5;
|
||||
|
||||
var stream = {
|
||||
point: point,
|
||||
|
||||
|
@ -8,7 +10,12 @@ function d3_geo_pathContext(context, pointRadius) {
|
|||
|
||||
// While inside a polygon, override lineEnd to closePath.
|
||||
polygonStart: function() { stream.lineEnd = lineEndPolygon; },
|
||||
polygonEnd: function() { stream.lineEnd = lineEnd; stream.point = point; }
|
||||
polygonEnd: function() { stream.lineEnd = lineEnd; stream.point = point; },
|
||||
|
||||
pointRadius: function(_) {
|
||||
pointRadius = +_;
|
||||
return stream;
|
||||
}
|
||||
};
|
||||
|
||||
function point(x, y) {
|
||||
|
|
|
@ -5,17 +5,16 @@
|
|||
|
||||
d3.geo.path = function() {
|
||||
var pointRadius = 4.5,
|
||||
pointCircle = d3_geo_pathCircle(pointRadius),
|
||||
projection = d3.geo.albersUsa(),
|
||||
context,
|
||||
buffer = [];
|
||||
buffer = [],
|
||||
stream = new d3_geo_pathBuffer(buffer);
|
||||
|
||||
function path(object) {
|
||||
if (object == null) return;
|
||||
var radius = typeof pointRadius === "function" ? pointRadius.apply(this, arguments) : pointRadius;
|
||||
d3.geo.stream(object, projection.stream(context == null
|
||||
? new d3_geo_pathBuffer(buffer, radius)
|
||||
: new d3_geo_pathContext(context, radius)));
|
||||
d3.geo.stream(object, projection.stream(stream.pointRadius(
|
||||
typeof pointRadius === "function" ? pointRadius.apply(this, arguments) : pointRadius
|
||||
)));
|
||||
if (buffer.length) {
|
||||
var result = buffer.join("");
|
||||
buffer = [];
|
||||
|
@ -47,14 +46,13 @@ d3.geo.path = function() {
|
|||
|
||||
path.context = function(_) {
|
||||
if (!arguments.length) return context;
|
||||
context = _;
|
||||
stream = new d3_geo_pathContext(context = _);
|
||||
return path;
|
||||
};
|
||||
|
||||
path.pointRadius = function(x) {
|
||||
path.pointRadius = function(_) {
|
||||
if (!arguments.length) return pointRadius;
|
||||
if (typeof x === "function") pointRadius = x;
|
||||
else pointCircle = d3_geo_pathCircle(pointRadius = +x);
|
||||
pointRadius = _;
|
||||
return path;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче