GetObjectCount

Returns the total number of chart objects.

Syntax

GetObjectCount(isStatic?: boolean, window?: number): number

Parameters

  • isStatic: boolean - Optional. Whether to count static objects (default: false)

  • window: number - Optional. Target window: 0 = MainChart, 1+ = OscWin, -1 = count across all windows. Default: current chart

Return Value

Returns a number representing the total count of chart objects.

Description

The GetObjectCount method returns the total number of objects in the chart. It can count either regular objects or static objects, depending on the isStatic parameter. Use the optional window parameter to scope the count to a specific chart window (MainChart or OscWin) or to count across all windows.

Example

// Get count of regular objects
const regularCount = this.api.GetObjectCount();
console.log(`Regular objects: ${regularCount}`);

// Get count of static objects
const staticCount = this.api.GetObjectCount(true);
console.log(`Static objects: ${staticCount}`);

// Use counts in a loop
for (let i = 0; i < this.api.GetObjectCount(); i++) {
  const objectName = this.api.GetObjectName(i);
  console.log(`Object ${i}: ${objectName}`);
}

// Count objects in MainChart (window = 0)
const mainChartCount = this.api.GetObjectCount(false, 0);

// Count objects across all windows
const totalCount = this.api.GetObjectCount(false, -1);

Last updated