DateTime in TextSource

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
M.Takeda
Newbie
Newbie
Posts: 18
Joined: Tue Aug 17, 2004 4:00 am

DateTime in TextSource

Post by M.Takeda » Sat Mar 17, 2007 1:23 am

With WindowsXP,VB2005.Net and TeeChart for .NET v2

Following my code comes error.
How to coding to get X-Values as datetime with textsource ?

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If System.IO.File.Exists(Application.StartupPath & "\2007-03-16.txt") Then
Line1.Clear()
TextSource1.HeaderLines = 1
TextSource1.Separator = ","
TextSource1.Series = Line1
TextSource1.Fields.Add(0, "X")
TextSource1.Fields.Add(1, "Y")
TextSource1.LoadFromFile(Application.StartupPath & "\2007-03-16.txt")
End If
End Sub

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
TChart1.Aspect.View3D = False
TChart1.Legend.Visible = False
End Sub

--- 2007-03-16 Text File-----
2007/03/16 12:44:43,87.05,50.59
2007/03/16 12:44:45,82.57,44.08
2007/03/16 12:44:47,78.09,37.57
2007/03/16 12:44:49,73.6,31.06
2007/03/16 12:44:51,69.12,24.55
2007/03/16 12:44:53,64.64,58.04
2007/03/16 12:44:55,60.16,51.53

Thank you for prompt advice in advance.

Edu
Advanced
Posts: 206
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia

Post by Edu » Mon Mar 19, 2007 10:19 am

Hi

First you have to indicate that the X value of the serie is a DateTime, and then you can import the Chart. You can do something similiar as below code

Code: Select all

   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Line1.XValues.DateTime = True
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim ts As New Steema.TeeChart.Data.TextSource()
        Try
            Cursor = Cursors.WaitCursor
            ts.HeaderLines = 0
            ts.Separator = ","
            ts.Series = Line1
            ts.Fields.Add(0, "X")
            ts.Fields.Add(2, "Y")
            ts.LoadFromFile("c:\your_file.txt")
        Finally
            Cursor = Cursors.Default
        End Try
    End Sub
Best Regards,
Edu

Steema Support Central
http://support.steema.com/

Post Reply