Hacker News new | ask | show | jobs
by ar15saveslives 3332 days ago
D3.js is quite low-level library, it's basically a wrapper around SVG with some sugar like animations and enter/exit/update.

> Is the most apparent benefit less lines of code?

Yes! With "reusable components" you don't need to write (or copypaste) a line chart over and over.

From their demos:

    brushChart
        .width(containerWidth)
        .height(300)
        .onBrush(function(brushExtent) {
        // Do something with the brushExtent
        });

    brushContainer.datum(dataset).call(brushChart);
1 comments

>D3.js is quite low-level library, it's basically a wrapper around SVG with some sugar like animations and enter/exit/update.

While D3 is low level, it's in no way just a "wrapper around SVG with some sugar thrown in".

Besides the tons and tons of helpers for scales, mapping, projections, calculations and all that jazz (including the animation stuff with enter/exit etc which you did mention), it's also a whole functional concept on top of the drawing primitives.

One could theoretically even remove SVG and add another rendering backend with D3 with the same top level primitives.

I use D3 for all kinds of non SVG DOM work.
I am interested on that, do you have some snippets or examples of it?