5 ms·
How much extra work would it have been, percentage-wise, to write the whole thing from scratch? What features did D3 give you for free?
by amelius 8y ago
How much extra work would it have been, percentage-wise, to write the whole thing from scratch? What features did D3 give you for free?
- teachrdan 8y agoNot OP, but a someone who uses D3 every day, it gives you (almost) total freedom. You can decide where to put your x and y axes, legends, labels, etc. You can decide how data determines not just how something appears on the screen (like a bar chart of y height) but how the underlying data determines its classes and styling, etc. D3 is awe-inspiring in its scope, and learning to use it has a steep learning curve. But for anything beyond trivial use cases the freedom it affords you is worth the effort.
- shostack 8y agoAny beginner resources you'd recommend for someone looking to get started with D3 and beginner coding experience?
- jacobolus 8y agoGo to https://beta.observablehq.com https://beta.observablehq.com and dive in: just start forking other people’s examples and fiddling and looking up stuff in the docs or asking for help whenever you get stuck.
- bulldoa 8y agodo you have any recommendation on resources on d3 for beginners? Personally I find d3.js very challenging, there is tons of example out there and simple tutorials, but I don't think there are tutorials that bridge those harder examples for beginners.
- BigJono 8y agoThe documentation. https://github.com/d3/d3/wiki/Tutorials https://github.com/d3/d3/wiki/Tutorials
- BigJono 8y agoI must be missing something, this doesn't answer the question at all. Literally everything you said is true for just building the graph in JS/SVG. What does D3 give on top of that?
- bsaunder 8y agoD3 particularly excels at graph animations and data transforms (as might be helpful to facilitate graphing). Its one of the most comprehensive graphing libraries around. Well written code that uses it looks like pure elegance. Its amazing how much functionality you can get out of so little code. It does take some time and a solid understanding of javascript and scope.
- fatbird 8y agoIf you do it yourself in straight JS, you'll very quickly start building the common tools of D3: various scaling mechanisms mapping the domain to the pixels, data binding against a set of DOM elements, converting an array of data values to the co-ordinates for the d attribute of an SVG path, etc. Somewhere else someone described D3 as a hammer, and that's a good analogy, because if you don't start with a hammer, it's the first tool you'll make for yourself when you need to pound nails.
- ryan-allen 8y agoIt's an API for building custom charts. It's a huge step up from having to fully 'roll your own'. If you have to do any kind of vis that isn't available in the various off the shelf libraries, you can put it together with D3 easier than you could if you fully DIY a solution. It's well thought out but you have to use it for that to be more obvious. This book (by the D3 author) got me started, it's worth the hassle of learning [0]. [0] http://alignedleft.com/work/d3-book http://alignedleft.com/work/d3-book
- jacobolus 8y agoThe creator of D3 is Mike Bostock. That book is by Scott Murray.
- fortylove 8y agoIt gives you a well defined set of primitives to work with. It's also a well established library, so there are a number of good resources on it (and it's seems to be mostly bug free).
- deleted 8y ago[deleted]
- udfalkso 8y agod3 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-shape https://github.com/d3/d3-scale 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"
- substack 8y agoThat's not really a fair comparison. Just because something is "baked in" doesn't mean you can't get similar functionality from other libraries in a more ala-carte fashion.
- udfalkso 8y agoIt is a la cart here. Look at those two repos as examples.
- enjalot 8y agoit is alacart and baked in at the same time! This article breaks down the API in graleater detail. https://medium.com/@Elijah_Meeks/d3-is-not-a-data-visualization-library-67ba549e8520 https://medium.com/@Elijah_Meeks/d3-is-not-a-data-visualizat... All of the functionality in d3 is split up into smaller modules that can be required independently.
- jamra 8y agoD3 gives you a diff algorithm for free. That handles adding new items to your visualization, updating existing ones, and removing them. You implement the enter, exit, and update (update may have been deprecated). That makes it easy to take your data and handle changes. It will handle animations in a very easy way for each of those cases as well. In data visualization, creating a scale based on the domain of your data (the range of your data) is annoying. This is handled for you by utility libraries in d3. It also can draw the line ticks of the scale without issues. Also placing labels is not too easy. D3 does that nicely. The truth is you can do all of that yourself, but if I were to try it, I would go over the d3 utilities first just to see how complicated some of the visual aspects you haven’t thought of but will need are. The drawing part of d3 (SVG, canvas) are not so hard to do on your own, but the way d3 isolates the context of what you are coding is very helpful. I’ve only run through the examples and read the d3 book as well as several other charting books, but I don’t use d3 on a day to day. But let’s go over a more realistic example. In one of my books, the author writes about simple line charts and displaying the quartiles (made by standard deviations) of the data. None of my charting libraries handle that. Rolling my own would be very time consuming. Doing this in d3 would be more feasible than the alernatives.
- stephen_g 8y agoThe last thing I did in D3 probably would have taken several times more effort with raw SVG and JS, I expect. I couldn't find a higher level graphing library that would let me do what I really wanted at all (a custom radial graph that had fairly complex user interaction), and D3 was a perfect sweet spot I think. It gives you a whole lot of helper functions that really speed things up, data binding, animations, transitions, etc.