Initial and final date in the x-axis

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
acastro
Advanced
Posts: 204
Joined: Tue Oct 27, 2009 12:00 am

Initial and final date in the x-axis

Post by acastro » Mon Nov 04, 2013 4:19 pm

Is it possible to have always visible in the x-axis the initial and final date?

By example in the attached screenshot we can see fist visible date in the axis is "01/01/2009 16:00" but, the chart starts but I would like to see in the x- axis "01/01/2009 13:00" just in the begininng of the chart. Is it possible?

Thanks
Attachments
initial-finaldate.png
initial-finaldate.png (39.35 KiB) Viewed 10128 times

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

Re: Initial and final date in the x-axis

Post by Sandra » Tue Nov 05, 2013 2:44 pm

Hello wakeup,

A solution would be change the labels styles of x-axis as do in next line of code:

Code: Select all

 tChart1.Axes.Bottom.Labels.Style = AxisLabelStyle.PointValue; 
Could you tell us if previous code works in your end?

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

acastro
Advanced
Posts: 204
Joined: Tue Oct 27, 2009 12:00 am

Re: Initial and final date in the x-axis

Post by acastro » Tue Nov 05, 2013 3:40 pm

Now it show the time of the first inserted point, but if I don't have automatic scale in x-axis it doen't show the first value of the axis in the 0/0 coordinate...

Thanks

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

Re: Initial and final date in the x-axis

Post by Sandra » Wed Nov 06, 2013 9:48 am

Hello wakeup,

Other solution allow you achieve as you want is, use custom labels as I do in next lines of code:

Code: Select all

     private void InitializeChart()
    {
      tChart1.Aspect.View3D = false; 
      Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
      DateTime dt = DateTime.Today;
      Random rnd = new Random(); 
      for (int i = 0; i < 20; i++)
      {
        line1.Add(dt, rnd.Next(1000));
        dt = dt.AddDays(1);
        dt = dt.AddHours(1); 
      }
      line1.Pointer.Visible = true; 
      line1.XValues.DateTime = true;
      AddCustomLabels(); 
      tChart1.Axes.Bottom.Labels.DateTimeFormat = "dd/MM/yyyy  HH:mm";
      tChart1.Axes.Bottom.Labels.MultiLine = true;
      tChart1.Axes.Bottom.Labels.Angle = 90; 
    }
     private void AddCustomLabels()
     {
       tChart1.Axes.Bottom.Labels.Items.Clear();
       for (int i = 0; i < tChart1[0].Count; i++)
       {
         tChart1.Axes.Bottom.Labels.Items.Add(tChart1[0].XValues[i], DateTime.FromOADate(tChart1[0].XValues[i]).ToString("dd/MM/yyyy  HH:mm"));    
       }
     }
Could you tell us if previous code works in your end? On the other hand to know more about DateTimeFormat please, taking a look in this link.

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

acastro
Advanced
Posts: 204
Joined: Tue Oct 27, 2009 12:00 am

Re: Initial and final date in the x-axis

Post by acastro » Fri Nov 08, 2013 10:53 am

It is not exatly what I want because the first date would be the first point, and I would like to see the minimum of the x-axis scale. I think I could change the code to do it manually, but then I would lose the automatic way of teechart to write dates... and it is very usefull because in the manual way the dates sometimes are one over other...
So it there isn't any automatic way, I think it is better to forget it, it's not a very important requeriment.

Thanks

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

Re: Initial and final date in the x-axis

Post by Sandra » Fri Nov 08, 2013 4:40 pm

Hello wakeup,

I am not sure this suggestion help you, but you can try to change the Minimum and Maximum offset of Bottom axis and use SetMinMax to adjust the axis as you want. You can do something as next:

Code: Select all

         
       tChart1.Axes.Bottom.SetMinMax(DateTime.FromOADate(tChart1[0].XValues.Minimum), DateTime.FromOADate(tChart1[0].XValues.Maximum)); 
      tChart1.Axes.Bottom.MinimumOffset = 1;
      tChart1.Axes.Bottom.MaximumOffset = 10;  

On the other hand, custom labels are the easiest solution to customize the labels as you want and do as you expect.

Thank,
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