Pre-build array to keep track of symbol IDs?

9 views
Skip to first unread message

Dan

unread,
Sep 26, 2011, 9:21:25 AM9/26/11
to d3-js
I wrote a D3 related question over here at Stackoverflow:
http://stackoverflow.com/questions/7555649/keeping-track-of-object-ids-according-to-criteria

Any input appreciated :)

Btw, someone with more reputation than me on Stackoverflow should
start a d3 tag :)

/dan

Jason Davies

unread,
Sep 26, 2011, 9:44:19 AM9/26/11
to d3...@googlegroups.com
On Mon, Sep 26, 2011 at 06:21:25AM -0700, Dan wrote:
> Btw, someone with more reputation than me on Stackoverflow should
> start a d3 tag :)

I think someone has already created one:

http://stackoverflow.com/questions/tagged/d3.js

--
Jason Davies, http://www.jasondavies.com/

Chris Viau

unread,
Sep 26, 2011, 10:20:06 AM9/26/11
to d3...@googlegroups.com
Why don't use two arrays, one for living and one for dead, containing just id's?

Your structure: 
{living: 5, dead: 1} =>
[{id: 1, type : living}, {id: 2, type : living}, 
 {id: 3, type : living}, {id: 4, type : living}, 
 {id: 5, type : living}, {id: 6, type : dead}]

Becomes something like:
{living:[1, 2, 3, 4, 5], dead:[6]}

And for new id's you just increment a counter.

Daniel

unread,
Sep 26, 2011, 11:04:16 AM9/26/11
to d3-js
Jason: Ahh, of course. Forgot the .js part :=)
Chris: Thanks for the suggestion, this will probably make it easier to
keep track of which symbol to tween. But perhaps I'm still making it
more complex than necessary?

/D
Reply all
Reply to author
Forward
0 new messages