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

Function fitWidth

docs/app/js/sanddance-app.js:134089–134097  ·  view source on GitHub ↗
(projection, width, object)

Source from the content-addressed store, hash-verified

134087 ], object);
134088}
134089function fitWidth(projection, width, object) {
134090 return fit(projection, function(b) {
134091 var w = +width, k = w / (b[1][0] - b[0][0]), x = (w - k * (b[1][0] + b[0][0])) / 2, y = -k * b[0][1];
134092 projection.scale(150 * k).translate([
134093 x,
134094 y
134095 ]);
134096 }, object);
134097}
134098function fitHeight(projection, height, object) {
134099 return fit(projection, function(b) {
134100 var h = +height, k = h / (b[1][1] - b[0][1]), x = -k * b[0][0], y = (h - k * (b[1][1] + b[0][1])) / 2;

Callers

nothing calls this directly

Calls 3

fitFunction · 0.70
translateMethod · 0.45
scaleMethod · 0.45

Tested by

no test coverage detected