Add more D3 Transition methods

This commit is contained in:
Richard Birkby
2013-03-27 23:10:11 +00:00
parent d7a3fbe70d
commit a6975c8496
2 changed files with 34 additions and 0 deletions
+30
View File
@@ -699,3 +699,33 @@ function panAndZoom {
svg.select(".y.axis").call(yAxis);
}
}
//Example from http://bl.ocks.org/mbostock/1125997
function chainedTransitions() {
var w = 960,
h = 500,
y = d3.scale.ordinal().domain(d3.range(50)).rangePoints([20, h - 20]),
t = Date.now();
var svg = d3.select("body").append("svg:svg")
.attr("width", w)
.attr("height", h);
var circle = svg.selectAll("circle")
.data(y.domain())
.enter().append("svg:circle")
.attr("r", 16)
.attr("cx", 20)
.attr("cy", y)
.each(slide(20, w - 20));
function slide(x0, x1) {
t += 50;
return function() {
d3.select(this).transition()
.duration(t - Date.now())
.attr("cx", x1)
.each("end", slide(x1, x0));
};
}
}
Vendored
+4
View File
@@ -811,6 +811,10 @@ module D3 {
select: (selector: string) => Transition;
selectAll: (selector: string) => Transition;
each: (type?: string, eachFunction?: (data: any, index: number) => any) => Transition;
transition: () => Transition;
ease: (value: string, ...arrs: any[]) => Transition;
}
interface Nest {