Hi,
Firstly, thanks for the great library!
I'm pretty new to d3 so sorry if this issue has been discussed somewhere else.
In my d3 v3 code (using coffeescript), I have a lot of attr() calls with multiple values:
svg.append("line").attr
"class" : "date-line"
"y1" : 0
"y2" : height
I just started migrating my code today to v4.1.0 and these lines don't produce errors but they also don't do anything. The only way I can get them to work is to go back to one set of values per attr() call:
svg.append("line")
.attr("class", "date-line")
.attr("y1", 0)
.attr("y2", height)
I couldn't find any reference to this in the api docs or in any other open issues for v4. I'm not sure if this change is by design or a bug but it might be worth mentioning it in the release notes.
Hi in the new version to assign multiple attributes on the same line you need to add d3-selection-multi. Now this functionality is not included with the main d3 import. The command is now called attrs instead of attr.
In the following probably this type of questions should be posted to the google group or stack overflow this is only for bugs and code issues.
Alberto González MartÃnez
[email protected]
On Jul 17, 2016, at 4:54 PM, Adam Grey [email protected] wrote:
Hi,
Firstly, thanks for the great library!
I'm pretty new to d3 so sorry if this issue has been discussed somewhere else.
In my d3 v3 code (using coffeescript), I have a lot of attr() calls with multiple values:
svg.append("line").attr
"class" : "date-line"
"y1" : 0
"y2" : height
I just started migrating my code today to v4.1.0 and these lines don't produce errors but they also don't do anything. The only way I can get them to work is to go back to one set of values per attr() call:svg.append("line")
.attr("class", "date-line")
.attr("y1", 0)
.attr("y2", height)
I couldn't find any reference to this in the api docs or in any other open issues for v4. I'm not sure if this change is by design or a bug but it might be worth mentioning it in the release notes https://github.com/d3/d3/blob/master/CHANGES.md.—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub https://github.com/d3/d3/issues/2907, or mute the thread https://github.com/notifications/unsubscribe-auth/AF9wxExNIEejOXTDbIooZGPJEKHUkUqAks5qWurigaJpZM4JOYWP.
Ok thanks. I will close the issue. It felt like a bug because there is no reference to the behaviour in the docs and no error produced by attr().
See the last paragraph of the release notes on d3-selection, which says:
For the sake of parsimony, the multi-value map methods have been extracted to d3-selection-multi and are no longer part of the default bundle. The multi-value map methods have also been renamed to plural form to reduce overload: _selection_.attrs, _selection_.styles and _selection_.properties.
Thanks, That paragraph makes perfect sense now that I understand. Being a bit of a noob I probably needed something like:
"In v4.0 attr(), style() and property() will not work with multiple values. You now need to add d3-selection-multi and use attrs(), styles() and properties()."
No need to change it though, I think it's just me. I've been using attr() with multiple values so much, I didn't even consider that you would remove it from the default behaviour. Even though you said quite clearly that you had.
I'll be sure to use the google group for questions like this in the future.
I'm having a ball with d3, keep up the great work! Hopefully I'll be able to contribute something back one day.
Thanks for the feedback. I could probably improve the wording!
Most helpful comment
Thanks, That paragraph makes perfect sense now that I understand. Being a bit of a noob I probably needed something like:
"In v4.0 attr(), style() and property() will not work with multiple values. You now need to add d3-selection-multi and use attrs(), styles() and properties()."
No need to change it though, I think it's just me. I've been using attr() with multiple values so much, I didn't even consider that you would remove it from the default behaviour. Even though you said quite clearly that you had.
I'll be sure to use the google group for questions like this in the future.
I'm having a ball with d3, keep up the great work! Hopefully I'll be able to contribute something back one day.