How to realize series auto-shifting

TeeChart for ActiveX, COM and ASP
Post Reply
David
Advanced
Posts: 203
Joined: Tue Nov 08, 2005 5:00 am

How to realize series auto-shifting

Post by David » Wed Nov 08, 2006 2:55 am

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Nov 08, 2006 4:19 pm

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

David
Advanced
Posts: 203
Joined: Tue Nov 08, 2005 5:00 am

Post by David » Thu Nov 09, 2006 1:12 am

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Nov 09, 2006 8:33 am

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

David
Advanced
Posts: 203
Joined: Tue Nov 08, 2005 5:00 am

Post by David » Thu Nov 09, 2006 9:57 am

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Nov 09, 2006 10:08 am

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
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

David
Advanced
Posts: 203
Joined: Tue Nov 08, 2005 5:00 am

Post by David » Thu Nov 09, 2006 10:25 am

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Nov 09, 2006 11:26 am

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply