Timestep greater than a Year

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Avatar
Newbie
Newbie
Posts: 26
Joined: Mon Mar 22, 2004 5:00 am
Location: Calgary Canada
Contact:

Timestep greater than a Year

Post by Avatar » Thu Aug 04, 2005 2:57 am

Hi Teechart

Thought pass questions I have been able to set the labels so they do not overlap and my grid is set at one year.

TChartz.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(DateTimeSteps.OneYear)

I have a graph with 53 years of data and with a vertical line every year it is getting crowded. Is there a way to set the vertical grid to show every two years or five years.

Thanks

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Fri Aug 05, 2005 9:53 am

Hi Avatar,

You should be able to use the following:

Code: Select all

 		private Steema.TeeChart.Styles.Line line1;
		
		private void InitializeChart() 
		{
			line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
			tChart1.Axes.Bottom.Labels.Angle = 90;

			line1.XValues.DateTime = true;

			DateTime today = DateTime.Today;
			Random rnd = new Random();
			
			for(int i=0; i < 50; ++i) 
			{
				line1.Add(today, rnd.Next(100));
				today = today.AddYears(1);
			}
			
			double fouryearincrement = 365 + 365 + 365 + 366;
			tChart1.Axes.Bottom.Increment = fouryearincrement;
		}
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

Avatar
Newbie
Newbie
Posts: 26
Joined: Mon Mar 22, 2004 5:00 am
Location: Calgary Canada
Contact:

Post by Avatar » Mon Aug 08, 2005 3:04 pm

Hi Chris,

I tried this code and the only time it works is if

tChart1.Axes.Bottom.Labels.Angle = 90

If I leave this line out or Angle= 0 it does't work. I get two vertical lines
in the same place reguardless of the increament set.

Suggestions?

avatar
Newbie
Newbie
Posts: 18
Joined: Mon Jun 20, 2005 4:00 am
Location: Calgary, Canada
Contact:

Post by avatar » Mon Aug 08, 2005 10:06 pm

Hi Chris

Ignore the last post

I had
TChartz.Axes.Bottom.Labels.Separation = 10
so only 90 degree would fit

Thanks Ed

avatar
Newbie
Newbie
Posts: 18
Joined: Mon Jun 20, 2005 4:00 am
Location: Calgary, Canada
Contact:

Post by avatar » Mon Aug 08, 2005 11:38 pm

Hi Chris,
The grid changes with increment greater than a year but now there is another problem.

Originally (a year ago) I had a problem where ‘DateTimeFormat = "yyyy"’ would label the year and grid to the last day of the year. So Dec 31, 1961 would appear 1961 where in fact that grid line was the start of the next year and should be labeled 1962.

If I use: ’GetDateTimeStep(DateTimeSteps.OneYear)’ the grid and the Years line up with 1962 being the start of 1962

If I use:
Dim fouryearincrement as double = 365 + 365 + 365 + 366
tChart1.Axes.Bottom.Increment = fouryearincrement
I get a grid with 4 years of spacing but the label year is the end or the previous year not the start of the next year. So the grid and label that should say 1962 now says 1961.

Miguel
Site Admin
Site Admin
Posts: 12
Joined: Thu Jul 28, 2005 4:00 am
Location: Barcelona
Contact:

Post by Miguel » Tue Aug 09, 2005 3:12 pm

Hi Avatar,

Another option to resolve your problem could be using custom labels. You can modify the original code in the following way:

Code: Select all

      private Steema.TeeChart.Styles.Line line1; 
       
      private void InitializeChart() 
      { 
         line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart); 
         tChart1.Axes.Bottom.Labels.Angle = 90; 

         line1.XValues.DateTime = true; 

         DateTime today = DateTime.Today; 
         Random rnd = new Random(); 
          
         for(int i=0; i < 50; ++i) 
         { 
            line1.Add(today, rnd.Next(100)); 
            today = today.AddYears(1); 
         } 
         //Custom labels
         for (int i=2005; i<2055; i++)
         {
              if ((i % 4)==0)
                    tChart1.Axes.Bottom.Labels.Items.Add(Steema.TeeChart.Utils.DateTime(Convert.ToDateTime("01/01/"+i.ToString())),"01/01/"+i.ToString());
          }
         //double fouryearincrement = 365 + 365 + 365 + 366; 
         //tChart1.Axes.Bottom.Increment = fouryearincrement; 
      } 
Best regards
Miguel Espinosa

Steema Software
http://support.steema.com

avatar
Newbie
Newbie
Posts: 18
Joined: Mon Jun 20, 2005 4:00 am
Location: Calgary, Canada
Contact:

Post by avatar » Tue Aug 09, 2005 5:23 pm

Thanks Miguel

that worked perfect

Post Reply