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.

JSP Sample Code

The following JSP 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.SetDataFromTxtFile("C:\\myData.txt");

// Retrieve the number of categories stored in the chart object 
int n_categories= chart.GetValuesCount();

if( n_categories == 0 )
  {
  out.println( "No category available<br>" );
  }
else
  {
  // Enumerate the categories stored in the chart object 
  for( int i= 0; i < n_categories; ++i )
    out.println( "Category[" + i + "]=" + chart.GetCategory(i) + "<br>" );
  }

See Also

GetValuesCount Method | SetCategoriesFromArray Method | SetCategoriesFromString Method

Applies To: Chart Object