Udostępnij za pośrednictwem


Metoda Chart.GetChartElement —

Pobiera informacje o elemencie wykresu w określonych współrzędnych X i Y.

Przestrzeń nazw:  Microsoft.Office.Tools.Excel
Zestaw:  Microsoft.Office.Tools.Excel (w Microsoft.Office.Tools.Excel.dll)

Składnia

'Deklaracja
Sub GetChartElement ( _
    x As Integer, _
    y As Integer, _
    ByRef ElementID As Integer, _
    ByRef Arg1 As Integer, _
    ByRef Arg2 As Integer _
)
void GetChartElement(
    int x,
    int y,
    ref int ElementID,
    ref int Arg1,
    ref int Arg2
)

Parametry

  • ElementID
    Typ: System.Int32%
    Gdy metoda zwraca, ten argument zawiera XlChartItem wartość elementu wykresu w określonych współrzędnych.Aby uzyskać więcej informacji zobacz sekcję "Uwagi".
  • Arg1
    Typ: System.Int32%
    Gdy metoda zwraca, ten argument zawiera informacje związane z elementu wykresu.Aby uzyskać więcej informacji zobacz sekcję "Uwagi".
  • Arg2
    Typ: System.Int32%
    Gdy metoda zwraca, ten argument zawiera informacje związane z elementu wykresu.Aby uzyskać więcej informacji zobacz sekcję "Uwagi".

Uwagi

Ta metoda jest nietypowe, określ wartości dla pierwszych dwóch argumentów.Program Microsoft Office Excel wypełnienie innych argumentów i kod powinna zbadać te wartości, gdy metoda zwraca wartość.

Wartość ElementID po metoda zwraca wartość określa, czy Arg1 i Arg2 zawierają wszelkie informacje, jak pokazano w poniższej tabeli.

ElementID

Argument1

Argument2

xlAxis

AxisIndex

AxisType

xlAxisTitle

AxisIndex

AxisType

xlDisplayUnitLabel

AxisIndex

AxisType

xlMajorGridlines

AxisIndex

AxisType

xlMinorGridlines

AxisIndex

AxisType

xlPivotChartDropZone

DropZoneType

Brak

xlPivotChartFieldButton

DropZoneType

PivotFieldIndex

xlDownBars

Indeks grupy

Brak

xlDropLines

Indeks grupy

Brak

xlHiLoLines

Indeks grupy

Brak

xlRadarAxisLabels

Indeks grupy

Brak

xlSeriesLines

Indeks grupy

Brak

xlUpBars

Indeks grupy

Brak

xlChartArea

Brak

Brak

xlChartTitle

Brak

Brak

xlCorners

Brak

Brak

xlDataTable

Brak

Brak

xlFloor

Brak

Brak

xlLeaderLines

Brak

Brak

xlLegend

Brak

Brak

xlNothing

Brak

Brak

xlPlotArea

Brak

Brak

xlWalls

Brak

Brak

xlDataLabel

SeriesIndex

PointIndex

xlErrorBars

SeriesIndex

Brak

xlLegendEntry

SeriesIndex

Brak

xlLegendKey

SeriesIndex

Brak

xlSeries

SeriesIndex

PointIndex

xlShape

ShapeIndex

Brak

xlTrendline

SeriesIndex

TrendLineIndex

xlXErrorBars

SeriesIndex

Brak

xlYErrorBars

SeriesIndex

Brak

W poniższej tabeli opisano znaczenie Arg1 i Arg2 po powrocie z metody.

Argument

Opis

AxisIndex

Określa, czy oś jest podstawowym lub pomocniczym.Może być jednym z następujących XlAxisGroup stałych: xlPrimary lub xlSecondary.

AxisType

Określa typ osi.Może być jednym z następujących XlAxisType stałych: xlCategory, xlSeriesAxis, lub xlValue.

DropZoneType

Określa typ strefy upuszczania: kolumny, danych, strony lub pole wiersza.Can be one of the following XlPivotFieldOrientation constants: xlColumnField, xlDataField, xlPageField, or xlRowField.Stałych pól wierszy i kolumn określić odpowiednio pola serii i kategorii.

Indeks grupy

Określa przesunięcie w ChartGroups kolekcji dla grup wykresu.

PivotFieldIndex

Określa przesunięcie w PivotFields kolekcji dla określonej kolumny (serii), danych, strony lub pole wiersza (kategorii). -1, jeśli typ strefy upuszczania jest xlDataField.

PointIndex

Określa przesunięcie w Points kolekcji dla określonego punktu w serii.Wartość-1 wskazuje, że są zaznaczone wszystkie punkty danych.

SeriesIndex

Określa przesunięcie w Series kolekcji dla konkretnej serii.

ShapeIndex

Określa przesunięcie w Shapes kolekcji dla określonego kształtu.

TrendlineIndex

Określa przesunięcie w Trendlines kolekcji dla określonej linii trendu w ramach serii.

Przykłady

Poniższy przykład kodu tworzy Microsoft.Office.Tools.Excel.Chart , a następnie używa GetChartElement metodę wyświetlania elementu wykresu po kliknięciu wykresu.

WithEvents elementChart As Microsoft.Office.Tools.Excel.Chart

Private Sub DisplayChartElement()
    Globals.Sheet1.Range("A1", "A5").Value2 = 22
    Globals.Sheet1.Range("B1", "B5").Value2 = 55

    elementChart = Me.Controls.AddChart(Me.Range("D2", "H12"), _
        "elementChart")
    elementChart.SetSourceData(Globals.Sheet1.Range("A1", "B5"), _
        Excel.XlRowCol.xlColumns)
    elementChart.ChartType = Excel.XlChartType.xl3DColumn
End Sub

Sub elementChart_MouseDownHandler(ByVal Button As Integer, ByVal Shift As Integer, _
    ByVal x As Integer, ByVal y As Integer) Handles elementChart.MouseDown

    Dim elementID As Integer = 0
    Dim arg1 As Integer = 0
    Dim arg2 As Integer = 0

    elementChart.GetChartElement(x, y, elementID, arg1, arg2)

    MsgBox("Chart element is: " & CType(elementID, Excel.XlChartItem).ToString() _
            & Constants.vbNewLine & "arg1 is: " & arg1.ToString() _
            & Constants.vbNewLine & "arg2 is: " & arg2.ToString())
End Sub
private Microsoft.Office.Tools.Excel.Chart elementChart;

private void DisplayChartElement()
{
    this.Range["A1", "A5"].Value2 = 22;
    this.Range["B1", "B5"].Value2 = 55;

    elementChart = this.Controls.AddChart(this.Range["D2", "H12"],
        "elementChart");

    elementChart.SetSourceData(this.Range["A1", "B5"],
        Excel.XlRowCol.xlColumns);
    elementChart.ChartType = Excel.XlChartType.xl3DColumn;
    elementChart.MouseDown +=
        new Excel.ChartEvents_MouseDownEventHandler(elementChart_MouseDown);
}

void elementChart_MouseDown(int Button, int Shift, int x, int y)
{
    Int32 elementID = 0;
    Int32 arg1 = 0;
    Int32 arg2 = 0;

    elementChart.GetChartElement(x, y, ref elementID, ref arg1, ref arg2);

    MessageBox.Show("Chart element is: " + ((Excel.XlChartItem)elementID).ToString()
        + "\n arg1 is: " + arg1.ToString() + "\n arg2 is: " + arg2.ToString());
}

Zabezpieczenia programu .NET Framework

Zobacz też

Informacje

Chart Interfejs

Przestrzeń nazw Microsoft.Office.Tools.Excel