2D Chart for WinForms | ComponentOne
Charting Data / Entering and Modifying Chart Data / Setting the X and Y Data Arrays Using Point Values
In This Topic
    Setting the X and Y Data Arrays Using Point Values
    In This Topic

    For charts that only use the X and Y-axes (XY-Plot, Bar, and so on), the PointData property can be a convenient shortcut. The PointData property of the ChartDataSeries object allows the entering of an array of PointF point values. This property is convenient for applications that use point data, but this array will only set the X and Y data arrays. This property cannot change the values in the data arrays for Y1, Y2, or Y3.

    The following example builds a PointF array and loads it into a ChartDataSeries:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Dim ps() As PointF = _
            
    { _       
        New PointF(30.0F, 20.0F), _    
        New PointF(60.0F, 24.0F), _        
        New PointF(90.0F, 42.0F), _       
        New PointF(120.0F, 13.0F), _        
        New PointF(150.0F, 10.0F) _        
    }        
    Dim s As New ChartDataSeries()      
    C1Chart1.ChartGroups.Group1.ChartData.SeriesList.Add(s)        
    s.PointData.CopyDataIn(ps)
    

    To write code in C#

    C#
    Copy Code
    PointF [] ps =        
    {        
        new PointF(30.0F, 20.0F),       
        new PointF(60.0F, 24.0F),        
        new PointF(90.0F, 42.0F),        
        new PointF(120.0F, 13.0F),   
        new PointF(150.0F, 10.0F)       
    };        
    ChartDataSeries  s = new ChartDataSeries();       
    c1Chart1.ChartGroups.Group1.ChartData.SeriesList.Add(s);        
    s.PointData.CopyDataIn(ps);
    
    See Also