series points

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

series points

Post by noaksey » Tue Mar 10, 2009 11:53 am

Is there any way of getting the number of points between the Min and Max X of the screen (not the Min and Max of the series), but when the series isn't visible?

Regards,
Chris.

PS: on a similar note, I think FirstDisplayedIndex() and LastDisplayedIndex() are returning the Min and Max point of the full series rather than just what is displayed on the screen?

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 10, 2009 3:19 pm

Hi Chris,
Is there any way of getting the number of points between the Min and Max X of the screen (not the Min and Max of the series), but when the series isn't visible?
Yes, you can use NearestPoint tool like this:

Code: Select all

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

		private Steema.TeeChart.Tools.NearestPoint nearestPoint1; 

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

			nearestPoint1 = new Steema.TeeChart.Tools.NearestPoint(tChart1.Chart);
			nearestPoint1.Series = bar1;
			nearestPoint1.Active = false;

			tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
			tChart1.Zoomed += new EventHandler(tChart1_Zoomed);
			tChart1.UndoneZoom += new EventHandler(tChart1_UndoneZoom);
			tChart1.Scroll += new EventHandler(tChart1_Scroll);

			tChart1.Draw();
		}

		void tChart1_Scroll(object sender, EventArgs e)
		{
			tChart1.Draw();
		}

		void tChart1_UndoneZoom(object sender, EventArgs e)
		{
			tChart1.Draw();
		}

		void tChart1_Zoomed(object sender, EventArgs e)
		{
			tChart1.Draw();
		}

		void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
		{
			int min = nearestPoint1.GetNearestPoint(new Point(tChart1.Axes.Bottom.IStartPos, tChart1.Axes.Left.IEndPos));
			int max = nearestPoint1.GetNearestPoint(new Point(tChart1.Axes.Bottom.IEndPos, tChart1.Axes.Left.IEndPos));

			tChart1.Header.Text = "Min: " + tChart1[0].XValues[min] + " - Max: " + tChart1[0].XValues[max];
		}
PS: on a similar note, I think FirstDisplayedIndex() and LastDisplayedIndex() are returning the Min and Max point of the full series rather than just what is displayed on the screen?
No, it returns the indexes of first and last displayed points in a series: You can see how it works implementing AfterDraw event in the example above like this:

Code: Select all

		void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
		{
			int min = nearestPoint1.GetNearestPoint(new Point(tChart1.Axes.Bottom.IStartPos, tChart1.Axes.Left.IEndPos));
			int max = nearestPoint1.GetNearestPoint(new Point(tChart1.Axes.Bottom.IEndPos, tChart1.Axes.Left.IEndPos));

			//tChart1.Header.Text = "Min: " + tChart1[0].XValues[min] + " - Max: " + tChart1[0].XValues[max];
			tChart1.Header.Text = "First index: " + tChart1[0].FirstDisplayedIndex() +
														" - Last index: " + tChart1[0].LastDisplayedIndex();
		}
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