Then you could use an ordinal scale to map the names to shapes, such as:
var type = d3.scale.ordinal()
.domain(["foo", "bar"])
.range(d3.svg.symbolTypes);
Then, change the type accessor for the shape generator so that it's
type(d.name) rather than d.type.
Mike
The first is you could use data to filter and/or compute the new x & y
coordinates dynamically. When you compute the shape type, you're
presumably using data, such as function(d) { return type(d.foo); },
where `d` is your data, `d.foo` is some property of your data object
that determines which shape is assigned, and `type` which is the
ordinal scale I mentioned previously. So, you could for example say:
selection.filter(function(d) { return d.foo == 42; })
to pull out a subset of your elements. Or you could recompute the
attributes for all of them, conditional on the data:
selection.attr("x", function(d) { return d.foo == 42 ? "0%" : "50%"; });
The second option is that you could assign a class to your elements
based on the shape type, and then use that class to reselect them
later. That might look like this:
selection.attr("class", function(d) { return type(d.foo); });
Then, later you can select just a specific shape type, and set new attributes:
d3.selectAll(".square")
.attr("x", …)
.attr("y", …);
Setting a shape-specific class is also nice if you want to style them via CSS.
Mike
> d3.selectAll(".circle")
> .size(500)
> .attr(x, 400);
* Selections don't have a size method. I'm guessing you meant to
recreate the path data, in which case you'd need to use attr("d", …),
and use your d3.svg.shape to recompute the path data with the new
size.
* Did you mean attr("x", 400) rather than attr(x, 400)? The variable
`x` doesn't exist in your code, though it's often used to refer to a
scale. If you were using circle elements, you could say attr("cx",
400) to change the center x-position of the circles. However, you're
using path elements, so you need to update the transform attribute
instead: attr("transform", "translate(400,0)").
Mike
For the first part, read this tutorial:
http://bost.ocks.org/mike/path/
There's also this example:
I'm not sure I understand your second example. Typically you either
schedule multiple transitions with a delay, or you use the transition
"end" event to start another transition. There are lots of examples of
this around, such as the stacked-to-grouped bar chart example on the
website, and this one:
Mike