SetObjectText
Sets the text content and formatting for a chart object.
Syntax
SetObjectText(
name: string,
text: string,
fontSize: number = 14,
fontName: string = Roboto Flex,
fontColor: string = '#000000',
isStatic: boolean = false
): boolean
Parameters
Parameter
Type
Description
name
string
The name of the object
text
string
The text content to set
fontSize
number
Optional. The font size (default: 14)
fontName
string
Optional. The font name (default: Roboto Flex)
fontColor
string
Optional. The font color in hex value (default: '#000000')
isStatic
boolean
Optional. Whether the object is static (default: false)
Return Value
Returns boolean
- true
if the text was set successfully, false
otherwise.
Description
The SetObjectText
method sets the text content and formatting properties for a specified chart object. This method is primarily used with text-based objects like labels, but can also be used with other objects that support text properties.
Example
// Set basic text
const success1 = this.api.SetObjectText("MyLabel", "Hello World");
console.log(`Text set: ${success1}`);
// Set text with custom formatting
const success2 = this.api.SetObjectText(
"MyLabel",
"Custom Text",
14, // font size
"Arial",
0xff0000 // red color
);
console.log(`Formatted text set: ${success2}`);
Last updated