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

Chart.GetChartElement 方法 (项目)Chart.GetChartElement Method (Project)

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

返回信息处的图表元素指定 X 和 Y 坐标。此方法将项目 2013年的发行版中移除。Returns information about the chart element at specified X and Y coordinates. This method will be removed in the released version of Project 2013.

语法Syntax

表达式GetChartElement(xy返回Arg1Arg2)expression. GetChartElement(x,? y,? ElementID,? Arg1,? Arg2)

表达式_一个表示图表对象的变量。_expression A variable that represents a Chart object.

参数Parameters

名称Name必需/可选Required/Optional数据类型Data type说明Description
xx必需RequiredLongLong图表元素的 X 坐标。The X coordinate of the chart element.
yy必需RequiredLongLong图表元素的 Y 坐标。The Y coordinate of the chart element.
返回ElementID必需RequiredLongLongGetChartElement方法返回时,返回_包含指定坐标处的图表元素的Office.XLChartItem值。有关详细信息,请参见备注When the GetChartElement method returns, _ElementID contains the Office.XLChartItem value of the chart element at the specified coordinates. For more information, seeRemarks.
Arg1Arg1必需RequiredLongLong当此方法返回时, Arg1_包含与图表元素相关的信息。有关详细信息,请参见备注When the method returns, _Arg1 contains information related to the chart element. For more information, seeRemarks.
Arg2Arg2必需RequiredLongLong当此方法返回时, Arg2_包含与图表元素相关的信息。有关详细信息,请参见备注When the method returns, _Arg2 contains information related to the chart element. For more information, seeRemarks.
xx必需RequiredINT32INT32
yy必需RequiredINT32INT32
返回ElementID必需RequiredINT32INT32
Arg1Arg1必需RequiredINT32INT32
Arg2Arg2必需RequiredINT32INT32

返回值Return value

GetChartElement方法返回Nothing。返回的值是中的_返回_、 Arg1_和_Arg2_参数。The GetChartElement method returns Nothing. Returned values are in the _ElementID, Arg1, and Arg2 parameters.

注解Remarks

请注意GetChartElement方法将项目 2013年的发行版中被删除。图表对象在项目中的未实现的事件;因此,还不能与鼠标事件交互使用GetChartElement方法动画项目中的图表。Note The GetChartElement method will be removed in the released version of Project 2013. The Chart object in Project does not implement events; so, a chart in Project cannot be animated with the GetChartElement method by interacting with mouse events.

GetChartElement方法是不寻常,因为,仅前两个参数为指定值。项目参数中返回数据,并在方法返回时,您的代码应检查这些值。The GetChartElement method is unusual because you specify values for only the first two arguments. Project returns data in the other arguments, and your code should examine those values when the method returns.

返回_后该方法返回的值确定参数_Arg1_和_Arg2_包含的任何信息 (请参见表 1)。The value of _ElementID after the method returns determines whether Arg1 and Arg2 contain any information (see Table 1).

表 1。在参数 Arg1 和 Arg2,基于元素 ID 信息Table 1. Information in Arg1 and Arg2, based on the element ID

返回常量ElementID Constant* * 常量值 * *Constant Value **Arg1Arg1Arg2Arg2
xlAxisxlAxis2121AxisIndexAxisIndexAxisTypeAxisType
xlAxisTitlexlAxisTitle1717AxisIndexAxisIndexAxisTypeAxisType
xlDisplayUnitLabelxlDisplayUnitLabel3030AxisIndexAxisIndexAxisTypeAxisType
xlMajorGridlinesxlMajorGridlines1515AxisIndexAxisIndexAxisTypeAxisType
xlMinorGridlinesxlMinorGridlines1616AxisIndexAxisIndexAxisTypeAxisType
xlPivotChartDropZonexlPivotChartDropZone3232DropZoneTypeDropZoneTypeNone
xlPivotChartFieldButtonxlPivotChartFieldButton3131DropZoneTypeDropZoneTypePivotFieldIndexPivotFieldIndex
xlDownBarsxlDownBars2020GroupIndexGroupIndexNone
xlDropLinesxlDropLines2626GroupIndexGroupIndexNone
xlHiLoLinesxlHiLoLines2525GroupIndexGroupIndexNone
xlRadarAxisLabelsxlRadarAxisLabels2727GroupIndexGroupIndexNone
xlSeriesLinesxlSeriesLines2222GroupIndexGroupIndexNone
xlUpBarsxlUpBars1818GroupIndexGroupIndexNone
xlChartAreaxlChartArea22NoneNone
xlChartTitlexlChartTitle44NoneNone
xlCornersxlCorners66NoneNone
xlDataTablexlDataTable77NoneNone
xlFloorxlFloor2323NoneNone
xlLeaderLinesxlLeaderLines2929NoneNone
xlLegendxlLegend2424NoneNone
xlNothingxlNothing2828NoneNone
xlPlotAreaxlPlotArea1919NoneNone
xlWallsxlWalls55NoneNone
xlDataLabelxlDataLabel77SeriesIndexSeriesIndexPointIndexPointIndex
xlErrorBarsxlErrorBars99SeriesIndexSeriesIndexNone
xlLegendEntryxlLegendEntry1212SeriesIndexSeriesIndexNone
xlLegendKeyxlLegendKey1313SeriesIndexSeriesIndexNone
xlSeriesxlSeries33SeriesIndexSeriesIndexPointIndexPointIndex
xlShapexlShape1414ShapeIndexShapeIndexNone
xlTrendlinexlTrendline88SeriesIndexSeriesIndexTrendLineIndexTrendLineIndex
xlXErrorBarsxlXErrorBars1010SeriesIndexSeriesIndexNone
xlYErrorBarsxlYErrorBars1111SeriesIndexSeriesIndexNone

