D3js plugin for clone nodes from selections.
npm install d3-cloned3-clone
========




D3js plugin for clone nodes from selections.
The d3-clone add methods to append and insert a duplicate of the selection on which this method was called.
This methods copy all of its attributes and their values, including intrinsic (in–line) listeners. It does not copy the data of the original selection.
You can see the running example on this link
Install
-------
To install via NPM use npm install d3-clone. You can also load directly from unpkg.com.
``html
`
`
How to use it
-------------
Append clone
selection.appendClone(source)`
svg.select('#source')
This example append the node selected by to each node selected from svg.selectAll('.node').
`
javascript
`
var nodes = svg.selectAll('.node')
.exit().remove()
.data(data).enter()
.appendClone(svg.select('#source'));
`
if you've start with this HTML structure
html
`
`
after run the code you'll have
html
`
`
Insert clone
selection.insertClone(source, before)`
svg.select('#source')
This example insert the node selected by to each node selected from svg.selectAll('.node') before the svg.select('#existing_node').
`
javascript
`
var nodes = svg.selectAll('.node')
.exit().remove()
.data(data).enter()
.insertClone(svg.select('#source'), svg.select('#existing_node'));
`
if you've start with this HTML structure
html
`
`
after run the code you'll have
html
``