Retrieves the name of a category from its index.

    string object->GetCategory( int 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.

#### PHP Sample Code

The following PHP code enumerates the categories stored in a chart object and displays them.

    // 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 )
      {
      print( "No category available<br>" );
      }
    else
      {
      // Enumerate the categories stored in the chart object
      for( $i= 0; $i < $n_categories; ++$i )
        print( "Category[" . $i . "]=" . $chart->GetCategory($i) . "<br>" );
      }

#### See Also

GetValuesCount Method | SetCategoriesFromArray Method | SetCategoriesFromString Method

Applies To: Chart Object