|
|
|
|
|
by udfalkso
2922 days ago
|
|
d3 has a lot of really useful libraries baked in. You can even use them independently and roll your own svg using its components as utilities. I find this super helpful when using d3 as a whole isn't really a good option (as part of a React/React-Native app for example). Such as:
https://github.com/d3/d3-shape https://github.com/d3/d3-scale Doing it from scratch without the help of utilities like these would be much harder. A couple examples: var line = d3.line()
.x(function(d) { return x(d.date); })
.y(function(d) { return y(d.value); })
.curve(d3.curveCatmullRom.alpha(0.5)); line(data); // gives you svg path and var color = d3.scaleLinear().domain([10, 100]).range(["brown", "steelblue"]); color(20); // "#9a3439"
color(50); // "#7b5167" |
|