Text
extends Mark
The Text class represents a text element. To create a Text object, use the mark method in the Scene class, for example:
let txt = scene.mark("text", {x: 50, y: 100, text: "hello"});
Properties
property | explanation | type | default value |
---|---|---|---|
anchor | the anchor of this text (Figure 1) | Array | [“center”, “middle”] |
x | the x coordinate of the anchor | Number | 0 |
y | the y coordinate of the anchor | Number | 0 |
text | the text content | String | "" |
fontFamily | the font family of the text | String | “Arial” |
fontSize | the font size of the text | String | “12px” |
fontWeight | the font weight of the text | String | “regular” |
fillColor | the color of the text | Color | “black” |
bounds | the bounding rectangle of the text | Rectangle |
Properties inherited from Mark
property | explanation | type | default value |
---|---|---|---|
id | the unique id of the text | String | |
type | the type of the text | String | “pointText” |
dataScope | the data scope of the text | DataScope | undefined |
opacity | the opacity value of the text (between 0 and 1) | Number | 1 |
visibility | whether the text is visible (“visible” or “hidden”) | String | “visible” |
Methods inherited from Mark
method | explanation | return type |
---|---|---|
contains(x, y) | whether this text contains a point x (Number): x coordinate of the point y (Number): y coordinate of the point | Boolean |
getScene() | returns the scene in which this mark resides | Scene |
duplicate() | returns a copy of this mark | Text |