I am pretty new to protovis. I was trying to understand the example in http://mbostock.github.com/protovis/docs/panel.html I can understand left(function() this.index * 10)
is actually left(function(){return this.index * 10;})
and when the function is called a scope is passed to it thats this
well and fine till now. BUt data(function(array) array)
doesn't takes the array from this
. rather its passed to it. from where this array
is passed ? I cannot understand the flow of the chain.
protovis magical properties
74 views Asked by Neel Basu At
1
This is one of the many parts of Protovis that's a bit confusing at first. When you add data to a mark, e.g.:
the mark will be duplicated once for each item in the
data
array, and passed the corresponding item as the first argument to its functions, e.g.:Any child mark you attach to
mark
will also receive this data point, which can then be used by the child mark as the input argument for its functions, e.g.:But child marks can also define their own
data()
, which will duplicate that mark accordingly. A child mark's data can be totally independent, e.g.:But often, as in the example you link to, the parent will have a 2- or 3-d array as its data, and the child will base its
data()
on the sub-array it's passed: