Page 1 of 1

How to realize series auto-shifting

Posted: Wed Nov 08, 2006 2:55 am
by 9529132
Hi,

I would like to realize something similar to the demo "delete point range", but the difference is that the displayed range keeps unchanged and the max x-axis value is always that of a new coming data. I could use m_chart1.GetAxis().GetBottom().SetMaximum() function to change the x-axis max every time the new data comes in. But will that cause the chart to refresh too fast? Is there a better way to realize it?

Thanks a lot.
David

Posted: Wed Nov 08, 2006 4:19 pm
by narcis
Hi David,

You don't need to change the bottom axis maximum. By default, TeeChart axes automatically scale to the series data, even if it's changing.

Posted: Thu Nov 09, 2006 1:12 am
by 9529132
Hi, Narcís,

Yes, I know it will automatically scale. But the problem is every time it scales, it moves a segment of data, instead of one, to the left, sets the maximum value to be much larger than the current data, and then leaves an empty area without data. This visual effect is not good enough.

I would like to realize something like smooth shifting with only one or two data points shifted to the left every time the x value of data exceeds max value of the axis. And the max x-axis value should always remain the same as the x-value of new-coming data.

Hopefully I made myself clear.

David

Posted: Thu Nov 09, 2006 8:33 am
by narcis
Hi David,

Then you may be interested in doing something like in the All Features\Welcome!\Speed\Delete Point Range example in the features demo. You'll find the example at TeeChart's program group.

Posted: Thu Nov 09, 2006 9:57 am
by 9529132
Hi, Narcís,

That example only realized the "delete old points" function that I want. But it uses the default fastline scale, the problem of which is every time it scales, it jumps left with a segment of data, sets the maximum value to be much larger than the current data, and then leaves an empty area without data. This visual effect is not good enough. What I want is a smooth shift, not a sudden jump to the left.

Hopefully I made my self clear this time.

David

Posted: Thu Nov 09, 2006 10:08 am
by narcis
Hi David,

Ok, instead of deleting a big range of points you could delete them one by one using the Delete method, for example:

Code: Select all

    If TChart1.Series(0).Count > 100 Then
        TChart1.Series(0).Delete 0
    End If
This example will remove the first point in the series if it has more than 100 points

Posted: Thu Nov 09, 2006 10:25 am
by 9529132
Hi, Narcís,

In my understanding, I don't think the deleterange caused the jump left of the fastline series. Even if I don't delete any point, it will automatically jump left if the x value exceeds the initial x-axis max to allow some range to display new coming data. This is the default setting of fastline series. I believe I have to manually set the maximum value of the x-axis after new data coming in to avoid the jumping effect. I just wonder if there is an effective way to do it.

David

Posted: Thu Nov 09, 2006 11:26 am
by narcis
Hi David,

This works fine for me here using v7.0.1.2 and using the code below. Could you please test if it works at your end and if necessary modify it so that I can reproduce your problem here?

Code: Select all

Dim c As Integer

Private Sub Form_Load()
    TeeCommander1.Chart = TChart1
    
    TChart1.AddSeries scFastLine
    Timer1.Enabled = True
    Timer1.Interval = 50
    
    c = 0
End Sub

Private Sub Timer1_Timer()
    With TChart1.Series(0)
        .AddXY c, Rnd, "", clTeeColor
    
        If .Count > 100 Then
            .Delete (0)
        End If
        
        c = c + 1
    End With
End Sub
Thanks in advance.