8000 vis-1/slides/callbacks.md at master · blehman/vis-1 · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
14 lines (8 loc) · 326 Bytes

callbacks.md

File metadata and controls

14 lines (8 loc) · 326 Bytes

Callbacks


When setting attributes or styles on bound elements, you can supply a callback.

myData = [{ size: 10}, {size: 2}];
...
mySelection.attr("r", function(d,i) { return d.size; });

The bound data and its index in the data array get passed in.

The return value is gets set as the attribute value.

0