by joelburget on 7/18/16, 12:47 PM with 79 comments
by krebby on 7/18/16, 3:38 PM
React as an ecosystem is pretty fantastic but the React animation story is still pretty terrible unfortunately. "Portals" / "reparenting" is a majorly hacky way of getting an element from one part of the DOM to another, and even React Motion, which solves a few of the animation gripes, is hard to use, slow, and brittle in my experience. There just isn't a good substitute for the enter-update-exit selections that make up the core of D3.
My usual workflow is to get as much DOM building done in React as I can, with D3 filling out the tricky bits. D3's lifecycles and direct DOM manipulation are much more complicated to reason about than React, on the whole.
by weego on 7/18/16, 2:18 PM
Different for the sake of different is fine, but "preferable" is a bold statement that appears to have no evidence.
by deno on 7/18/16, 3:17 PM
> let React do all the migraine-inducing heavy lifting to figure out what to enter and exit, and have D3 take care of the updates.
https://medium.com/@sxywu/on-d3-react-and-a-little-bit-of-fl...
by colinmegill on 7/18/16, 7:53 PM
Wrote an article on this concept last year: http://formidable.com/blog/2015/05/21/react-d3-layouts/
and spoke about it at Reactive2015: https://www.youtube.com/watch?v=n8TwLWsR40Y
Have been doing data visualizations like this ever since, it works. Yes, the hardest part is animation, which we had to address, as well as the axis components and other higher order functionality that builds on d3 itself:
https://github.com/FormidableLabs/victory-animation
http://formidable.com/open-source/victory/docs/victory-axis/
by dechov on 7/18/16, 3:41 PM
As others are alluding to, transitions are not currently so easy to express with React alone. We wrote and recently open-sourced a React component that aims to encapsulate the power and simplicity of d3 transitions (feedback & contributions welcome): https://github.com/dechov/join-transition/
by otoburb on 7/18/16, 2:29 PM
According to the changelog for the recently released version 4.0.0 of D3.js by Mike Bostock[1], one of the big shifts is for D3 v4.0.0 to be "composed of many small libraries that"[2] can be used independently. So the author of D4.js can now more easily examine Bostock's refactored code for Zoom and Drag as they please.
by aurelianito on 7/18/16, 7:34 PM
I did that! One function that receives actions for update, create, delete, etc. Now my code is easier to read. Check the function gupChildren (AKA: General update pattern for child nodes of a selection) in my code, and feel free to use it: https://bitbucket.org/aurelito/sandro-lib/src/83b81c4b556848...
At last, unless you understand what you are doing, use selectAll and no select.
Cheers!
by jordache on 7/18/16, 3:19 PM
by jtwaleson on 7/18/16, 2:24 PM
by pathsjs on 7/18/16, 3:58 PM
For the animations, it is often just a matter of continuosly updating the state of some component, something that I did in this mixin https://github.com/andreaferretti/paths-js-react-demo/blob/m...
by athenot on 7/18/16, 6:50 PM
- Basically the data fetches get pushed to a lightweight queue/topic system in the browser (using publish.js).
- Each part of the page listens for messages it cares about and updates the page accordingly.
There is still some of the d3 plumbing (I must specify how updates differ from mere element creations, and handle the exits). But I still get a nice decoupling between the different parts of my app. Coupled with browserify, this ends up with semantics not unlike Erlang (I even named the listener method "receive" and it acts on patterns of messages).
by koopatrol on 7/18/16, 1:15 PM
by b34r on 7/19/16, 12:59 AM
by FoeNyx on 7/18/16, 4:41 PM
by guylepage3 on 7/18/16, 2:39 PM
by adamwong246 on 7/18/16, 2:46 PM
by nthitz on 7/18/16, 2:34 PM
by choward on 7/18/16, 10:01 PM
by colemannerd on 7/18/16, 3:05 PM