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
property | explanation | type | default value |
---|---|---|---|
id | the unique id of the group | String | |
type | the type of the group | String | “group” |
dataScope | the data scope of the group | DataScope | undefined |
layout | the layout of the group children | Layout | undefined |
children | the graphical objects in the group | Array | [] |
firstChild | the first child in the group | Mark or Group | |
lastChild | the last child in the group | Mark or Group | |
bounds | the bounding rectangle of the group | Rectangle | |
center | the center of the group bounds | Point | |
x | the x coordinate of the center of the group bounds | Number | |
y | the y coordinate of the center of the group bounds | Number | |
visibility | whether the group is visible (“visible” or “hidden”) | String | “visible” |
Methods
method | explanation | return type |
---|---|---|
addChild(c) | adds an object to the group | void |
addChildAt(c, i) | adds an object to the group at the specified index | void |
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 group | void |
removeAll() | removes all the children from the group | void |
getScene() | returns the scene in which this group resides | Scene |
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 |