Page 1 of 1

Property Last does not update when adding values from array

Posted: Wed May 10, 2006 10:11 am
by 9640765
When adding values to a serie by adding the whole array at once, the property "Last" of xValues/yValues of the series still remains 0. This leads to errors using the DownSampling-Function.

Example:
dim xVal(100) as double, yVal(100) as single
xVal(0) = 1
yVal(0) = 1
....
tChart1.series(0).add(xVal, yVal)

->the property "Last" is still 0!!

Using a for-loop to add every point individual, the property is being updated and the DownSampling-Function works.

How can I force TeeChart to update this value.

Thanks,
Dirk

Posted: Mon May 15, 2006 4:12 pm
by narcis
Hi Dirk,

I did some tests and Last property works fine. However, I found another error when populating the series with an array. I've added this issue (TF02011417) to our defect list to be fixed for future releases.

Using the code below gives an IndexOutOfRange error when clicking Button1 (populating the series with an array) but works fine clicking Button2 (populating the series with a for loop).

Code: Select all

    Private NumValues As Integer = 1000

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim i As Integer
        Dim rndVal As New Random()
        Dim xVal(NumValues) As Double, yVal(NumValues) As Single

        For i = 0 To xVal.Length - 1
            xVal(i) = i
            yVal(i) = rndVal.Next()
        Next i
        Line1.Add(xVal, yVal)

        TChart1.Header.Text = Line1.XValues.Last.ToString() & ", " & Line1.YValues.Last.ToString()
        Line2.CheckDataSource()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim i As Integer
        Dim rndVal As New Random()

        For i = 0 To NumValues - 1
            Line1.Add(i, rndVal.Next())
        Next

        TChart1.Header.Text = Line1.XValues.Last.ToString() & ", " & Line1.YValues.Last.ToString()
        Line2.CheckDataSource()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim i As Integer

        For i = 0 To TChart1.Series.Count - 1
            TChart1.Series(i).Clear()
        Next
    End Sub