WPS 加载项开发 > 表格 API 参考 > Chart > 方法 > Chart.GetChartElement 方法
返回指定的 X 坐标和 Y 坐标上图表元素的信息。本方法稍有与众不同之处:调用时只须指定前两个参数,在本方法执行期间,ET 为其余参数赋值,本方法返回后应检验这些参数的值。

语法

表达式.GetChartElement(x, y, ElementID, Arg1, Arg2)

表达式   一个代表 Chart 对象的变量。

参数

名称 必选/可选 数据类型 说明
x 必选 Long 图表元素的 X 坐标。
y 必选 Long 图表元素的 Y 坐标。
ElementID 必选 Long 该方法返回时,此参数包含指定坐标的图表元素的 XLChartItem 值。有关详细信息,请参阅“备注”部分。
Arg1 必选 Long 该方法返回时,该参数包含与图表元素相关的信息。有关详细信息,请参阅“备注”部分。
Arg2 必选 Long 该方法返回时,该参数包含与图表元素相关的信息。有关详细信息,请参阅“备注”部分。

说明

本方法返回的 ElementID 值决定了 Arg1 和 Arg2 所包含的信息,如下表所示。

ElementID 常量 常量值 Arg1 Arg2
xlAxis 21 AxisIndex AxisType
xlAxisTitle 17 AxisIndex AxisType
xlDisplayUnitLabel 30 AxisIndex AxisType
xlMajorGridlines 15 AxisIndex AxisType
xlMinorGridlines 16 AxisIndex AxisType
xlPivotChartDropZone 32 DropZoneType 无
xlPivotChartFieldButton 31 DropZoneType PivotFieldIndex
xlDownBars 20 GroupIndex 无
xlDropLines 26 GroupIndex 无
xlHiLoLines 25 GroupIndex 无
xlRadarAxisLabels 27 GroupIndex 无
xlSeriesLines 22 GroupIndex 无
xlUpBars 18 GroupIndex 无
xlChartArea 2 无 无
xlChartTitle 4 无 无
xlCorners 6 无 无
xlDataTable 7 无 无
xlFloor 23 无 无
xlLeaderLines 29 无 无
xlLegend 24 无 无
xlNothing 28 无 无
xlPlotArea 19 无 无
xlWalls 5 无 无
xlDataLabel 7 SeriesIndex PointIndex
xlErrorBars 9 SeriesIndex 无
xlLegendEntry 12 SeriesIndex 无
xlLegendKey 13 SeriesIndex 无
xlSeries 3 SeriesIndex PointIndex
xlShape 14 ShapeIndex 无
xlTrendline 8 SeriesIndex TrendLineIndex
xlXErrorBars 10 SeriesIndex 无
xlYErrorBars 11 SeriesIndex 无

下表说明了本方法返回后,参数 Arg1 和 Arg2 的含义。

参数 说明
AxisIndex 指定坐标轴是主坐标轴还是次坐标轴。可为以下 XlAxisGroup 常量之一:xlPrimary 或 xlSecondary。
AxisType 指定坐标轴类型。可为以下 XlAxisType 常量之一:xlCategory、xlSeriesAxis 或 xlValue。
DropZoneType 指定拖放区的类型:列、数据、页或行字段。可为以下 XlPivotFieldOrientation 常量之一:xlColumnField、xlDataField、xlPageField 或 xlRowField。列和行字段常量分别指定了系列和分类字段。
GroupIndex 指定特定图表组在 ChartGroups 集合内的偏移量。
PivotFieldIndex 指定特定列(数据系列)、数据、页或行(类别)字段在 PivotFields 集合中的偏移量。如果拖放区域类型为 xlDataField,则返回 -1。
PointIndex 指定系列中的特定点在 Points 集合中的偏移量。-1 表示选定了所有数据点。
SeriesIndex 指定特定系列在 Series 集合中的偏移量。
ShapeIndex 指定特定形状在 Shapes 集合中的偏移量。
TrendlineIndex 指定某个系列中特定趋势线在 Trendlines 集合中的偏移量。

示例

当鼠标移动到图表图例上时,本示例发出警告。

示例代码
function Chart_MouseMove(Button, Shift, X, Y) {
    let IDNum 
    let a
    let b
    ActiveChart.GetChartElement(X, Y, IDNum, a, b)
    if(IDNum == xlLegendEntry) {
        MsgBox("WARNING: Move away from the legend")
    }
}


请参阅