DEV Community

Build your React charts without a library

Ed Bentley on April 01, 2020

So you want to build a chart in your React app? If you're like me, the first thing you did was search for something like "react charting library". ...
Collapse
 
meatnordrink profile image
AndyG

This is the second "Make your own chart in React" demo I've seen, and both use bar charts. I need line graphs more often; it strikes me that building a line graph (particularly with bezier curves between the points) would be much more challenging to do using React/SVG; or am I mistaken? (I'm not familiar at all with using SVG.)

Collapse
 
akirautio profile image
Aki Rautio

I very much like this approach and thanks from the very practical explanations! :)

This definitely takes longer time to develop than using a library for most use cases but if the need is very specific it may be easier to build from the scratch than trying to figure out how to the library handles it.

Collapse
 
larrykubende profile image
Larry Karani Kubende

const yRatio = (dataY - dataYMin) / dataYRange;

this will always return 0 for the data with the minimum