Hacker Newsnew | past | comments | ask | show | jobs | submit | chrtze's commentslogin

Thanks, Felix ;)


We wanted to focus more on tools and plugins, not on visualization examples because many resources for that already exist.


Good enough reason, I'll certainly be using your resource, thanks :)


Sorry, haven't seen that one.


I like the code examples for every library presented in the article.


D3 implements many other features like scales and stuff. The two just have some parts in common when it comes to DOM-manipulations and selections.


totally understand that. i'm just wondering why the authors would want to write methods for DOM manipulation in the first place when they could piggyback off jQuery for that and concentrate on the other stuff.


I appreciate that they didn't. I don't like jQuery. I'm forced to use it for work sometimes, but on side projects I won't touch it. However, I do like D3 a lot for visualization work. If D3 piggybacked onto jQuery, I would find it a lot less palatable.

That said, the way D3 does selections/grouping is much more complex than jQuery. Sure, on the surface level they do the same thing (selecting DOM nodes), but where D3 diverges is the ability to represent DOM nodes as data you tie to it. So your array and your <circle> elements are 1:1, or perhaps your array elements have sub-arrays...D3 can easily tie those sub-arrays into sub-DOM-elements, all while letting you address different pieces of the tree easily.

They are two different beasts. One is a DOM library, one is a visualization library. There is really not a whole lot of intersection beyond some basic operations.


Yes you can. Both libraries are based on document.querySelectorAll which has the same selectors as you know them from CSS.


That's true. I am still often missing the shorthand versions if jQuery when working with d3. For example doing something like this:

$('.foo').append('<div class="bar" data-selected="true"/>');

in d3 I have to go the long way:

d3.select('.foo') .append('div') .classed('bar', true) .attr('data-selected', true);

I have recently worked a lot with this plugin https://github.com/gka/d3-jetpack which includes some very nice helper functions!


d3.select('.foo').html('<div class="bar" data-selected="true"/>';


Wouldn't that replace instead of appending?


Yea, that's something d3 can't do: convert raw HTML to DOM nodes the way that $.parseHTML do.

But if you can do that...

d3.select('.foo').append(d3.functor(node));


okay, didnt think of that solution! thx!


From my perspective I would rather have $.select() instead of $() because it makes more clear what this function actually does.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: