Page 1 of 1

Timestep greater than a Year

Posted: Thu Aug 04, 2005 2:57 am
by 8124568
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

Posted: Fri Aug 05, 2005 9:53 am
by Chris
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;
		}

Posted: Mon Aug 08, 2005 3:04 pm
by 8124568
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?

Posted: Mon Aug 08, 2005 10:06 pm
by 9637235
Hi Chris

Ignore the last post

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

Thanks Ed

Posted: Mon Aug 08, 2005 11:38 pm
by 9637235
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.

Posted: Tue Aug 09, 2005 3:12 pm
by Miguel
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; 
      } 

Posted: Tue Aug 09, 2005 5:23 pm
by 9637235
Thanks Miguel

that worked perfect