Page 1 of 1

Possible to change scale labels without event handlers?

Posted: Tue Mar 31, 2009 12:48 pm
by 13050364
Hi

Using event handlers (eg GetAxisDrawLabel) works nearly all the time. But Ive one window where it causes an exception. I think its due to my application being multi-threaded.

So is there another way to redraw the scale labels without using event handlers? i just want to loop through all the displayed labels and multiply the value by a scaling factor. eg. 0.01 would be changed to
10 for scaling factor 1000. Im using looking for a simple for loop really.
Thanks.

Posted: Tue Mar 31, 2009 3:15 pm
by narcis
Hi Dave,

You could try using GetNextAxisLabel instead of GetAxisLabel. You may also be interested in playing with Custom Numeric Format Strings. You'll find more information about how to set axes labels format in Tutorial 4 - Axis Control, available at TeeChart's program group.

Posted: Wed Apr 01, 2009 9:28 am
by 13050364
Narcis

Thanks. I checked out Tutorial 4 and a code snippet of what I want is shown below. But Im not sure how to implement the bit in the while loop.

int total = tChart.Axes.Bottom.Labels.Items.Count;
int Factor = 1000;
int tem = 0;

while (tem < total)
{

tChart1.Axes.Bottom.Labels.Items[count] = tChart1.Axes.Bottom.Labels.Items[count] * Factor;

tem = tem + 1;

}

Posted: Fri Apr 03, 2009 9:46 am
by narcis
Hi Dave,

In that case the only solution I can think of is using custom labels as you already tried. Notice that Labels.Items.Count will return zero if no custom labels have been added to the chart. So that you can do something like this:

Code: Select all

		public Form1()
		{
			InitializeComponent();
			InitializeChart();
		}

		private void InitializeChart()
		{
			Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
			line1.FillSampleValues();

			tChart1.Axes.Bottom.Labels.Angle = 90;
			tChart1.Axes.Bottom.Labels.Items.Clear();
			int Factor = 1000;

			for (int i = 0; i < line1.Count; i++)
			{
				double tmp = line1.XValues[i] * Factor;
				tChart1.Axes.Bottom.Labels.Items.Add(line1.XValues[i], tmp.ToString());
			}
		}	
To avoid custom labels overlapping please read this thread. Please notice this is quite a long thread (has several pages) and what you are looking for may not appear in the first posts. However, several possibilities were discussed there and it covers a lot of ground on that area.

Hope this helps!