Possible to change scale labels without event handlers?

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Dave
Advanced
Posts: 139
Joined: Mon Sep 22, 2008 12:00 am

Possible to change scale labels without event handlers?

Post by Dave » Tue Mar 31, 2009 12:48 pm

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.

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 31, 2009 3:15 pm

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.
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

Dave
Advanced
Posts: 139
Joined: Mon Sep 22, 2008 12:00 am

Post by Dave » Wed Apr 01, 2009 9:28 am

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;

}

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

Post by Narcís » Fri Apr 03, 2009 9:46 am

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!
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