show datetime on the x-axis

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply

Hello, When i want to show a datetime object on the x-axis

date starts at 1899-12-30
1
100%
time aways 00:00:00
0
No votes
 
Total votes: 1

Chinfot
Newbie
Newbie
Posts: 9
Joined: Wed Sep 02, 2015 12:00 am

show datetime on the x-axis

Post by Chinfot » Tue Sep 29, 2015 7:31 am

Code: Select all

   public class NumberAxis
        {
            public DateTime X  { get; set; }
            public int Y { get; set; }
            public int Z { get; set; }
        }


        private void Form1_Load(object sender, EventArgs e)
        {
            List<NumberAxis> stemp = new List<NumberAxis>();
            for (int t = 0; t < 20; t++)
            {
                DateTime dt = DateTime.Parse("2015-02-14 12:02:06");
                NumberAxis ss = new NumberAxis() { X = dt.AddDays(t), Y = t, Z = t };
                stemp.Add(ss);
            }

            tChart1.Axes.Bottom.Labels.ExactDateTime = true;
            tChart1.Axes.Bottom.Labels.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            tChart1.Axes.Bottom.Labels.Angle = 90;

            points3D1.DataSource = stemp;      
            points3D1.XValues.DataMember = "X";
            points3D1.XValues.DataMember = "Y";
            points3D1.ZValues.DataMember = "Z"; 
        }
Attachments
demo.jpg
demo.jpg (64.3 KiB) Viewed 6791 times

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: show datetime on the x-axis

Post by Christopher » Tue Sep 29, 2015 9:16 am

The following code:

Code: Select all

    public class NumberAxis
    {
      public DateTime X { get; set; }
      public int Y { get; set; }
      public int Z { get; set; }
    }

    Points3D points3D1;

    private void InitializeChart()
    {
      points3D1 = new Points3D(tChart1.Chart);

      List<NumberAxis> stemp = new List<NumberAxis>();
      for (int t = 0; t < 20; t++)
      {
        DateTime dt = DateTime.Parse("2015-02-14 12:02:06");
        NumberAxis ss = new NumberAxis() { X = dt.AddDays(t), Y = t, Z = t };
        stemp.Add(ss);
      }

      tChart1.Axes.Bottom.Labels.Style = AxisLabelStyle.PointValue;
      tChart1.Axes.Bottom.Labels.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
      tChart1.Axes.Bottom.Labels.Angle = 90;

      points3D1.DataSource = stemp;
      points3D1.XValues.DataMember = "X";
      points3D1.YValues.DataMember = "Y";
      points3D1.ZValues.DataMember = "Z";
    }
gives me the following chart:
chart_dates.PNG
chart_dates.PNG (27.88 KiB) Viewed 6785 times
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

Chinfot
Newbie
Newbie
Posts: 9
Joined: Wed Sep 02, 2015 12:00 am

Re: show datetime on the x-axis

Post by Chinfot » Wed Sep 30, 2015 1:27 am

thank you!

Post Reply