Teechart Can't Handle Dates less than 1900???
Teechart Can't Handle Dates less than 1900???
I created a forecast and dates dip into the 1800's and everything printed backwards on the chart.
Here's test code to show the problem:
vb.net
Dim dtTest as DateTime
dtTest = CDate("1/1/1809 2:00 am")
Me.TChart1.Series(0).Add(dtTest, 2)
dtTest = CDate("1/1/1809 3:00 am")
Me.TChart1.Series(0).Add(dtTest, 3)
dtTest = CDate("1/1/1809 4:00 am")
Me.TChart1.Series(0).Add(dtTest, 4)
Chart is defined with bottom axis as datetime and so is fastline series.
If there's a limitation on printing dates in 1800's I didn't see it in the documentation and this control would then be worthless to me.
I"m hoping it's some trick I didn't know or something simple.
thanks in advance anyone who can help me get past this challenge.
Joseph
- Attachments
-
- Code to replicate.
- DrawingBackwardsCode.png (3.72 KiB) Viewed 6237 times
-
- Same chart with years changed to 1909 or 2009 works as expected -- not backwards.
- 1900sNormal.png (24.66 KiB) Viewed 6238 times
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: Teechart Can't Handle Dates less than 1900???
The explanation for this behaviour is as follows. CDate("1/1/1809 2:00 am") returns a negative double value, as can be seen in this simple test:jzarech wrote:If there's a limitation on printing dates in 1800's I didn't see it in the documentation and this control would then be worthless to me.
Code: Select all
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim dtTest As DateTime
dtTest = CDate("1/1/1809 2:00 am")
MessageBox.Show(dtTest.ToOADate().ToString())
End Sub
So when running code such as the following:
Code: Select all
Private Sub InitializeChart()
Dim dtTest As DateTime
Dim series As Line
series = New Line(tChart1.Chart)
dtTest = CDate("1/1/1809 2:00 am")
series.Add(dtTest, 2)
dtTest = CDate("1/1/1809 3:00 am")
series.Add(dtTest, 3)
dtTest = CDate("1/1/1809 4:00 am")
series.Add(dtTest, 4)
series.XValues.DateTime = True
tChart1.Axes.Bottom.Labels.Angle = 90
tChart1.Axes.Bottom.Labels.DateTimeFormat = "dd/MM/yyyy hh:mm:ss"
End Sub
Code: Select all
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim dtTest As DateTime
dtTest = DateTime.FromOADate(0.0)
MessageBox.Show(dtTest.ToShortDateString() + " " + dtTest.ToShortTimeString())
End Sub
Code: Select all
tChart1.Axes.Bottom.Inverted = True
Code: Select all
Private Sub InitializeChart()
Dim dtTest As DateTime
Dim series As Line
series = New Line(tChart1.Chart)
dtTest = CDate("1/1/1809 2:00 am")
series.Add(dtTest, 2)
dtTest = CDate("1/1/1809 3:00 am")
series.Add(dtTest, 3)
dtTest = CDate("1/1/1809 4:00 am")
series.Add(dtTest, 4)
series.XValues.DateTime = True
tChart1.Axes.Bottom.Labels.Angle = 90
tChart1.Axes.Bottom.Labels.DateTimeFormat = "dd/MM/yyyy hh:mm:ss"
tChart1.Axes.Bottom.Inverted = True
End Sub
Best Regards,
Christopher Ireland / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |