2D Chart for WinForms | ComponentOne
Charting Data / Entering and Modifying Chart Data / Changing Data Elements in the Data Arrays
In This Topic
    Changing Data Elements in the Data Arrays
    In This Topic

    The method of altering individual data elements in the data arrays involves the ChartDataSeries and the ChartDataArray objects.

    Setting individual values through the .NET Properties window is made quite easy by the ChartDataArray Collection Editor. Data array editors exist for the X, Y, Y1, Y2, Y3, and PointData arrays. These editors can be accessed by clicking the ellipsis next to the appropriate data array in the SeriesList Collection Editor (which is available under the ChartData node of the ChartGroupsCollection Editor). Similar to the .NET collection editors, the ChartDataArray Editor has the array indices in a text box on the left and the array values on the right.

    Note: The ChartDataArray Collection Editor also contains functionality for toggling the display between Date, DateTime, and Time display. If the values for the ChartDataArray are of DateTime type, then by clicking on the header above the value column, the values displayed will toggle between DateTime, Date and Time formats.

    At run time the ChartDataArray elements are available like any normal array elements would be. Changing the values in the array objects is as easy as changing the values in an array:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    C1Chart1.ChartGroups.Group0.ChartData.SeriesList(0).X(4) = 4
    

    To write code in C#

    C#
    Copy Code
    c1Chart1.ChartGroups.Group0.ChartData.SeriesList[0].X[4] = 4;
    

    Retrieving the values from the ChartDataArray requires a similar process:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Dim xval As Single
    xval = C1Chart1.ChartGroups.Group0.ChartData.SeriesList(0).X(4)
    

    To write code in C#

    C#
    Copy Code
    float xval;
    xval = c1Chart1.ChartGroups.Group0.ChartData.SeriesList[0].X[4];
    
    See Also