Share via


Chart.ApplyDataLabels Method

Applies data labels to a point, a series, or all the series in a Chart control.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)

Syntax

'Declaration
Sub ApplyDataLabels ( _
    Type As XlDataLabelsType, _
    LegendKey As Object, _
    AutoText As Object, _
    HasLeaderLines As Object, _
    ShowSeriesName As Object, _
    ShowCategoryName As Object, _
    ShowValue As Object, _
    ShowPercentage As Object, _
    ShowBubbleSize As Object, _
    Separator As Object _
)
void ApplyDataLabels(
    XlDataLabelsType Type,
    Object LegendKey,
    Object AutoText,
    Object HasLeaderLines,
    Object ShowSeriesName,
    Object ShowCategoryName,
    Object ShowValue,
    Object ShowPercentage,
    Object ShowBubbleSize,
    Object Separator
)

Parameters

  • LegendKey
    Type: System.Object

    true to show the legend key next to the point. The default value is false.

  • AutoText
    Type: System.Object

    true if the object automatically generates appropriate text based on content.

  • ShowSeriesName
    Type: System.Object

    The series name for the data label.

  • ShowCategoryName
    Type: System.Object

    The category name for the data label.

  • ShowPercentage
    Type: System.Object

    The percentage for the data label.

  • ShowBubbleSize
    Type: System.Object

    The bubble size for the data label.

  • Separator
    Type: System.Object

    The separator for the data label.

Remarks

Optional Parameters

For information on optional parameters, see Optional Parameters in Office Solutions.

Examples

The following code example creates a Chart and then uses the ApplyDataLabels method to display data labels with the series names on the chart.

Private Sub DisplayLabels()
    Me.Range("A1", "A5").Value2 = 22
    Me.Range("B1", "B5").Value2 = 55

    Dim Chart1 As Microsoft.Office.Tools.Excel.Chart = _
        Me.Controls.AddChart(Me.Range("D2", "H20"), "Chart1")

    Chart1.SetSourceData(Me.Range("A1", "B5"), Excel.XlRowCol.xlColumns)
    Chart1.ChartType = Excel.XlChartType.xlBarClustered

    Chart1.ApplyDataLabels(Excel.XlDataLabelsType.xlDataLabelsShowLabel, _
        False, False, False, True, False, False, False, False, False)
End Sub
private void DisplayLabels()
{
    this.Range["A1", "A5"].Value2 = 22;
    this.Range["B1", "B5"].Value2 = 55;

    Microsoft.Office.Tools.Excel.Chart chart1 =
        this.Controls.AddChart(this.Range["D2", "H20"], 
        "chart1");

    chart1.SetSourceData(this.Range["A1", "B5"], 
        Excel.XlRowCol.xlColumns);
    chart1.ChartType = Excel.XlChartType.xlBarClustered;

    chart1.ApplyDataLabels(
        Excel.XlDataLabelsType.xlDataLabelsShowLabel,
        false, false, false, true, false, false, false, 
        false, false);
}

.NET Framework Security

See Also

Reference

Chart Interface

Microsoft.Office.Tools.Excel Namespace