Page 1 of 1

setting increments

Posted: Tue Mar 07, 2006 1:45 pm
by 9638326
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

Posted: Tue Mar 07, 2006 2:33 pm
by narcis
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();
		}

Posted: Tue Mar 07, 2006 2:53 pm
by 9638326
hi narcis,
thank you, ill try this, but how do i get back to auto mode once i set the increment?
rob

Posted: Tue Mar 07, 2006 2:54 pm
by narcis
Hi rob,

Use:

Code: Select all

			tChart1.Axes.Bottom.Automatic=true;

Posted: Tue Mar 07, 2006 4:09 pm
by 9638326
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

Posted: Tue Mar 07, 2006 4:15 pm
by narcis
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.

Posted: Tue Mar 07, 2006 4:50 pm
by 9638326
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