Page 1 of 1

Indices and DateTime together

Posted: Mon May 05, 2008 11:49 am
by 45194
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

Posted: Mon May 05, 2008 1:38 pm
by narcis
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!

Posted: Mon May 05, 2008 2:33 pm
by 45194
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.

Posted: Mon May 05, 2008 3:14 pm
by narcis
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);
			}
		}