Retrieves the name of a category from its index.

object.GetCategory index 

Arguments

object
Required. A Chart object.
index
Required. An integer value that specifies the zero-based index of the category in the chart object.

Return Value

The GetCategory method returns a string value that contains the name of the category specified by index.

Remarks

If the index argument refers to a category that does not exist in the chart object, the GetCategory method raises an out of bounds error.

Call the GetValuesCount to retrieve the number of categories in the chart object.

The GetCategory method can return an empty string. This happens when the chart object contains series that have a greater number of values than the number of specified categories.

VBScript Sample Code

The following VBScript code enumerates the categories stored in a chart object and displays them in an ASP page.

'Fill the chart object with data and categories stored in the query string 
chart.SetDataFromQuery

'Retrieve the number of categories stored in the chart object 
n_categories= chart.GetValuesCount

If n_categories = 0 Then
  Response.Write "No category available"
Else
  'Enumerate the categories stored in the chart object 
  For i = 0 to (n_categories-1)
    Response.Write "Category[" & i & "]=" & chart.GetCategory(i) 
  Next
End If

See Also

GetValuesCount Method | SetCategoriesFromArray Method | SetCategoriesFromString Method

Applies To: Chart Object