ChDataLabels Object

Microsoft Office Web Components Object Model

ChDataLabels Object

         
ChDataLabelsCollection ChDataLabels
Multiple objects

Contains a collection of ChDataLabel objects that represent all the data labels in the specified set of data labels for a series. Note that a series can contain more than one set of data labels.

Using the ChDataLabels object

The following methods and properties can be used to return a ChDataLabels object:

The  ChDataLabelsCollection collection object's Add method.

The  ChDataLabelsCollection collection object's Item property.

The following example adds data labels to the first series in the first chart in Chartspace1 and then formats the data labels.

Sub AddDataLabels()

    Dim serSeries1
    Dim dlSeries1Labels

    ' Set a variable to the first series of the first chart
    ' in Chartspace1.
    Set serSeries1 = ChartSpace1.Charts(0).SeriesCollection(0)

    ' Add a set of data labels to the first series and return
    ' a DataLabels object.
    Set dlSeries1Labels = serSeries1.DataLabelsCollection.Add

    ' Set the number format of the data labels.
    dlSeries1Labels.NumberFormat = "0.00"

    ' Set the data labels to display the category
    ' name for the data point.
    dlSeries1Labels.HasCategoryName = True

    ' Set the data labels to display the value
    ' for the data point.
    dlSeries1Labels.HasValue = True

End Sub