Created
September 26, 2018 12:06
-
-
Save DavidSanwald/dcb3c1a077fd2492facbec1772a59dd6 to your computer and use it in GitHub Desktop.
saving individual parts of data join
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create single idempotent container that is appended to the DOM only once | |
const container = selection.selectAll('.lines').data([null]).enter().append('g').attr('class', 'lines') | |
// bind data, create and save the update selection | |
let update = container.selectAll('.line') | |
.data(data, d => d.id) | |
// create and save the exit selection | |
let exit = update.exit() | |
// do something with a selection | |
exit | |
.remove() | |
// create and save enter selection | |
let enter = update | |
.enter() | |
// do something with enter selection | |
enter | |
.append('path') | |
.attr('class', 'line') | |
// create and save combined selection | |
let merged = update | |
.merge(enter) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment