Page 1 of 1

autoscaling only visible points on the TeeChart

Posted: Fri Jan 09, 2009 5:17 pm
by 9787981
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.

Posted: Mon Jan 12, 2009 10:21 am
by narcis
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);
		}