autoscaling only visible points on the TeeChart

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
BenW
Advanced
Posts: 119
Joined: Wed Aug 10, 2005 4:00 am

autoscaling only visible points on the TeeChart

Post by BenW » Fri Jan 09, 2009 5:17 pm

Hello.

When autoscale is enabled for a y-axis, is it possible to have autoscaling (i.e. the dynamic adjustment of the y-axis max and min values), only applied based on the visible points. It seems that autoscaling is being determined based on all points in the series, not just those visible.

thanks,
Ben.

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 Jan 12, 2009 10:21 am

Hi Ben,

In that case you can do something like this:

Code: Select all

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

		private Steema.TeeChart.Styles.Line line1;

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

			tChart1.Scroll += new EventHandler(tChart1_Scroll);
			tChart1.UndoneZoom += new EventHandler(tChart1_UndoneZoom);
		}

		void tChart1_UndoneZoom(object sender, EventArgs e)
		{
			tChart1.Axes.Left.Automatic = true;
		}

		void tChart1_Scroll(object sender, EventArgs e)
		{
			double min = line1.MaxYValue();
			double max = line1.MinYValue();

			for (int i = line1.FirstVisibleIndex; i <= line1.LastVisibleIndex; i++)
			{
				double tmp = line1.YValues[i];

				if (tmp < min)
				{
					min = tmp;
				}

				if (tmp > max)
				{
					max = tmp;
				}
			}

			tChart1.Axes.Left.SetMinMax(min, max);
		}
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