From 0d2c1b528494eaab96b0373a66f7b0fb97968aab Mon Sep 17 00:00:00 2001 From: Matt Huntington Date: Wed, 24 Aug 2016 14:50:28 -0400 Subject: [PATCH] data binding other than index --- D3.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/D3.md b/D3.md index a5ac1b1..9b68978 100644 --- a/D3.md +++ b/D3.md @@ -111,6 +111,15 @@ d3.selectAll('circle')//make a "ghost call" to all circles, even if there are no .remove(); //removes those elements ``` +To bind data to elements by something other than index: + +```javascript +.data(data, function(d){ + //match data based on d.id, not index + return d.id +}); +``` + ## Linear Scale A scale will map a data value to a visual value.