Contour with Custom Pallette

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Dave
Advanced
Posts: 139
Joined: Mon Sep 22, 2008 12:00 am

Post by Dave » Tue Nov 11, 2008 3:56 pm

Okay, I have a possible workaround but have one problem.

Is there a function in the contour series that takes in a horizontal position and a vertical position (either screen or value) and returns either the depth value of that point, the point itself which would contain that information or the point index which would let me get the value from the series?

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 Nov 11, 2008 5:02 pm

Hi Dave,

Yes, see Clicked method as in the MouseMove example I posted yesterday. Its return parameter (index) is later used for retrieving contour's ZValues.
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

Dave
Advanced
Posts: 139
Joined: Mon Sep 22, 2008 12:00 am

Post by Dave » Tue Nov 11, 2008 5:19 pm

When i place this code into the cursorChanged handler in my example:

Code: Select all

Point p = contour1.ValuePointToScreenPoint(mainCursor.XValue, mainCursor.YValue);

 int index = contour1.Clicked(p);

Index is always equal to minus one. I can confirm that the x and y values from the cursor are correct values form the chart, and i assume the x and y values in the point returned from contour1.ValuePointToScreenPoint are correct.

Whats going wrong?

On a side note this is where the help file needs some work. It gives no indication of what return values to expect in the case of errors or invalid input (im assuming -1 is used to indicate some form of error).

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Nov 12, 2008 11:36 am

Hi Dave,

Yes, Clicked method doesn't work very well with Contour series. It always gives 1 for ZValues and YValues doesn't coincide with contour's levels. I've added this issue to the bug list to be fixed for next releases with ID number TF02013564.
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

Dave
Advanced
Posts: 139
Joined: Mon Sep 22, 2008 12:00 am

Post by Dave » Wed Nov 12, 2008 11:39 am

Thank you, is there a planned date for the next release, or is it a "when its done" type of thing? :wink:

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Nov 12, 2008 11:46 am

Hi Dave,

We expect next maintenance release to be published in week 51 (from 15th to 21st December). I just logged this in the bug list so I'm still unable to tell you if this issue will be fixed for that release. I recommend you to be aware at this forum or subscribe to our RSS news feed for new release announcements and what's fixed on them.

Thanks in advance.
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

Dave
Advanced
Posts: 139
Joined: Mon Sep 22, 2008 12:00 am

Post by Dave » Wed Nov 12, 2008 11:53 am

Thats fine. So in the meantime is there any way to get the point index or zvalue given the x and y co-ordinates?

I.e from the cursor i can get the vertical and horizontal axis positions, and from that I can get the screen location. Given this information is there any working way to get the depth value at that point at the moment?

Does the clicked method function properly for a surface series? (im thinking that if it does i could keep a surface with the same data and plug the given x, y values into its clicked method).

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Nov 12, 2008 12:11 pm

Hi Dave,
Thats fine. So in the meantime is there any way to get the point index or zvalue given the x and y co-ordinates?

I.e from the cursor i can get the vertical and horizontal axis positions, and from that I can get the screen location. Given this information is there any working way to get the depth value at that point at the moment?
I'm afraid this is going to be difficult because Contour series levels are calculated from provided values so something like code snippet below won't work either:

Code: Select all

		void tChart1_MouseMove(object sender, MouseEventArgs e)
		{
			double xVal = tChart1.Axes.Bottom.CalcPosPoint(e.X);
			double zVal = tChart1.Axes.Left.CalcPosPoint(e.Y);

			int xIndex = contour1.XValues.IndexOf(xVal);
			int zIndex = contour1.ZValues.IndexOf(zVal);

			if ((xIndex == zIndex) && (xIndex != -1))
			{
				tChart1.Header.Text = contour1.YValues[xIndex].ToString() + ", " + contour1.ZValues[xIndex].ToString();
			}
		}
I can think of any alternative method at the moment.
Does the clicked method function properly for a surface series? (im thinking that if it does i could keep a surface with the same data and plug the given x, y values into its clicked method).
In that case I recommend you to use ColorGrid series. Clicked method for this series style works:

Code: Select all

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

		private Steema.TeeChart.Styles.Contour contour1;
		private Steema.TeeChart.Styles.ColorGrid colorGrid1;

		private void InitializeChart()
		{
			tChart1.Aspect.View3D = false;

			contour1 = new Steema.TeeChart.Styles.Contour(tChart1.Chart);
			contour1.FillSampleValues();

			colorGrid1 = new Steema.TeeChart.Styles.ColorGrid(tChart1.Chart);
			colorGrid1.DataSource = contour1;

			contour1.Active = false;

			tChart1.MouseMove += new MouseEventHandler(tChart1_MouseMove);
		}

		void tChart1_MouseMove(object sender, MouseEventArgs e)
		{
			int index = colorGrid1.Clicked(e.X, e.Y);

			if (index != -1)
			{
				tChart1.Header.Text = colorGrid1.YValues[index].ToString() + ", " + colorGrid1.ZValues[index].ToString();
			}
			else
			{
				tChart1.Header.Text = index.ToString();
			}
		}
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

Dave
Advanced
Posts: 139
Joined: Mon Sep 22, 2008 12:00 am

Post by Dave » Wed Nov 12, 2008 2:43 pm

The colourGrid method seems to work perfectly, plus my boss having seen it has decided he wantes to use it as well anyway! :lol:

Thank you very much!

Dave
Advanced
Posts: 139
Joined: Mon Sep 22, 2008 12:00 am

Post by Dave » Wed Nov 12, 2008 2:49 pm

For future reference my code goes something like this:

Code: Select all


            Point p = contour1.ValuePointToScreenPoint(mainCursor.XValue, mainCursor.YValue);

            int index = colourGrid1.Clicked(p);

            timeTB.Text = mainCursor.XValue.ToString();
            wavelenTB.Text = mainCursor.YValue.ToString();

            intensityTB.Text = contour1.YValues[index].ToString();


Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Nov 12, 2008 3:00 pm

Hi Dave,

You're welcome. I'm glad to hear that!
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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu May 07, 2009 12:10 pm

Hi Dave,

I've been revisiting TF02013564 and found that it's not a bug. Clicked method in Contour series works quite in a different manner as contour series generates its levels from values. So, using Contour's Clicked method combined with Levels' Clicked method works fine, for example:

Code: Select all

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

		private Steema.TeeChart.Styles.Contour contour1;

		private void InitializeChart()
		{
			tChart1.Aspect.View3D = false;

			contour1 = new Steema.TeeChart.Styles.Contour(tChart1.Chart);
			contour1.FillSampleValues();
			contour1.ContourMarks.Visible = true;

			tChart1.MouseMove += new MouseEventHandler(tChart1_MouseMove);
		}

		void tChart1_MouseMove(object sender, MouseEventArgs e)
		{
			int index = contour1.Clicked(e.X, e.Y);

			if (index != -1)
			{
				int segment, point;
				contour1.Levels[index].Clicked(e.X, e.Y, out segment, out point);
				tChart1.Header.Text = "Level: " + contour1.Levels[index].UpToValue.ToString() + 
															", Z: " + contour1.ZValues[point].ToString();
			}
			else
			{
				tChart1.Header.Text = index.ToString();
			}
		}
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