question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

v4 .attr() fails silently with multiple arguments

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
greyman888commented, Jul 19, 2016

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.

1reaction
mbostockcommented, Jul 18, 2016

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Attribute may silently crash · Issue #3769 - GitHub
IntelliSenese work for Param1 and don't work for Param2 with error message or IntelliSenese don't work for both parameters with appropriate ...
Read more >
How can you set class attributes from variable arguments ...
that takes a variable number of arguments and then sets them as class attributes conditionally.
Read more >
8 Conditions | Advanced R - Hadley Wickham
Section 8.4 introduces the condition object, and the two fundamental tools of condition handling: tryCatch() for error conditions, and withCallingHandlers() ...
Read more >
The 10 Most Common JavaScript Issues Developers Face
If you need help figuring out why your JavaScript isn't working, consult this list of the 10 most common JavaScript issues from a...
Read more >
Built-in Exceptions — Python 3.11.1 documentation
This exception is raised when a system function returns a system-related error, including I/O failures such as “file not found” or “disk full”...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found