Using datetime on x-axis

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Jeff Motter
Newbie
Newbie
Posts: 5
Joined: Fri May 28, 2004 4:00 am

Using datetime on x-axis

Post by Jeff Motter » Mon Jul 12, 2004 1:45 pm

VB.NET.
I'm adding points to a line series. The x-axis is datetime and the y-axis is double. The problem I'm having, is that the datetime values being added are not exact increments of each other.

X-Axis Y-Axis
2004-07-01 21:00:00 3
2004-07-02 18:00:00 3
2004-07-03 20:00:00 3
2004-07-04 10:00:00 3
2004-07-05 21:00:00 4
2004-07-06 16:00:00 4
2004-07-07 16:00:00 4

I keep getting x-axis lables "in-between" these when I add the points. I only want the points of data I'm adding and nothing else. I didn't have this problem in VB6 when I was using the ActiveX version of the control.

Would it be easier to add these points as Text on the x-axis, and doubles on the y-axis?

Here's my code:
While dr.Read()
TChart1.Series(0).Add(dr.GetDate(0).Value, dr.GetDecimal(1).Value)
TChart1.Series(1).Add(dr.GetDate(0).Value, dr.GetDecimal(2).Value)
End While

Jeff
Last edited by Jeff Motter on Tue Jul 13, 2004 1:00 pm, edited 1 time in total.

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Tue Jul 13, 2004 6:24 am

Hi Jeff,
Would it be easier to add these points as Text on the x-axis, and doubles on the y-axis?
Exactly ... there is a difference between adding date (or any other) values as XValues or as string lables; please have a look at the following code to see the difference:

Code: Select all

 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        TChart1.Series.Add(New Steema.TeeChart.Styles.Line)
        TChart1.Axes.Bottom.Labels.Angle = 90
        TChart1.Axes.Bottom.Increment = 1
        TChart1.Series(0).Clear()
        TChart1.Series(0).Add(DateTime.Parse("01/07/2004 21:00:00"), 3)
        TChart1.Series(0).Add(DateTime.Parse("02/07/2004 18:00:00"), 3)
        TChart1.Series(0).Add(DateTime.Parse("03/07/2004 20:00:00"), 3)
        TChart1.Series(0).Add(DateTime.Parse("04/07/2004 10:00:00"), 3)
        TChart1.Series(0).Add(DateTime.Parse("05/07/2004 21:00:00"), 4)
        TChart1.Series(0).Add(DateTime.Parse("06/07/2004 16:00:00"), 4)
        TChart1.Series(0).Add(DateTime.Parse("07/07/2004 16:00:00"), 4)

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TChart1.Series(0).Clear()
        TChart1.Series(0).Add(3, DateTime.Parse("01/07/2004 21:00:00").ToString("dd/MM/yyyy"))
        TChart1.Series(0).Add(3, DateTime.Parse("02/07/2004 18:00:00").ToString("dd/MM/yyyy"))
        TChart1.Series(0).Add(3, DateTime.Parse("03/07/2004 20:00:00").ToString("dd/MM/yyyy"))
        TChart1.Series(0).Add(3, DateTime.Parse("04/07/2004 10:00:00").ToString("dd/MM/yyyy"))
        TChart1.Series(0).Add(4, DateTime.Parse("05/07/2004 21:00:00").ToString("dd/MM/yyyy"))
        TChart1.Series(0).Add(4, DateTime.Parse("06/07/2004 16:00:00").ToString("dd/MM/yyyy"))
        TChart1.Series(0).Add(4, DateTime.Parse("07/07/2004 16:00:00").ToString("dd/MM/yyyy"))
    End Sub

Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

Post Reply