4 ms·
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 clas
by chrtze 11y ago
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 https://github.com/gka/d3-jetpack which includes some very nice helper functions!
- lightblade 11y agod3.select('.foo').html('<div class="bar" data-selected="true"/>';
- chrtze 11y agookay, didnt think of that solution! thx!
- silverwind 11y agoWouldn't that replace instead of appending?
- lightblade 11y agoYea, 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));