Indented tree, a few simple questions

21 Aufrufe
Direkt zur ersten ungelesenen Nachricht

Bob Monteverde

ungelesen,
04.10.2011, 16:00:0104.10.11
an protovis
I'm working on an indented tree to show something similar to a
directory structure. I'm starting with a flat list of objects that
have different key/values where some I will be grouping by, some I
will be displaying as 'file meta data'

My primary issue is, I'm trying to figure out how to make the leafs
objects (instead of just a key) that way I can display more than just
the name (date created, owner, permissions, etc)


So, testdata is the flat list of objects. For now I am grouping by
year, then month, then displaying the name. Basically, if rollup
returns an object, the indented tree graph thinks the leaf is actually
another node, and each of its keys are the leaves. Is there a way to
have the leaves as an object?


var nest = pv.nest(testdata)
.key(function(d) { return d.year })
.key(function(d) { return monthnames[d.month] })
.key(function(d) { return d.name })
.rollup(function(d) { return d.date });


I will probably have some other small questions (this is my first time
using the pv.nest function), but this seems to the the primary thing
holding me back right now.

Thank you!

Bob Monteverde

ungelesen,
05.10.2011, 16:39:4305.10.11
an protovis
OK, so I needed the 'leaf' function... I'm doing something like this:

var root = pv.dom(data)
.leaf(function(n) { return n.leaf })
.root("Documents")
.sort(function(a, b) { return pv.naturalOrder(a.nodeName,
b.nodeName) });


Also, since I wanted a very specific data structure, changed my nest
structure to:

var nest = pv.nest(testdata)
.key(function(d) { return d.year })
.key(function(d) { return monthnames[d.month] })
.key(function(d) { return d.name })
.rollup(function(d) { return d[0] });

I don't know if that's the best way to get the results I wanted, but
it definitely works. And just mapped "leaf: true" to the originally
array of values.

Always willing to hear some advice on how I can do things better if
nayone has any.
Allen antworten
Antwort an Autor
Weiterleiten
0 neue Nachrichten