Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var o = trans ? {} : item,
offset = item.mark.def.offset,
orient = item.mark.def.orient,
width = group.width,
height = group.height; // TODO fallback to global w,h?
if (dl.isArray(offset)) {
var ofx = offset[0],
ofy = offset[1];
switch (orient) {
case 'left': { Tuple.set(o, 'x', -ofx); Tuple.set(o, 'y', ofy); break; }
case 'right': { Tuple.set(o, 'x', width + ofx); Tuple.set(o, 'y', ofy); break; }
case 'bottom': { Tuple.set(o, 'x', ofx); Tuple.set(o, 'y', height + ofy); break; }
case 'top': { Tuple.set(o, 'x', ofx); Tuple.set(o, 'y', -ofy); break; }
default: { Tuple.set(o, 'x', ofx); Tuple.set(o, 'y', ofy); }
}
} else {
if (dl.isObject(offset)) {
offset = -group.scale(offset.scale)(offset.value);
}
switch (orient) {
case 'left': { Tuple.set(o, 'x', -offset); Tuple.set(o, 'y', 0); break; }
case 'right': { Tuple.set(o, 'x', width + offset); Tuple.set(o, 'y', 0); break; }
case 'bottom': { Tuple.set(o, 'x', 0); Tuple.set(o, 'y', height + offset); break; }
case 'top': { Tuple.set(o, 'x', 0); Tuple.set(o, 'y', -offset); break; }
default: { Tuple.set(o, 'x', 0); Tuple.set(o, 'y', 0); }
}
}
if (trans) trans.interpolate(item, o);
prototype.interpolate = function(item, values) {
var key, curr, next, interp, list = null;
for (key in values) {
curr = item[key];
next = values[key];
if (curr !== next) {
if (skip[key] || curr === undefined) {
// skip interpolation for specific keys or undefined start values
Tuple.set(item, key, next);
} else if (typeof curr === 'number' && !isFinite(curr)) {
// for NaN or infinite numeric values, skip to final value
Tuple.set(item, key, next);
} else {
// otherwise lookup interpolator
interp = d3.interpolate(curr, next);
interp.property = key;
(list || (list=[])).push(interp);
}
}
}
if (list === null && item.status === Status.EXIT) {
list = []; // ensure exiting items are included
}
data.forEach(function(n) {
Tuple.set(n, output.x, n.x);
Tuple.set(n, output.y, n.y);
Tuple.set(n, output.width, n.dx);
Tuple.set(n, output.height, n.dy);
Tuple.set(n, output.depth, n.depth);
});
data.forEach(function(n) {
Tuple.set(n, output.x, n.x);
Tuple.set(n, output.y, n.y);
Tuple.set(n, output.depth, n.depth);
if (mode === PARTITION) {
Tuple.set(n, output.width, n.dx);
Tuple.set(n, output.height, n.dy);
}
});
function set(t) {
var path = shape(sourceX(t), sourceY(t), targetX(t), targetY(t), tension);
Tuple.set(t, output.path, path);
}
function update(d) {
var v = get(d),
v = v == null ? null
: b.start + s * ~~((v - b.start) / s);
Tuple.set(d, output.start, v);
Tuple.set(d, output.end, v + s);
Tuple.set(d, output.mid, v + s/2);
}
input.add.forEach(update);
function set(t) {
var ll = [lon(t), lat(t)];
var xy = proj(ll) || [null, null];
Tuple.set(t, output.x, xy[0]);
Tuple.set(t, output.y, xy[1]);
}
data.forEach(function(n) {
Tuple.set(n, output.x, n.x);
Tuple.set(n, output.y, n.y);
Tuple.set(n, output.depth, n.depth);
if (mode === PARTITION) {
Tuple.set(n, output.width, n.dx);
Tuple.set(n, output.height, n.dy);
}
});
data.forEach(function(n) {
Tuple.set(n, output.x, n.x);
Tuple.set(n, output.y, n.y);
Tuple.set(n, output.depth, n.depth);
if (mode === PARTITION) {
Tuple.set(n, output.width, n.dx);
Tuple.set(n, output.height, n.dy);
}
});
ofy = offset[1];
switch (orient) {
case 'left': { Tuple.set(o, 'x', -ofx); Tuple.set(o, 'y', ofy); break; }
case 'right': { Tuple.set(o, 'x', width + ofx); Tuple.set(o, 'y', ofy); break; }
case 'bottom': { Tuple.set(o, 'x', ofx); Tuple.set(o, 'y', height + ofy); break; }
case 'top': { Tuple.set(o, 'x', ofx); Tuple.set(o, 'y', -ofy); break; }
default: { Tuple.set(o, 'x', ofx); Tuple.set(o, 'y', ofy); }
}
} else {
if (dl.isObject(offset)) {
offset = -group.scale(offset.scale)(offset.value);
}
switch (orient) {
case 'left': { Tuple.set(o, 'x', -offset); Tuple.set(o, 'y', 0); break; }
case 'right': { Tuple.set(o, 'x', width + offset); Tuple.set(o, 'y', 0); break; }
case 'bottom': { Tuple.set(o, 'x', 0); Tuple.set(o, 'y', height + offset); break; }
case 'top': { Tuple.set(o, 'x', 0); Tuple.set(o, 'y', -offset); break; }
default: { Tuple.set(o, 'x', 0); Tuple.set(o, 'y', 0); }
}
}
if (trans) trans.interpolate(item, o);
return true;
}