Reset Minimum/Maximum of a series datapoints

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Buchi Labortechnik AG
Newbie
Newbie
Posts: 2
Joined: Fri Nov 15, 2002 12:00 am
Location: Switzerland
Contact:

Reset Minimum/Maximum of a series datapoints

Post by Buchi Labortechnik AG » Mon Feb 09, 2004 8:43 am

Hi

I already published a question to public.teechart.dotnet, but as I am a registred user Ichange now to this forum:

When using

Code: Select all

Steema.TeeChart.Axis.Automatic=true
, the Minimum/Maximum is taken from the series Minimum/Maximum.
I set this, when I do a Backzoom.
Now I have a new set of series with new Minimum/Maximum, and I want to reset the series Minimum/Maximum that they are calculated from new.

Is there a posibility to do that?

As workaround I set it manually by using

Code: Select all

Steema.TeeChart.Axis.SetMinMax 
Method

Best regards
Richard Boesiger :D
Richard Boesiger
Buchi Labortechnik AG, Switzerland
mailto:boesiger.r@buchi.com

Marc
Site Admin
Site Admin
Posts: 1217
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Post by Marc » Mon Feb 09, 2004 10:10 pm

Hello Richard,

The axes should automatically adjust when new points are added. The Series Maximum and Minimum values are also automatically updated when new Series points are added or points deleted.

If the Chart is zoomed then the Axis won't automatically resize to show new Series values, a UndoZoom should be done to enable the Automatic Axis scaled view.

From some elements of the code syntax in your post this appears to be the TeeChart AX version, is that correct? It is not too important as both the native C#.Net version and the AX version include the Axis AdjustMaxMin method that may be what you require here. Nevertheless we would be interested to hear how to reproduce the issue if the Axes are failing to set the scale automatically when required.

AdjustMaxMin:
eg.
TeeChart ActiveX version:
TChart1.Axis.Left.AdjustMaxMin
TeeChart NET version:
TChart1.Axes.Left.AdjustMaxMin

To make it easier for us to distinguish between versions for support purposes, if the version of TeeChart that you are using is the AX version please post related questions to the ActiveX forum.

With thanks,

Regards,
Marc Meumann
Steema Support

Buchi Labortechnik AG
Newbie
Newbie
Posts: 2
Joined: Fri Nov 15, 2002 12:00 am
Location: Switzerland
Contact:

Post by Buchi Labortechnik AG » Tue Feb 10, 2004 9:16 am

I'm actually using TeeChart .NET with C#.

I had the problem with the version 1.0.1189.31308.
With the new version 1.0.1452.42972 the problem seems to be solved :D .
I recognize different behavior between the 2 versions.

Best regards

:lol: Richard

Following is a small test:

