-
Notifications
You must be signed in to change notification settings - Fork 46.5k
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
D3.js Example Using React #782
Comments
https://github.com/facebook/react-art is another project we have that bridges React and ART (https://github.com/sebmarkbage/art/), which uses SVG or even canvas to render. It should be possible to use D3, though I'm not sure anybody has attempted yet. If you're interested in giving it a shot, react-art should be a good reference. |
Cool, this looks very useful. Thanks |
Closing as this is not actionable :) |
Might be of interest: http://bl.ocks.org/herrstucki/9204795 |
I've written about combining React with D3 to create reusable charting components with example bar and line charts. Examples |
The above links are helpful, thanks for sharing. It would be great to see a full blown example of React + D3 + D3 events (such as tooltips on hover), as all current examples I've found appear to just be for static outputs (no event handlers). |
+1 @dhruvbhatia |
If anyone is interested, I created a demo using a D3 force layout and rendering with React. |
@JMStewart Just a quick thought (which probably you are already aware of): In your React example, you are creating a complex hierarchy of objects which are used to determine the required DOM mutations in each tick, whereas in the D3 example the operation is already almost optimal, as it directly mutates the DOM via an existing selection. This is almost optimal, because in a typical force layout simulation almost all nodes actually require an update in each tick. If you'd mutate state on existing React components instead of starting from scratch each time, I'd expect improved performance. |
This is pretty much a worst case for React because you're mutating the entire DOM on every tick so you don't gain anything from the diffing. I personally find the React example easier to reason about even in a simple example like this, but with hundreds of nodes updating on each frame you may find that it's better to do the dom manipulations by hand. |
@spicyj And could it be improved by immutable data structures and/or RAF batching? I've started building an app with lots of charts transitioning on every action (similar to dc.js). Basically a worst-case scenario. |
Not sure if this is the right place to ask, but are there any examples of using React to render a visualization created in D3.js?
It seems like React's Virtual DOM could really speed up animations and transitions used in visualizations like the Force Directed Graph. D3.js just draws SVG, so as long as React can manipulate SVG like DOM it should work, right? I'm still a React newb, so just looking for any suggestions to get me started.
The text was updated successfully, but these errors were encountered: