(Project) 的 Series 物件
表示在圖表中建立資料列或資料行的相關資料集合。
Series物件是SeriesCollection集合的成員,其中包含圖表中的所有資料數列。 數列的名稱通常會顯示在圖表圖例中。
下列範例會列印圖表上資料數列集合的數列名稱、X (水準) 值,以及 Y (垂直) 值。
Sub TestChartSeries()
Dim reportName As String
Dim theReportIndex As Integer
Dim theChart As Chart
Dim seriesCollec As SeriesCollection
Dim chartSeries As Series
Dim i As Integer
Dim j As Integer
reportName = "Simple scalar chart"
theReportIndex = -1
If (ActiveProject.Reports.IsPresent(reportName)) Then
' Make the report active.
theReportIndex = ActiveProject.Reports(reportName).Index
ActiveProject.Reports(theReportIndex).Apply
Set theChart = ActiveProject.Reports(theReportIndex).Shapes(1).Chart
Set seriesCollec = theChart.SeriesCollection()
For i = 1 To seriesCollec.Count
Set chartSeries = seriesCollec(i)
If (IsEmpty(chartSeries.Name)) Then
Debug.Print "Series " & i & " name is an empty string."
Else
Debug.Print "Series " & i & ": " & chartSeries.Name
End If
For j = 1 To seriesCollec.Count
Debug.Print vbTab & "X, Y values(" & j & "): " & chartSeries.XValues(j) _
& ", " & chartSeries.Values(j); ""
Next j
Next i
End If
End Sub
下列範例輸出來自圖表,例如 Chart 目的檔中的範例。
Series 1: Actual Work
X, Y values(1): T1, 16
X, Y values(2): T2 - new, 32
X, Y values(3): T3, 7
Series 2: Remaining Work
X, Y values(1): T1, 0
X, Y values(2): T2 - new, 16
X, Y values(3): T3, 17
Series 3: Work
X, Y values(1): T1, 16
X, Y values(2): T2 - new, 48
X, Y values(3): T3, 24
名稱 |
---|
Application |
名稱 |
Parent |
值 |
XValues |
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。