?

表 2 描述了参数_Arg1_和_Arg2_的含义,在方法返回后。在参数列中的值是从表 1。Table 2 describes the meaning of Arg1 and Arg2 after the method returns. Values in the Argument column are from Table 1.

表 2。数据参数 Arg1 和 Arg2 的含义Table 2. Meaning of data in Arg1 and Arg2

参数Argument说明Description
AxisIndexAxisIndex指定轴主要或辅助。可以是下列的Office.XlAxisGroup常量之一: xlPrimaryxlSecondarySpecifies whether the axis is primary or secondary. Can be one of the following Office.XlAxisGroup constants: xlPrimary or xlSecondary.
AxisTypeAxisType指定坐标轴类型。可以是下列的Office.XlAxisType常量之一: xlCategoryxlSeriesAxisxlValueSpecifies the axis type. Can be one of the following Office.XlAxisType constants: xlCategory, xlSeriesAxis, or xlValue.
DropZoneTypeDropZoneType指定拖放区域类型: 列、 数据、 页或行字段。可以是下列的Office.XlPivotFieldOrientation常量之一: xlColumnFieldxlDataFieldxlPageFieldxlRowField。列和行字段常量分别指定系列和分类字段。Specifies the drop zone type: column, data, page, or row field. Can be one of the following Office.XlPivotFieldOrientation constants: xlColumnField, xlDataField, xlPageField, or xlRowField. The column and row field constants specify the series and category fields, respectively.
GroupIndexGroupIndex指定特定图表组的Office.IMsoChart.ChartGroups集合中的偏移量。Specifies the offset within the Office.IMsoChart.ChartGroups collection for a specific chart group.
PivotFieldIndexPivotFieldIndex指定特定列 (系列)、 数据、 页或行 (类别) 字段的Excel.PivotFields集合中的偏移量。如果拖放区域类型是xlDataField,则值为-1Specifies the offset within the Excel.PivotFields collection for a specific column (series), data, page, or row (category) field. The value is -1 if the drop zone type is xlDataField.
PointIndexPointIndex指定系列中的特定点的Office.IMsoSeries.Points集合中的偏移量。_QM_1一个值指示选中了所有数据点。Specifies the offset within the Office.IMsoSeries.Points collection for a specific point within a series. A value of ?1 indicates that all data points are selected.
SeriesIndexSeriesIndex指定特定系列的Office.IMsoChart.SeriesCollection中的偏移量。Specifies the offset within the Office.IMsoChart.SeriesCollection for a specific series.
ShapeIndexShapeIndex指定某一特定形状的Shapes集合中的偏移量。Specifies the offset within the Shapes collection for a specific shape.
TrendlineIndexTrendlineIndex指定一系列内的特定趋势线的Office.IMsoSeries.Trendlines集合中的偏移量。Specifies the offset within the Office.IMsoSeries.Trendlines collection for a specific trendline within a series.

示例Example

下面的示例获取点 (100,100) 图表中的图表元素信息。例如,如果数据点位于绘图区中,在立即窗格中的输出是idNum: 19, a: 0, b: 0。在表 1 中, xlPlotArea的信息 = 19。The following example gets the chart element information for point (100, 100) in the chart. For example, if the point is within the plot area, output in the Immediate pane is idNum: 19, a: 0, b: 0. From the information in Table 1, xlPlotArea = 19.

Sub TestGetChartElements()
    Dim chartShape As Shape
    Dim reportName As String
    Dim x As Long
    Dim y As Long
    Dim idNum As Long
    Dim a As Long
    Dim b As Long

    reportName = "Simple scalar chart"
    Set chartShape = ActiveProject.Reports(reportName).Shapes(1)

    ' Specify a point in the chart.
    x = 100
    y = 100

    chartShape.Chart.GetChartElement x, y, idNum, a, b

    Debug.Print "idNum: " &; idNum &; ", a: " &; a &; ", b: " &; b
End Sub

另请参阅See also

其他资源Other resources

Chart 对象Chart Object

© 2018 Microsoft