Permalink
Browse files

Add more D3 Transition methods

  • Loading branch information...
1 parent d7a3fbe commit a6975c8496a5edc95c992304cc4f5e0ec01910ed @rbirkby rbirkby committed Mar 27, 2013
Showing with 34 additions and 0 deletions.
  1. +30 −0 d3/d3-tests.ts
  2. +4 −0 d3/d3.d.ts
View
@@ -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));
+ };
+ }
+}
View
@@ -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 {

0 comments on commit a6975c8

Please sign in to comment.