Collection

extends Group

The Collection class represents a group of marks, glyphs, or collections (i.e., nested collection). Children inside a collection have the same “type” property. Collections are created through the repeat, divide, and densify methods in the Scene class.

Properties inherited from Group

propertyexplanationtypedefault value
id the unique id of the groupString
type the type of the groupString“collection”
dataScopethe data scope of the groupDataScopeundefined
layoutthe layout of the group childrenLayoutundefined
children the graphical objects in the groupArray[]
firstChild the first child in the groupMark or Group
lastChild the last child in the groupMark or Group
bounds the bounding rectangle of the groupRectangle
center the center of the group boundsPoint
x the x coordinate of the center of the group boundsNumber
y the y coordinate of the center of the group boundsNumber
visibilitywhether the group is visible (“visible” or “hidden”)String“visible”

Methods inherited from Group

methodexplanationreturn type
addChild(c)adds an object to the groupvoid
addChildAt(c, i)adds an object to the group at the specified indexvoid
contains(x, y)whether this group contains a point
x (Number): x coordinate of the point
y (Number): y coordinate of the point
Boolean
removeChild(c)removes the specified object from the groupvoid
removeAll()removes all the children from the groupvoid
getScene()returns the scene in which this group residesScene
sortChildren
(channel, reverse)
sort the children by a visual channel
channel (String): the channel to sort the children by
reverse: (Boolean, optional) setting to true will sort in descending order;
default is false.
void
sortChildrenByData
(field, reverse, order)
sort the children by a data field
field (String): the data field to sort the children by
reverse (Boolean, optional): setting to true will sort in descending order;
default is false.
order (Array, optional): an array of field values in ascending order
void