Setting the range for y-axis

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
TeeUser
Newbie
Newbie
Posts: 14
Joined: Wed Jun 22, 2005 4:00 am
Contact:

Setting the range for y-axis

Post by TeeUser » Tue Jan 24, 2006 6:41 pm

I have a teechart with datetime on x-axis and Price on y-axis.

x and y axes are set automatically depending on the data to the chart.

Now, my question is what if I want my y-axis to have a much wider range of values, i.e for ex if the range of value to the y-axis varies from 10 to 20 then I want the y-axis value to vary from 0 to 30.

Is there a way to set the y-axis range? Please let me know
Thanks.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Jan 25, 2006 8:55 am

Hi TeeUser,

Yes, this is possible using axis SetMinMax method or Minimum and Maximum properties:

Code: Select all

			tChart1.Axes.Left.SetMinMax(0,30);
or

Code: Select all

			tChart1.Axes.Left.Minimum=0;
			tChart1.Axes.Left.Maximum=30;
Best Regards,
Narcís Calvet / 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

TeeUser
Newbie
Newbie
Posts: 14
Joined: Wed Jun 22, 2005 4:00 am
Contact:

Post by TeeUser » Wed Jan 25, 2006 3:18 pm

Hi,
Thanks a lot for the reply.
The data for my teechart is dynamic, meaning I cannot hard code the min and max value. Dpending on the data from the database max value has to be (max val from the database+ 10) and the min val has to be (min val from the database-10).
Is there a way to set it dynamically.
Thanks.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Jan 25, 2006 3:41 pm

Hi TeeUser,

Yes, you can do something like the code below every time you add values to your series:

Code: Select all

		private void LeftAxisUpdate()
		{
			tChart1.Axes.Left.Automatic = false;
			tChart1.Axes.Left.Minimum=tChart1[0].YValues.Minimum-10;
			tChart1.Axes.Left.Maximum=tChart1[0].YValues.Maximum+10;
		}

		private void Form1_Load(object sender, System.EventArgs e)
		{
			line1.FillSampleValues();			

			LeftAxisUpdate();
		}
Another option is using axis MinimumOffset and MaximumOffset:

Code: Select all

		private void Form1_Load(object sender, System.EventArgs e)
		{
			line1.FillSampleValues();			

			tChart1.Axes.Left.MinimumOffset=10;
			tChart1.Axes.Left.MaximumOffset=10;
		}
Please the unit for the offset units are pixels.
Best Regards,
Narcís Calvet / 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

TeeUser
Newbie
Newbie
Posts: 14
Joined: Wed Jun 22, 2005 4:00 am
Contact:

Post by TeeUser » Wed Jan 25, 2006 7:38 pm

That helped a lot, Thanks.
I just have one other question, What if I want to keep the date time in x-axis between 9.00am and 4.00pm constant.
Thanks.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Jan 26, 2006 11:58 am

Hi TeeUser,

Yes, you can use something like:

Code: Select all

			tChart1.Axes.Bottom.Labels.DateTimeFormat = "hh:mm";
			tChart1.Axes.Bottom.SetMinMax(new DateTime(2006,1,23,9,00,00).ToOADate(),
																		new DateTime(2006,1,23,16,00,00).ToOADate());
Please notice that a date is necessary and you'll have to consider that.
Best Regards,
Narcís Calvet / 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