GetObjectType

Returns the type of a chart object.

Syntax

GetObjectType(name: string, isStatic: boolean = false): TObjectType

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 TObjectType enum value representing the object's type.

Description

The GetObjectType method retrieves the type of a specified chart object. The type is returned as a TObjectType enumeration value.

Example

// Get type of a specific object
const type = this.api.GetObjectType("MyTrendLine");
console.log(`Object type: ${type}`);

// Check object type
if (this.api.GetObjectType("MyLine") === TObjectType.TREND_LINE) {
  console.log("Object is a trend line");
}

// List all objects with their types
const count = this.api.GetObjectCount();
for (let i = 0; i < count; i++) {
  const name = this.api.GetObjectName(i);
  const type = this.api.GetObjectType(name);
  console.log(`Object ${name} is of type ${type}`);
}

// Check static object type
const staticType = this.api.GetObjectType("MyStaticLine", true);
if (staticType === TObjectType.V_LINE) {
  console.log("Static object is a vertical line");
}

Last updated