|
|
|
|
|
by jrmoran
5406 days ago
|
|
I might be missing something, since I just started learning it. But instead of drawing a circle like this sampleSVG.append("svg:circle")
.style("stroke", "gray")
.style("fill", "white")
.attr("r", 40)
.attr("cx", 50)
.attr("cy", 50)
.attr("width", 100)
.attr("height", 100);
I'd prefer to express it like this sampleSVG.append("svg:circle")
.style({
"stroke": "gray",
"fill": "white"})
.attr({
"r": 40,
"cx": 50,
"cy": 50,
"width": 100,
"height": 100});
That way, I can just pass object literals as arguments to functions such as attr. |
|
https://github.com/mbostock/d3/commits/map https://github.com/mbostock/d3/pull/179
We're working on this syntax for: style, classed, property, on, attr, attrTween, style, styleTween. It's a more concise syntax, especially when the attrs are functions. An example from the tutorial:
Becomes: Three anonymous functions become a single function which returns an object.