You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The cross operator (as in the splom example) is very useful for recreating something like the Protovis data stack, where data from multiple levels in the hierarchy is available in the property functions.
The implementation is simple, if a bit confusing. Take an array a. To use this array as data, as the y attribute of each element, crossed with the enclosing parent's data as the x attribute:
function cross(a) {
return function(d) {
var c = [];
for (var i = 0, n = a.length; i < n; i++) c.push({x: d, y: a[i]});
return c;
};
}
Another possibility might be to pull the parent data out of the current group in the property function (group.parentData). But, we don't currently expose the group index (j) or the group itself in the property function. We could pass these as two additional arguments to the property function, similar to Protovis but limited to the immediate enclosing parent, but I like the current simplicity. The extra arguments were a frequent source of confusion in Protovis.
Yet another possibility is for a parentData() method (or similarly a group() method that returns the current group, changing the node returned by node(), etc.), but that requires keeping state within the selection, which I don't like because of reentrancy issues.
So, I like the idea of the cross operator making the access of the parent data more explicit. But I'm not sure about the efficiency or the semantics.
The text was updated successfully, but these errors were encountered:
You can obviate the need for a cross operator by using recursive evaluation, via each. The nice thing is it allows access to parent data, as with Protovis, and avoids flattening (embedding) the parent data into child data. The downside is that it could make later updates more difficult, because if you reselect the children you'll be outside of the closure and so won't have access to the parent data…
The
cross
operator (as in the splom example) is very useful for recreating something like the Protovis data stack, where data from multiple levels in the hierarchy is available in the property functions.The implementation is simple, if a bit confusing. Take an array
a
. To use this array as data, as they
attribute of each element, crossed with the enclosing parent's data as thex
attribute:Another possibility might be to pull the parent data out of the current group in the property function (
group.parentData
). But, we don't currently expose the group index (j
) or the group itself in the property function. We could pass these as two additional arguments to the property function, similar to Protovis but limited to the immediate enclosing parent, but I like the current simplicity. The extra arguments were a frequent source of confusion in Protovis.Yet another possibility is for a
parentData()
method (or similarly agroup()
method that returns the current group, changing the node returned bynode()
, etc.), but that requires keeping state within the selection, which I don't like because of reentrancy issues.So, I like the idea of the cross operator making the access of the parent data more explicit. But I'm not sure about the efficiency or the semantics.
The text was updated successfully, but these errors were encountered: