Bivariate Maps with React and D3
github.com
Bivariate Maps with React and D3
1–10 of 17 posts
Re: Bivariate Maps with React and D3
#2Re: Bivariate Maps with React and D3
#3It seems weird to pair D3 with React, since D3 is just another abstraction over the DOM, just like React. Why not just render the graphics with React?
React has tools for state management, code reuse, routing and other common front-end needs and leaves the DOM content to be decided by the coder with XML-like markup. D3 abstracts over the DOM content to handle the specifics of rendering while the coder focuses on the data.
Pairing D3 with React or Vue is a very common decision. Because this project seems to make little use of React beyond memoization I would think that doing without React would be much more plausible.
Re: Bivariate Maps with React and D3
#4It seems weird to pair D3 with React, since D3 is just another abstraction over the DOM, just like React. Why not just render the graphics with React?
Re: Bivariate Maps with React and D3
#5It seems weird to pair D3 with React, since D3 is just another abstraction over the DOM, just like React. Why not just render the graphics with React?
{geoJson.features.map(feature =>
)}
I was thinking maybe React was also used with this visualization in production (e.g. adding interactive elements for a published story), and so maybe the author found it easy to use React for the rendering too?Re: Bivariate Maps with React and D3
#6It seems weird to pair D3 with React, since D3 is just another abstraction over the DOM, just like React. Why not just render the graphics with React?
Re: Bivariate Maps with React and D3
#7It seems weird to pair D3 with React, since D3 is just another abstraction over the DOM, just like React. Why not just render the graphics with React?
The use of react is hereby not sctrictly necessary and much of the code found in SwissMap.js is also valid for other programming environments.
The usefulness of combing react and d3 is that you can create reusable and composable components, instead of creating something news every time you need a specific chart/map. This makes it easier to create more complex things like dashboards or UIs.Re: Bivariate Maps with React and D3
#8It seems weird to pair D3 with React, since D3 is just another abstraction over the DOM, just like React. Why not just render the graphics with React?
I couldn't see a reason for React to be used in this visualization either. It's been awhile since I've used D3 but I thought it could do this kind of rendering on its own? {geoJson.features.map(feature => )} I was thinking maybe React was also used with this visualization in production (e.g. adding interactive elements for a published story), and so maybe the author found it easy to use React for the rendering too?
To me this is more readable and easy to understand, but you don't really need react to do any of this. This can also be done with plan js.
Re: Bivariate Maps with React and D3
#9Re: Bivariate Maps with React and D3
#10It seems weird to pair D3 with React, since D3 is just another abstraction over the DOM, just like React. Why not just render the graphics with React?
D3 has many parts. d3-selection ( https://github.com/d3/d3-selection ) is the only part that deals with the DOM (I think). It wouldn't make much sense to use it with React, but the rest of D3 can easily be combined with React.