Live data from Hacker News

Bivariate Maps with React and D3

github.com

11–17 of 17 posts

Re: Bivariate Maps with React and D3

#11

It 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 creator admits this in the README: 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 dashboa…

There is a better way to create reusable and composable components: Web Components. Read about it here: https://developer.mozilla.org/en-US/docs/Web/Web_Components

Re: Bivariate Maps with React and D3

#13

Earlier quoted context omitted.

The creator admits this in the README: 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 dashboa…

There is a better way to create reusable and composable components: Web Components. Read about it here: https://developer.mozilla.org/en-US/docs/Web/Web_Components

I highly recommend against using web components. Polymer has failed to take off in the past 3/4 years, and there are performance issues across browsers.

Subjectively, I didn’t find the API all that great either.

Re: Bivariate Maps with React and D3

#15
post #5

It 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?

I think biggest reason to use React was great create-react-app for developer setup.

Fast and easy to start and expand as needed.

Re: Bivariate Maps with React and D3

#16

It 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 creator admits this in the README: 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 dashboa…

That answers the question of "why use React". But that wasn't my question. My question is "why use D3".

I've been using D3 for a couple years now, and it's so low-level that I really don't feel like it abstracts very much for me. Using React, I can easily build an abstraction over an SVG path element that receives datapoints and produces a `d` attribute.

Re: Bivariate Maps with React and D3

#17
post #13

Earlier quoted context omitted.

There is a better way to create reusable and composable components: Web Components. Read about it here: https://developer.mozilla.org/en-US/docs/Web/Web_Components

I highly recommend against using web components. Polymer has failed to take off in the past 3/4 years, and there are performance issues across browsers. Subjectively, I didn’t find the API all that great either.

Polymer is crap. Web Components are great. There is definitely no performance issues. Ditch polymer and other such bloated libs. Try this 200-line lib instead: https://github.com/wisercoder/uibuilder
Post reply on HN