Chart2D CopyXVectorIn and CopyYVectorIn Error

Posted by: SatishMatani on 25 February 2019, 4:57 am EST

    • Post Options:
    • Link

    Posted 25 February 2019, 4:57 am EST

    Hello,

    I am getting “Incorrect array dimensions” error using CopyXVectorIn and CopyYVectorIn in Chart2d.

    Following is the abbreviated version of the code:

    Dim r

    Dim i As Integer

    r = 10

    Dim Lx(r)

        For i = 0 To UBound(Lx) - 1
            Lx(i) = i
    
        Next
    
        With Chart
            .Border.Type = C1Chart2D8.BorderTypeConstants.oc2dBorderFrameIn
            With .ChartArea
                With .Axes("X")
                    .Min.Value = -5
                    .Max.Value = Lx(9)
                    .Title.Text = "X Axes"
                    .Origin.Value = 0
                End With
    
                With .Markers("Y")
                    .Method = C1Chart2D8.MarkerMethodConstants.oc2dMarkerDataIndex
                End With
    
    
            End With
            .Header.Text.Text = "Title"
    
            With .ChartGroups(1)
                With .Data
    
                    .NumSeries = 1
                    .CopyXVectorIn(1, Lx)
                End With
    
            End With
    
  • Posted 28 February 2019, 3:51 pm EST

    Hi Satish,

    I could observe the issue using the code snippet you shared.

    I am investigating it further at my end and will let you know once it is done.

    Thanks,

    Pragati

  • Posted 5 March 2019, 4:41 pm EST

    Hi Satish,

    In order to resolve the error, you just need to set the Chart2DData object’s NumPoints property to the number of points in your series. In your case, it should be set as follows:

    
    Dim r
     Dim i As Integer
     r = 10
     Dim Lx(10)
    
    
     For i = 0 To UBound(Lx) - 1
     Lx(i) = i
    
     Next
    
     With Chart
     .Border.Type = C1Chart2D8.BorderTypeConstants.oc2dBorderFrameIn
     With .ChartArea
     With .Axes("X")
     .Min.Value = -5
     .Max.Value = Lx(9)
     .Title.Text = "X Axes"
     .Origin.Value = 0
     End With
    
     With .Markers("Y")
     .Method = C1Chart2D8.MarkerMethodConstants.oc2dMarkerDataIndex
     End With
    
    
     End With
     .Header.Text.Text = "Title"
    
     With .ChartGroups(1)
     With .Data
    
     .NumSeries = 1
     .NumPoints(1) = 11 'Set this to number of points in the series
    
     .CopyXVectorIn 1, Lx
     End With
    
     End With
    
    End With
    
    

    Please refer the attached application which works fine at my end.

    Thanks,

    Pragati

    Project1.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels