Created
April 21, 2017 15:52
-
-
Save ramboldio/851f20923f2b9f5694baab3520aac00b to your computer and use it in GitHub Desktop.
Reasonable d3.js (v4) update logic
This file contains hidden or 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
_updated3 : function (canvas, data) { | |
// JOIN data to canvas and provide selection object | |
const circlesSelection = canvas.selectAll("circle").data(data); | |
// get circles which have to be added and subtracted | |
const circlesToAdd = circlesSelection.enter(); | |
const circlesToRemove = circlesSelection.exit(); | |
// create and delete svg object | |
const newCricles = circlesToAdd.append(d3.creator("circle")); | |
const obsoleteCircles = circlesToRemove.remove(); | |
// get currently visible circles | |
const currentCircles = newCricles.merge(circlesSelection); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment