Overview
TheLabel class creates a text label with advanced features including inline formatting, data placeholders, text wrapping, truncation, and more. It extends the Container class.
Constructor
The root element of the chart
Configuration settings for the label
Settings
text
The label’s text content. Supports inline styling and data placeholders.
Text Styling
Text color.
Text opacity (0-1).
Fill gradient for the text.
Font family. Multiple fonts can be separated by commas.
Font size in any supported CSS format (pixel, point, em, etc.).
fontWeight
'normal' | 'bold' | 'bolder' | 'lighter' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900'
Font weight.
Font style.
Font variant.
Text decoration.
Text Alignment
Text alignment.
Baseline to use when aligning text chunks vertically.
Text direction.
Line Height and Spacing
Line height in percent or absolute pixels.
How much of the height should be considered to go below baseline.
Oversized Text Handling
How to handle labels that do not fit into designated space.
none- Do nothinghide- Hide the labelfit- Scale down the label to fitwrap- Wrap text to multiple lineswrap-no-break- Wrap text without breaking wordstruncate- Truncate text with ellipsis
Whether words can be broken when truncating or wrapping text.
Ellipsis characters to use when truncating text.
Minimum relative scale allowed for label when scaling down with
oversizedBehavior="fit". If fitting would require scaling beyond this value, the label will be hidden instead.Maximum number of characters to allow in label. Text will be truncated using
breakWords and ellipsis settings.Data and Formatting
If set to
true, the label will parse text for data placeholders and populate them with actual data.If set to
true, will ignore inline formatting blocks and display text exactly as is.Shadow Effects
Color of the element’s shadow. Requires at least one of
shadowBlur, shadowOffsetX, or shadowOffsetY to be set.Blurriness of the shadow. The bigger the number, the more blurry.
Horizontal shadow offset in pixels.
Vertical shadow offset in pixels.
Opacity of the shadow (0-1). If not set, will use the same as
fillOpacity.Properties
text
Access to the underlying
Text rendering element (read-only).Methods
getText()
Returns text with populated placeholders and formatting ifpopulateText is set to true.
The populated text string
getAccessibleText()
Returns “aria-label” text with populated placeholders and formatting ifpopulateText is set to true.
The populated accessible text string
Examples
Basic Label
Label with Inline Formatting
Label with Data Binding
Truncated Label
Wrapped Label
Label with Shadow
Text Styling
Labels support inline text styling using square bracket notation:[bold]...[/]- Bold text[italic]...[/]- Italic text[#RRGGBB]...[/]- Colored text[fontSize: XXpx]...[/]- Custom font size- And more…