Page 1 of 1

Setting bottom axis to decimal time read from CSV File.

Posted: Mon Jan 07, 2013 9:00 pm
by 13052810
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!

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

Posted: Tue Jan 08, 2013 12:08 pm
by 10050769
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,

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

Posted: Tue Jan 08, 2013 3:33 pm
by 13052810
Thanks Sandra!

Here's the data file.

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

Posted: Wed Jan 09, 2013 2:54 pm
by 10050769
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,

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

Posted: Fri Nov 15, 2013 4:35 pm
by 13052810
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!

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

Posted: Fri Nov 15, 2013 4:41 pm
by 13052810
Also, with respect to the Data file; my code strips out the Quotes prior to using the data.

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

Posted: Mon Nov 18, 2013 9:33 am
by 10050769
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,