GetObjectText
Returns the text content of a chart object.
Syntax
GetObjectText(name: string, isStatic: boolean = false): string
Parameters
Parameter
Type
Description
name
string
The name of the object
isStatic
boolean
Optional. Whether to look in static objects (default: false)
Return Value
Returns a string
containing the object's text content.
Description
The GetObjectText
method retrieves the text content of a specified chart object. This is primarily used with text-based objects like labels, but can also be used with other objects that have text properties.
Example
// Get text from a text label
const labelText = this.api.GetObjectText('MyLabel')
console.log(`Label text: ${labelText}`)
// Get text from a static label
const staticText = this.api.GetObjectText('MyStaticLabel', true)
console.log(`Static label text: ${staticText}`)
// List all text objects with their content
const count = this.api.GetObjectCount()
for (let i = 0; i < count; i++) {
const name = this.api.GetObjectName(i)
if (this.api.GetObjectType(name) === TObjectType.TEXT) {
const text = this.api.GetObjectText(name)
console.log(`Text object ${name}: "${text}"`)
}
}
// Error handling example
try {
const text = this.api.GetObjectText('NonExistentObject')
} catch (error) {
console.log('Error getting object text:', error.message)
}
Last updated