Code: Select all

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace TeeChartTest
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button buttonClose;
		private Steema.TeeChart.TChart tChart1;
		private System.Windows.Forms.Button buttonEditor;
		private Steema.TeeChart.Styles.FastLine fastLine1;
		private System.Windows.Forms.Button buttonStep;
		private System.Windows.Forms.TextBox textBoxLog;
		private System.Windows.Forms.CheckBox checkBox1;
		private System.Windows.Forms.CheckBox checkBox2;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Form1()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.buttonClose = new System.Windows.Forms.Button();
			this.textBoxLog = new System.Windows.Forms.TextBox();
			this.tChart1 = new Steema.TeeChart.TChart();
			this.fastLine1 = new Steema.TeeChart.Styles.FastLine();
			this.buttonEditor = new System.Windows.Forms.Button();
			this.buttonStep = new System.Windows.Forms.Button();
			this.checkBox1 = new System.Windows.Forms.CheckBox();
			this.checkBox2 = new System.Windows.Forms.CheckBox();
			this.SuspendLayout();
			// 
			// buttonClose
			// 
			this.buttonClose.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.buttonClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.buttonClose.Location = new System.Drawing.Point(8, 520);
			this.buttonClose.Name = "buttonClose";
			this.buttonClose.TabIndex = 0;
			this.buttonClose.Text = "Close";
			this.buttonClose.Click += new System.EventHandler(this.buttonClose_Click);
			// 
			// textBoxLog
			// 
			this.textBoxLog.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.textBoxLog.BackColor = System.Drawing.Color.White;
			this.textBoxLog.Location = new System.Drawing.Point(8, 344);
			this.textBoxLog.Multiline = true;
			this.textBoxLog.Name = "textBoxLog";
			this.textBoxLog.ReadOnly = true;
			this.textBoxLog.ScrollBars = System.Windows.Forms.ScrollBars.Both;
			this.textBoxLog.Size = new System.Drawing.Size(696, 168);
			this.textBoxLog.TabIndex = 1;
			this.textBoxLog.Text = "";
			// 
			// tChart1
			// 
			this.tChart1.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			// 
			// tChart1.Aspect
			// 
			this.tChart1.Aspect.View3D = false;
			this.tChart1.Cursor = System.Windows.Forms.Cursors.Default;
			// 
			// tChart1.Header
			// 
			this.tChart1.Header.Lines = new string[] {
														 "TeeChart"};
			// 
			// tChart1.Legend
			// 
			this.tChart1.Legend.Visible = false;
			this.tChart1.Location = new System.Drawing.Point(8, 8);
			this.tChart1.Name = "tChart1";
			this.tChart1.Series.Add(this.fastLine1);
			this.tChart1.Size = new System.Drawing.Size(696, 328);
			this.tChart1.TabIndex = 2;
			// 
			// fastLine1
			// 
			// 
			// fastLine1.LinePen
			// 
			this.fastLine1.LinePen.Color = System.Drawing.Color.Red;
			this.fastLine1.Title = "fastLine1";
			// 
			// fastLine1.XValues
			// 
			this.fastLine1.XValues.Order = Steema.TeeChart.Styles.ValueListOrder.Ascending;
			// 
			// buttonEditor
			// 
			this.buttonEditor.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.buttonEditor.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.buttonEditor.Location = new System.Drawing.Point(96, 520);
			this.buttonEditor.Name = "buttonEditor";
			this.buttonEditor.TabIndex = 0;
			this.buttonEditor.Text = "Editor";
			this.buttonEditor.Click += new System.EventHandler(this.buttonEditor_Click);
			// 
			// buttonStep
			// 
			this.buttonStep.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.buttonStep.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.buttonStep.Location = new System.Drawing.Point(184, 520);
			this.buttonStep.Name = "buttonStep";
			this.buttonStep.TabIndex = 0;
			this.buttonStep.Text = "Step >";
			this.buttonStep.Click += new System.EventHandler(this.buttonStep_Click);
			// 
			// checkBox1
			// 
			this.checkBox1.Location = new System.Drawing.Point(272, 520);
			this.checkBox1.Name = "checkBox1";
			this.checkBox1.Size = new System.Drawing.Size(152, 24);
			this.checkBox1.TabIndex = 3;
			this.checkBox1.Text = "Use Clear before Add";
			// 
			// checkBox2
			// 
			this.checkBox2.Location = new System.Drawing.Point(456, 520);
			this.checkBox2.Name = "checkBox2";
			this.checkBox2.Size = new System.Drawing.Size(152, 24);
			this.checkBox2.TabIndex = 3;
			this.checkBox2.Text = "Own X Values";
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.CancelButton = this.buttonEditor;
			this.ClientSize = new System.Drawing.Size(712, 549);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.checkBox1,
																		  this.tChart1,
																		  this.textBoxLog,
																		  this.buttonClose,
																		  this.buttonEditor,
																		  this.buttonStep,
																		  this.checkBox2});
			this.Name = "Form1";
			this.Text = "TeeChartTest";
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}

		private void buttonClose_Click(object sender, System.EventArgs e)
		{
			Close();
		}

		int m_Counter = 0;

		private void buttonEditor_Click(object sender, System.EventArgs e)
		{
			this.tChart1.ShowEditor();
		}

		private void buttonStep_Click(object sender, System.EventArgs e)
		{
			switch(m_Counter++)
			{
				case 0:
					tChart1.Series[0].Clear();
					AppendLog("Step 1: Empty Chart");
					tChart1.Refresh();
					break;
				case 1:
				case 2:
					double[] y1 = new Double[] {1.0, 2.0, 3.0, 4.0, 5.0, 4.5, 3.5, 2.5, 1.5, 0.5};
					if(checkBox1.Checked)
					{
						tChart1.Series[0].Clear();
					}
					if(checkBox2.Checked)
					{
						double[] x1 = new Double[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0};
						tChart1.Series[0].Add(x1, y1);
					}
					else
					{
						tChart1.Series[0].Add(y1);
					}
					tChart1.Refresh();
					AppendLog("Step " + ((int)m_Counter-1).ToString() + ": Add 10 values");
					break;
				case 3:
					double[] y2 = new Double[] {1.0, 2.0, 3.0, 4.0, 5.0, 4.5, 3.5, 2.5, 1.5, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0, 4.5, 3.5, 2.5, 1.5, 0.5};
					if(checkBox1.Checked)
					{
						tChart1.Series[0].Clear();
					}
					if(checkBox2.Checked)
					{
						double[] x2 = new Double[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0};
						tChart1.Series[0].Add(x2, y2);
					}
					else
					{
						tChart1.Series[0].Add(y2);
					}
					tChart1.Refresh();
					AppendLog("Step 3: Add 20 values");
					m_Counter = 0;
					break;
			}
		}

		private void AppendLog(string p_String)
		{
			textBoxLog.AppendText(p_String);
			textBoxLog.AppendText(Environment.NewLine);
			textBoxLog.AppendText("X Min/Max of Series: " + tChart1.Series[0].MinXValue().ToString() + " / " + tChart1.Series[0].MaxXValue().ToString());
			textBoxLog.AppendText(Environment.NewLine);
			textBoxLog.AppendText("Min/Max of Bottom  : " + tChart1.Axes.Bottom.Minimum.ToString() + " / " + tChart1.Axes.Bottom.Maximum.ToString());
			textBoxLog.AppendText(Environment.NewLine);
			textBoxLog.AppendText("Count of X values  : " + tChart1.Series[0].Count.ToString());
			textBoxLog.AppendText(Environment.NewLine);
			textBoxLog.AppendText(Environment.NewLine);
		}

	}
}

Post Reply