Created
September 1, 2015 20:16
-
-
Save mhkeller/a0a2a222e33f5bcacff0 to your computer and use it in GitHub Desktop.
data vs datum
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
var list = [ | |
{obj}, | |
{obj}, | |
{obj}, | |
{obj}, | |
{obj}, | |
{obj}, | |
{obj}, | |
{obj}, | |
{obj} | |
] | |
var response = { | |
length: 10, | |
results: [ | |
{obj}, | |
{obj}, | |
{obj}, | |
{obj}, | |
{obj}, | |
{obj}, | |
{obj}, | |
{obj}, | |
{obj}, | |
{obj} | |
] | |
} | |
d3.selectAll('.container').data(list).enter() | |
d3.select('.container').datum(response) | |
.attr('data-length', function(d){ | |
return d.length | |
}) | |
.selectAll('.item').data(function(d){ | |
return d.results | |
}).enter() | |
.append('div') | |
.attr('data-name', function(d){ | |
return d.name | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment