Chart.XYGroups 方法

在二维图表上返回一个对象,该对象表示单个散点图组(ChartGroup 对象)或散点图组的集合(ChartGroups 集合)。

命名空间:  Microsoft.Office.Tools.Excel
程序集:  Microsoft.Office.Tools.Excel(在 Microsoft.Office.Tools.Excel.dll 中)

语法

声明
Function XYGroups ( _
    Index As Object _
) As Object
Object XYGroups(
    Object Index
)

参数

返回值

类型:System.Object

备注

可选参数

有关可选参数的信息,请参见Office 解决方案中的可选参数

示例

下面的代码示例创建一个 XY 散点图 Chart,然后使用 XYGroups 方法显示轴组。

Private Sub UseXYGroups()
    Me.Range("A1", "A5").Value2 = 22
    Me.Range("B1", "B5").Value2 = 55

    Dim Chart1 As Microsoft.Office.Tools.Excel.Chart = _
        Me.Controls.AddChart(Me.Range("D2", "H12"), "Chart1")

    Chart1.SetSourceData(Me.Range("A1", "B5"), Excel.XlRowCol.xlColumns)
    Chart1.ChartType = Excel.XlChartType.xlXYScatterLines

    Dim group As Excel.ChartGroup = CType(Chart1.XYGroups(1), _
        Excel.ChartGroup)

    MsgBox("The axis group is: " & group.AxisGroup.ToString())
End Sub
private void UseXYGroups()
{
    this.Range["A1", "A5"].Value2 = 22;
    this.Range["B1", "B5"].Value2 = 55;

    Microsoft.Office.Tools.Excel.Chart chart1 =
        this.Controls.AddChart(this.Range["D2", "H12"], 
        "chart1");

    chart1.SetSourceData(this.Range["A1", "B5"], 
        Excel.XlRowCol.xlColumns);
    chart1.ChartType = Excel.XlChartType.xlXYScatterLines;

    Excel.ChartGroup group =
        (Excel.ChartGroup)chart1.XYGroups(1);

    MessageBox.Show("The axis group is: " + 
        group.AxisGroup.ToString());
}

.NET Framework 安全性

请参见

参考

Chart 接口

Microsoft.Office.Tools.Excel 命名空间