MCPcopy Create free account
hub / github.com/microsoft/SandDance / fitExtent

Function fitExtent

docs/app/js/sanddance-app.js:134071–134079  ·  view source on GitHub ↗
(projection, extent, object)

Source from the content-addressed store, hash-verified

134069 return projection;
134070}
134071function fitExtent(projection, extent, object) {
134072 return fit(projection, function(b) {
134073 var w = extent[1][0] - extent[0][0], h = extent[1][1] - extent[0][1], k = Math.min(w / (b[1][0] - b[0][0]), h / (b[1][1] - b[0][1])), x = +extent[0][0] + (w - k * (b[1][0] + b[0][0])) / 2, y = +extent[0][1] + (h - k * (b[1][1] + b[0][1])) / 2;
134074 projection.scale(150 * k).translate([
134075 x,
134076 y
134077 ]);
134078 }, object);
134079}
134080function fitSize(projection, size, object) {
134081 return fitExtent(projection, [
134082 [

Callers 1

fitSizeFunction · 0.70

Calls 4

fitFunction · 0.70
minMethod · 0.45
translateMethod · 0.45
scaleMethod · 0.45

Tested by

no test coverage detected