D3v4 compatibility #23

Closed
joemaller opened this Issue Jul 10, 2016 · 3 comments

Projects

None yet

1 participant

@joemaller
Contributor
joemaller commented Jul 10, 2016 edited

There seem to be a few things breaking with D3v4. I think most of them are related to D3's updated selection methods.

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.

Changing all the .attr calls to .attr is east enough. But changes to selection.call seem like they're going to be trickier.

The selection.call method no longer sets the this context when invoking the specified function; the selection is passed as the first argument to the function, so use that.

I'm having issues with call in other places too, but I'm trying to get this working.

@joemaller
Contributor

the multi-value map methods have been extracted to d3-selection-multi and are no longer part of the default bundle.

Wish I'd read that more carefully. Using selection.attrs means textures.js is also dependent on d3-selection-multi.

@joemaller
Contributor

Got it working with a surprisingly minor change to the pattern factory functions:

lines = (sel) ->
  g = sel.append "defs"
      .append "pattern"
      .attrs
        id: id

Problem is, switching to selection.attrs broke backwards compatibility, otherwise that code works in v3 and v4.

My attempts at hacking in a .attrs polyfill for v3 haven't worked so far.

Converting all the attrs calls back to chained, singular .attr statements seems big enough that it should be it's own PR, but maybe translating those is the best solution.

@joemaller
Contributor

That wasn't so bad. Sending an object to .attr was just a convenience anyway. PR incoming.

@joemaller joemaller added a commit to joemaller/textures that referenced this issue Jul 10, 2016
@joemaller joemaller update textures.js and textures.min.js. Closes #23
tools:
- coffee-script@1.10.0
- uglify-js@2.7.0
6212045
@joemaller joemaller added a commit to joemaller/textures that referenced this issue Jul 10, 2016
@joemaller joemaller update textures.js and textures.min.js. Closes #23
tools:
- coffee-script@1.10.0
- uglify-js@2.7.0
9d1b15b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment