다음을 통해 공유


Chart.ApplyDataLabels Method

Definition

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

public void ApplyDataLabels (Microsoft.Office.Interop.Excel.XlDataLabelsType Type = Microsoft.Office.Interop.Excel.XlDataLabelsType.xlDataLabelsShowValue, object LegendKey, object AutoText, object HasLeaderLines, object ShowSeriesName, object ShowCategoryName, object ShowValue, object ShowPercentage, object ShowBubbleSize, object Separator);
abstract member ApplyDataLabels : Microsoft.Office.Interop.Excel.XlDataLabelsType * obj * obj * obj * obj * obj * obj * obj * obj * obj -> unit
Public Sub ApplyDataLabels (Optional Type As XlDataLabelsType = Microsoft.Office.Interop.Excel.XlDataLabelsType.xlDataLabelsShowValue, Optional LegendKey As Object, Optional AutoText As Object, Optional HasLeaderLines As Object, Optional ShowSeriesName As Object, Optional ShowCategoryName As Object, Optional ShowValue As Object, Optional ShowPercentage As Object, Optional ShowBubbleSize As Object, Optional Separator As Object)

Parameters

Type
XlDataLabelsType

XlDataLabelsType. The type of data label to apply.

LegendKey
Object

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

AutoText
Object

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

HasLeaderLines
Object

For the Chart and Series objects, true if the series has leader lines.

ShowSeriesName
Object

The series name for the data label.

ShowCategoryName
Object

The category name for the data label.

ShowValue
Object

The value for the data label.

ShowPercentage
Object

The percentage for the data label.

ShowBubbleSize
Object

The bubble size for the data label.

Separator
Object

The separator for the data label.

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 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);
}
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

Remarks

Optional Parameters

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

Applies to