New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A more compact attribute syntax? #55
Comments
I like this idea, I thought about suggesting it too! It does take a bit longer to type |
That sounds reasonable to me, although I'd prefer to use a separate method (say, There's also the API parsimony downside, which I think is more significant. Presumably we want to extend this to Or… not that this is a good idea, an
|
I think
Assumes that I'm not sure if it should be included in D3 because then it would affect parsimony (love that word!) as you say :) |
That's pretty clever. We could add that as |
I guess we could add some |
Thanks for considering this, I really appreciate it. Let me know if you need anybody to test out a new format, I'd be happy to help. |
An alternate syntax I used initially by accident: |
I'm learning towards the initial recommendation of a map for Although, there's another question here, should you be able to pass a function to
Or can you assign a function to an attribute of the map?
Supporting both seems like a pain, but I kind of like the idea of allowing a function that generates a map—that way you can actually set different attributes on different elements in the same selection, which might be useful. It also would allow us to build helper classes that set multiple attributes (although we can do that already using |
See also discussion in #65. |
I think this compact approach would make sense for "style" and "on" as well, and the second argument to append (to eliminate need for attr/s in many cases). |
So, having a single argument version of Supporting a single-argument function that generates a map sounds less desirable than a single-argument map; and if we take a single-argument map, then we should allow the values to be functions for consistency with the existing interface. That suggests we could support taking a map for Lastly, I'm against |
Great, that sounds cool to me, thanks! Brett On 3/23/2011 12:53 PM, mbostock wrote:
|
On 3/23/2011 12:53 PM, mbostock wrote:
Sure, it's reasonable, but it's used a lot, and I think attributes tend I'd think that styles could also be treated as an attribute if "style" But whatever you like is ok with me. Thanks, |
See pull request #179. Should be able to incorporate this into the next release! |
Folding this discussion into #277. |
Fix missing values for defaultOrder and offsetZero
I've been using raphael lately and I really like the ability to make a set of attributes, see the example below. Does this functionality exist in d3? Do you think it ever would?
//d3 way to make a simple circle.
p.append("svg:circle")
.attr("cx", 150)
.attr("cy", 140)
.attr("r", 40)
.attr("fill", "#F00")
.attr("stroke", "black");
// The way I would like to do it.
p.append("svg:circle").attr({cx: 250, cy: 240, r: 40, fill: "#F00", stroke:"black"});
The text was updated successfully, but these errors were encountered: