Page 1 of 1

AddArrayXYZ replaces arrays instead of adding

Posted: Tue Aug 30, 2005 5:12 pm
by 9527947
Hello,

I am using Visual C++ 6 and Visual Basic 6 with TChart 7.0.0.5 on Windows XP.

I am trying to add sets of points to a surface in a loop, one set of points per iteration. I expected that calling AddArrayXYZ for 20 points, then calling AddArrayXYZ for 20 more points would result in 40 points on the surface. That is not the case, there are only 20 points. Seems like AddArrayXYZ removes old contents and only then adds new data.

I put two charts on a VB form, TChart1 and TChart2. For the TChart1 I added 4 points in one shot, and it produced a surface. For the TChart2 I add two points at a time, which demonstrates the problem.

Am I doing something wrong? I really need to add points in batches and not all together. How can I do it without AddArrayXYZ? If AddArrayXYZ is buggy, when will it be fixed?

Thanks,
Alex

Code: Select all

Option Explicit

Dim XArray() As Double
Dim YArray() As Double
Dim ZArray() As Double
    

Private Sub Form_Load()
    
    Call FillChartOne
    Call FillChartTwo
    
End Sub


Private Sub FillChartOne()

    ReDim XArray(4)
    ReDim YArray(4)
    ReDim ZArray(4)
    
    TChart1.Series(0).Clear
    
    ' Add four points:
    ' (0, 1, 0)
    ' (1, 1, 0)
    ' (0, 0, 1)
    ' (1, 0, 1)
    
    XArray(0) = 0
    XArray(1) = 1
    XArray(2) = 0
    XArray(3) = 1
    
    YArray(0) = 1
    YArray(1) = 1
    YArray(2) = 0
    YArray(3) = 0
    
    ZArray(0) = 0
    ZArray(1) = 0
    ZArray(2) = 1
    ZArray(3) = 1
    
    TChart1.Series(0).asSurface.AddArrayXYZ XArray, YArray, ZArray
    Debug.Print "TChart1 count " & TChart1.Series(0).Count

End Sub


Private Sub FillChartTwo()

    ReDim XArray(2)
    ReDim YArray(2)
    ReDim ZArray(2)
    
    TChart2.Series(0).Clear
    
    ' Add two points:
    ' (0, 1, 0)
    ' (1, 1, 0)
    ' Add two more points:
    ' (0, 0, 1)
    ' (1, 0, 1)

    XArray(0) = 0
    XArray(1) = 1
    YArray(0) = 1
    YArray(1) = 1
    ZArray(0) = 0
    ZArray(1) = 0
    TChart2.Series(0).asSurface.AddArrayXYZ XArray, YArray, ZArray
    Debug.Print "TChart2 count " & TChart2.Series(0).Count

    XArray(0) = 0
    XArray(1) = 1
    YArray(0) = 0
    YArray(1) = 0
    ZArray(0) = 1
    ZArray(1) = 1
    TChart2.Series(0).asSurface.AddArrayXYZ XArray, YArray, ZArray
    Debug.Print "TChart2 count " & TChart2.Series(0).Count
    
End Sub

Posted: Wed Aug 31, 2005 8:46 am
by narcis
Hi Alex,

Yes, that's AddArrayXYZ behaviour and is as designed, so this is not a bug, to add points with AddArrayXYZ in batches you'll have to add every batch to the same array and then add the whole array to the series.