Created
February 13, 2015 20:19
-
-
Save FrankHassanabad/95f3886260c02b89ca84 to your computer and use it in GitHub Desktop.
Change three little circles
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
//On the page http://bost.ocks.org/mike/circles/ | |
//This will change the first set of circles as an example of | |
//how all of that works. Paste this into your chrome console | |
//when on that page and then execute changeFirstCircles([4, 4, 4]) | |
//or any other numbers you want. | |
var chanageFirstCircles = function(newDataSet) | |
{ | |
// Generic function that binds the data | |
var f = function(d) { return d; } | |
// Get the first svg | |
var svg = d3.select('svg'); | |
// Add the data | |
var circles = svg.selectAll('circle').data(newDataSet); | |
// Change the existing data | |
circles.attr('r', f).attr('cx', f).attr('cy', f); | |
// Add the new data | |
circles.enter().append('circle').attr('r', f).attr('cx', f).attr('cy', f); | |
// Remove the old data | |
circles.exit().remove(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment