Setting bottom axis to decimal time read from CSV File.

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
tirby
Newbie
Newbie
Posts: 84
Joined: Mon Mar 16, 2009 12:00 am

Setting bottom axis to decimal time read from CSV File.

Post by tirby » Mon Jan 07, 2013 9:00 pm

Hi,

My data is read from a CSV (Comma Separated Variable)file.
I'm having trouble getting the correct time to display in the bottom axis.
I'm getting 12:00:00 for every Time Mark label on the grid in the X axis.

The time format in the CSV file is this (based on 24 hour clock):
111458
11 = 11am
14 = 14 minutes
58 = 58 seconds

The left most side (Minimum) of the bottom axis should start at 111458.
I have 2 modes of graphing:
1) Hourly
I need the Right most side (Maximum) to be 65 minutes later - 121958 (as a default span at startup), and should be displayed as 11:14:58.
As the number/value of time points increments, once the value is start+60mins., begin shiftingthe entire graph to the left by 5 mins. and displayed as 12:19:58

2) Entire length of data
The left most side (Minimum) of the bottom axis should start at 111458, and the rightmost(Maximum) to be what ever the last time stamp in the file is (in this case, it's 111807).
Again, the Minimum shoud be displayed as 11:14:58, and the Maximum should be displayed as 11:18:07

In both cases, the number of time mark labels need to be selectable by the user in ranges of 1 sec, 1 min. 5 min, 30min, 1 hour, 4 hours, 8 hours, 12 hours, 24 hours, days, weeks.

These should be easy, but they have me whipped!
Thanks!

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Setting bottom axis to decimal time read from CSV File.

Post by Sandra » Tue Jan 08, 2013 12:08 pm

Hello triby,

Thanks for information. Could you send us your data file, so we can working with your data and suggest you a good solution for you?

Thanks,
Best Regards,
Sandra Pazos / 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

tirby
Newbie
Newbie
Posts: 84
Joined: Mon Mar 16, 2009 12:00 am

Re: Setting bottom axis to decimal time read from CSV File.

Post by tirby » Tue Jan 08, 2013 3:33 pm

Thanks Sandra!

Here's the data file.
Attachments
DataFile.Zip
(4.29 KiB) Downloaded 671 times

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Setting bottom axis to decimal time read from CSV File.

Post by Sandra » Wed Jan 09, 2013 2:54 pm

Hello Triby,

Thanks for your Data. I have made a simple code where try to achieve as you want and you can apply it in your project with your data:

Code: Select all

  public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        Steema.TeeChart.Styles.FastLine Series1, Series2;
        DateTime dt; 
        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
             Series1 = new FastLine(tChart1.Chart);
            //  Series2 = new FastLine(tChart1.Chart);
            dt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 11, 14, 58);
            Random rnd = new Random();
            for (int i = 0; i < 13; i++)
            {
                Series1.Add(dt, rnd.Next(100));
                dt = dt.AddMinutes(5);
              
            }
            tChart1.Axes.Bottom.SetMinMax(DateTime.FromOADate(Series1.XValues.First), new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 12, 19, 58));
            tChart1.Axes.Bottom.Labels.DateTimeFormat = "hh:mm:ss";
            tChart1.Axes.Bottom.Labels.Style = Steema.TeeChart.AxisLabelStyle.PointValue;
        }
Could you please tell us if previous code works in your end? Could you tell if you can can apply it in your code?

I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / 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

tirby
Newbie
Newbie
Posts: 84
Joined: Mon Mar 16, 2009 12:00 am

Re: Setting bottom axis to decimal time read from CSV File.

Post by tirby » Fri Nov 15, 2013 4:35 pm

Sandra,

I get moved from 1 project to another quite often as what happened with this one.
I am now back on it and so I'm picking up where I left off.

I have copied the code you provided here into a test project.
The very last line of code is a problem:

Code: Select all

tChart1.Axes.Bottom.Labels.Style = Steema.TeeChart.AxisLabelStyle.PointValue;
The .PointValue is not a property of the AxisLabelStyle.

I commented out this line, but I fear it needs something in it's place.
Can you re-visit this issue so I can move forward?

Thanks!

tirby
Newbie
Newbie
Posts: 84
Joined: Mon Mar 16, 2009 12:00 am

Re: Setting bottom axis to decimal time read from CSV File.

Post by tirby » Fri Nov 15, 2013 4:41 pm

Also, with respect to the Data file; my code strips out the Quotes prior to using the data.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Setting bottom axis to decimal time read from CSV File.

Post by Sandra » Mon Nov 18, 2013 9:33 am

Hello tirby,

Is possible the PointValue property doesn't exist in your version of TeeChartFor.Net.
What version of TeeChartFor.Net are you using?
On the other hand, an alternative for your problem is, use custom labels as I have done in next code:

Code: Select all

public Form1()
    {
      InitializeComponent();
      InitializeChart();
    }
    Steema.TeeChart.Styles.FastLine Series1; 
    DateTime dt;
    private void InitializeChart()
    {
      tChart1.Aspect.View3D = false;
      Series1 = new FastLine(tChart1.Chart);
      dt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 11, 14, 58);
      Random rnd = new Random();
      for (int i = 0; i < 13; i  )
      {
        Series1.Add(dt, rnd.Next(100));
        dt = dt.AddMinutes(5);
      }
      tChart1.Axes.Bottom.SetMinMax(DateTime.FromOADate(Series1.XValues.First), new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 12, 19, 58));
      tChart1.Axes.Bottom.Labels.Angle = 90;
      tChart1.Axes.Bottom.Labels.Items.Clear();
      for (int i = 0; i < Series1.Count; i  )
      {
        tChart1.Axes.Bottom.Labels.Items.Add(Series1.XValues[i], DateTime.FromOADate(Series1.XValues[i]).ToString("hh:mm:ss")); 
      }
    }
Could you tell us if previous code with your data, works in your end? If it doesn't work please, try to arrange for us a simple project, because we can reproduce your exactly problem and try solution for you.

Thanks,
Best Regards,
Sandra Pazos / 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