Indices and DateTime together

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Aptitude
Newbie
Newbie
Posts: 14
Joined: Wed May 23, 2007 12:00 am
Contact:

Indices and DateTime together

Post by Aptitude » Mon May 05, 2008 11:49 am

Hi,

Is there a way to show indices on the Top Axis and DateTime value on the bottomAxis of the same series?

I am using fastline series styles in TeeChart.NET V3. And I have added the points with the corresponding DateTime value. So I have managed to show DateTime on the bottom axis. Now I am not sure how to go about displaying the indices on the TopAxis. By indices, I mean the integer index of all the values, like the way it would have shown had I not supplied the DateTime value.

Regards,
Gaurav

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

Post by Narcís » Mon May 05, 2008 1:38 pm

Hi Gaurav,

In that case you need to do something like the code snippet below. You need to use GetAxisLabel event and set top axis label style to text so that ValueIndex event's argument has a valid value.

Code: Select all

		public Form1()
		{
			InitializeComponent();	

			Steema.TeeChart.Styles.FastLine fastLine1 = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);

			fastLine1.XValues.DateTime = true;
			fastLine1.HorizAxis = Steema.TeeChart.Styles.HorizontalAxis.Both;
			fastLine1.FillSampleValues();

			tChart1.Axes.Top.Labels.Style = Steema.TeeChart.AxisLabelStyle.Text;
			tChart1.GetAxisLabel += new Steema.TeeChart.GetAxisLabelEventHandler(tChart1_GetAxisLabel);
		}

		void tChart1_GetAxisLabel(object sender, Steema.TeeChart.GetAxisLabelEventArgs e)
		{
			if (sender == tChart1.Axes.Top)
			{
				e.LabelText = e.ValueIndex.ToString();
			}
		}
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

Aptitude
Newbie
Newbie
Posts: 14
Joined: Wed May 23, 2007 12:00 am
Contact:

Post by Aptitude » Mon May 05, 2008 2:33 pm

Yes it did. Any ideas on how to synchronise it with the labels on bottom axis? I don't want to see two sets of gridlines. If I can get a top label wherever I have bottom label, that would be ideal.

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

Post by Narcís » Mon May 05, 2008 3:14 pm

Hi Aptitude,

In that case you can try using custom labels for the top axis as shown below. However, this may only work if bottom axis labels are placed exactly in a data point.

Code: Select all

		public Form1()
		{
			InitializeComponent();

			tChart1.Aspect.View3D = false;
			Steema.TeeChart.Styles.FastLine fastLine1 = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);

			fastLine1.XValues.DateTime = true;
			fastLine1.HorizAxis = Steema.TeeChart.Styles.HorizontalAxis.Both;
			fastLine1.FillSampleValues();
			tChart1.Axes.Top.Labels.Items.Clear();
			tChart1.GetNextAxisLabel += new Steema.TeeChart.GetNextAxisLabelEventHandler(tChart1_GetNextAxisLabel);

			Bitmap bmp = tChart1.Bitmap;
		}

		void tChart1_GetNextAxisLabel(object sender, Steema.TeeChart.GetNextAxisLabelEventArgs e)
		{
			if (sender == tChart1.Axes.Bottom)
			{
				tChart1.Axes.Top.Labels.Items.Add(e.LabelIndex);
			}
		}
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