RemoveAllObjects
Removes all chart objects of a specified type.
Syntax
RemoveAllObjects(objType: TObjectType, isStatic: boolean = false): void
Parameters
Parameter
Type
Description
isStatic
boolean
Optional. Whether to remove static objects (default: false)
Description
The RemoveAllObjects
method removes all chart objects of a specified type from the chart. This is useful for cleaning up multiple objects at once. The method can remove either regular objects or static objects, depending on the isStatic
parameter.
Example
// Remove all trend lines
this.api.RemoveAllObjects(TObjectType.TREND_LINE);
// Remove all static text labels
this.api.RemoveAllObjects(TObjectType.TEXT, true);
// Clean up all drawing objects
const objectTypes = [
TObjectType.TREND_LINE,
TObjectType.RECTANGLE,
TObjectType.TRIANGLE,
TObjectType.TEXT,
];
for (const type of objectTypes) {
this.api.RemoveAllObjects(type);
}
// Remove objects and log count
const beforeCount = this.api.GetObjectCount();
this.api.RemoveAllObjects(TObjectType.RECTANGLE);
const afterCount = this.api.GetObjectCount();
console.log(`Removed ${beforeCount - afterCount} rectangle objects`);
Last updated