Table of contents
TOC
折叠目录
展开目录

数据标签对象 (PowerPoint)DataLabel Object (PowerPoint)

office 365 dev account|上次更新日期: 2018/3/13
|
2 参与人员

代表图表数据点或趋势线上的数据标签。Represents the data label on a chart point or trendline.

注解Remarks

系列的数据标签对象是数据标签集合的一个成员。数据标签集合中包含的每个点的数据标签对象。对于没有可定义点 (如区域系列),数据标签集合包含单个数据标签对象。On a series, the DataLabel object is a member of the DataLabels collection. The DataLabels collection contains a DataLabel object for each point. For a series without definable points (such as an area series), the DataLabels collection contains a single DataLabel object.

示例Example

请注意 尽管下面的代码适用于 Microsoft Word 中,您可以随时修改将其应用到 PowerPoint。Note Although the following code applies to Microsoft Word, you can readily modify it to apply to PowerPoint.

使用数据标签索引),其中_索引_是数据标签的索引号,返回单个数据标签对象。下面的示例设置活动文档中第一个图表的第一个系列中的第五个数据标签的数字格式。Use DataLabels ( Index ), where Index is the data label index number, to return a single DataLabel object. The following example sets the number format for the fifth data label in the first series of the first chart in the active document.

With ActiveDocument.InlineShapes(1)

    If .HasChart Then

        .Chart.SeriesCollection(1).DataLabels(5).NumberFormat = "0.000"

    End If

End With

请注意 尽管下面的代码适用于 Microsoft Word 中,您可以随时修改将其应用到 PowerPoint。Note Although the following code applies to Microsoft Word, you can readily modify it to apply to PowerPoint.

使用Point.DataLabel属性返回单个点的数据标签对象。下面的示例打开活动文档中第一个图表中第一个数据系列的第二个点的数据标签,并设置数据标签文本为"Saturday。Use the Point.DataLabel property to return the DataLabel object for a single point. The following example turns on the data label for the second point in the first series of the first chart in the active document and sets the data label text to "Saturday."

With ActiveDocument.InlineShapes(1)

    If .HasChart Then

        With .Chart.SeriesCollection(1).Points(2)

            .HasDataLabel = True

            .DataLabel.Text = "Saturday"

        End With

    End If

End With

请注意 尽管下面的代码适用于 Microsoft Word 中,您可以随时修改将其应用到 PowerPoint。Note Although the following code applies to Microsoft Word, you can readily modify it to apply to PowerPoint.

在趋势线,则Trendline.DataLabel属性返回与趋势线所显示的文本。这可以是计算公式、 R 平方值,或两者 (如果两者都出现)。下面的示例设置活动文档仅显示公式中的第一个图表的第一个系列中第一个趋势线趋势线文本。On a trendline, the Trendline.DataLabel property returns the text shown with the trendline. This can be the equation, the R-squared value, or both (if both are showing). The following example sets the trendline text for the first trendline in the first series of the first chart in the active document to show only the equation.

With ActiveDocument.InlineShapes(1)

    If .HasChart Then

        With .Chart.SeriesCollection(1).Trendlines(1)

            .DisplayRSquared = False

            .DisplayEquation = True

        End With

    End If

End With

另请参阅See also

概念Concepts

PowerPoint 对象模型引用PowerPoint Object Model Reference

© 2018 Microsoft