Last active
November 19, 2017 17:04
-
-
Save limscoder/ea96bd30b4f761a0f690548bff442bc3 to your computer and use it in GitHub Desktop.
D3 data selection
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
// html: | |
// <ul> | |
// <li></li> | |
// <li></li> | |
// </ul> | |
const users = [{ | |
id: 1, | |
name: 'Nancy', | |
role: 'person' | |
}, { | |
id: 2, | |
name: 'Bart', | |
role: 'cartoon' | |
}, { | |
id: 3, | |
name: 'Maggie', | |
role: 'cartoon' | |
}]; | |
const selection = d3.select('ul.app-user-list') | |
.selectAll('li.app-user') | |
.data(users); | |
// prints "2" | |
// Nancy and Bart datums were matched to the two "li" elements in the document. | |
console.log(selection.size()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment