DataLabel 對(duì)象

此頁沒有內(nèi)容條目
內(nèi)容

Chart

parchildSeriesCollection (Series)

spaceparmultDataLabels (DataLabel)

spaceparmultPoints (Point)

spaceparlowerparchildDataLabel

spaceparchildTrendlines (Trendline)

spacespaceparchildDataLabel

代表圖表中指定數(shù)據(jù)點(diǎn)或趨勢(shì)線的數(shù)據(jù)標(biāo)簽。對(duì)于數(shù)據(jù)系列,DataLabel 對(duì)象是 DataLabels 集合的成員,該集合包含每個(gè)數(shù)據(jù)點(diǎn)的 DataLabel 對(duì)象。對(duì)于沒有可定義數(shù)據(jù)點(diǎn)的數(shù)據(jù)系列(如面積圖數(shù)據(jù)系列),DataLabels 集合包含單個(gè) DataLabel 對(duì)象。

DataLabel 對(duì)象的用法

使用 DataLabels(index)(其中 index 為數(shù)據(jù)標(biāo)簽的索引號(hào))可返回單個(gè) DataLabel 對(duì)象。下例設(shè)置圖表上第一個(gè)數(shù)據(jù)系列中的第五個(gè)數(shù)據(jù)標(biāo)簽的數(shù)字格式。

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

使用 DataLabel 屬性可返回單個(gè)數(shù)據(jù)點(diǎn)的 DataLabel 對(duì)象。下例打開圖表上第一個(gè)數(shù)據(jù)系列中第二個(gè)數(shù)據(jù)點(diǎn)的數(shù)據(jù)標(biāo)簽,并將該數(shù)據(jù)標(biāo)簽的文字設(shè)置為“Saturday”。

With myChart

    With .SeriesCollection(1).Points(2)

        .HasDataLabel = True

        .DataLabel.Text = "Saturday"

    End With

End With

對(duì)于趨勢(shì)線,DataLabel 屬性返回與趨勢(shì)線一起顯示的文本。這些文本可能是公式、R 平方值或兩者均有(如果兩者都出現(xiàn))。下例使趨勢(shì)線的文本中僅出現(xiàn)公式,并將數(shù)據(jù)標(biāo)簽文本置于數(shù)據(jù)表上的單元格 A1 中。

With myChart.SeriesCollection(1).Trendlines(1)

    .DisplayRSquared = False

    .DisplayEquation = True

    x = .DataLabel.Text

End With

With myChart.Application.DataSheet

    .Range("A1").Value = x

End With