Вход Регистрация
Файл: src/public/plugins/metrics-graphics/misc/transitions.js
Строк: 50
<?php
// http://bl.ocks.org/mbostock/3916621
function path_tween(d1precision) {
  return function() {
    var 
path0 this,
        
path1 path0.cloneNode(),
        
n0 path0.getTotalLength() || 0,
        
n1 = (path1.setAttribute("d"d1), path1).getTotalLength() || 0;

    
// Uniform sampling of distance based on specified precision.
    
var distances = [0], 0dt precision Math.max(n0n1);
    while ((
+= dt) < 1distances.push(i);
    
distances.push(1);

    
// Compute point-interpolators at each distance.
    
var points distances.map(function(t) {
      var 
p0 path0.getPointAtLength(n0),
          
p1 path1.getPointAtLength(n1);
      return 
d3.interpolate([p0.xp0.y], [p1.xp1.y]);
    });

    return function(
t) {
      return 
"M" points.map(function(p) { return p(t); }).join("L") : d1;
    };
  };
}

MG.path_tween path_tween;
?>
Онлайн: 2
Реклама