Group

Subclasses: Scene, Collection, Glyph

The Group class represents a group of graphical objects (i.e., marks or groups). To create a group, use the group method in the Scene class, for example:

let g = scene.group();

Properties

propertyexplanationtypedefault value
id the unique id of the groupString
type the type of the groupString“group”
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
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

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