setting increments

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Torte
Newbie
Newbie
Posts: 19
Joined: Fri Sep 16, 2005 4:00 am

setting increments

Post by Torte » Tue Mar 07, 2006 1:45 pm

hi there,

besides the option to automatically asign the labels on an axis i need two options where one can enter either the wanted gap between labels or the number of labels he wants to see.
e.g. ymin=0,ymax=2000, option 1=>gap=500(entered)
=>5 labels(0,500,1000,1500,2000)
option 2=>labelcount=3(entered)
=>3 labels(666,1333,1999(or 2k))
how to archieve this? i tried some own functions but they wont work very accurately...is there a way to say e.g. labels at 0 and 2000 are allways shown and only the rest is calculated? how to get back to automatic asignment?
best regards,
robert

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

Post by Narcís » Tue Mar 07, 2006 2:33 pm

Hi robert,

You can easily achieve what you request doing something like this:

Code: Select all

		private double Gap=500;
		private int NumLabels=3;

		private void SetLabels()
		{
			if (checkBox1.Checked) 
				tChart1.Axes.Bottom.Increment=Gap;
			else
				tChart1.Axes.Bottom.Increment=(tChart1.Axes.Bottom.Maximum-tChart1.Axes.Bottom.Minimum)/NumLabels;
		}

		private void Form1_Load(object sender, System.EventArgs e)
		{
			for (int i=0;i<=2000;++i)
			{
				line1.Add(i);
			}

			tChart1.Axes.Bottom.SetMinMax(0,2000);			
			SetLabels();
		}

		private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
		{
			SetLabels();
		}
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

Torte
Newbie
Newbie
Posts: 19
Joined: Fri Sep 16, 2005 4:00 am

Post by Torte » Tue Mar 07, 2006 2:53 pm

hi narcis,
thank you, ill try this, but how do i get back to auto mode once i set the increment?
rob

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

Post by Narcís » Tue Mar 07, 2006 2:54 pm

Hi rob,

Use:

Code: Select all

			tChart1.Axes.Bottom.Automatic=true;
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

Torte
Newbie
Newbie
Posts: 19
Joined: Fri Sep 16, 2005 4:00 am

Post by Torte » Tue Mar 07, 2006 4:09 pm

hi again,

i know this one but it just wont work:(
especially when zooming the labels wont readjust like they normally do in auto mode!
there must be more set to false then just tChart1.Axes.Bottom.Automatic when setting the increment hard by hand
rob

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

Post by Narcís » Tue Mar 07, 2006 4:15 pm

Hi rob,

Ok, then you can set the axis increment to zero as it is the minimum step between axis labels. It must be a positive number or DateTime value. TChart will use this value as the starting axis labels step. If there is not enough space for all labels, TChart will calculate a bigger one.
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

Torte
Newbie
Newbie
Posts: 19
Joined: Fri Sep 16, 2005 4:00 am

Post by Torte » Tue Mar 07, 2006 4:50 pm

working, thank you:)
even tho i think its strange that setting the increment to zero does what normally the automatic=true should do...with increment=0 zooming is working even without setting auto to true again
thanks again,
rob

Post Reply