Individual Points marked by a square and clickable

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Lars Iversen
Newbie
Newbie
Posts: 61
Joined: Wed Jun 22, 2005 4:00 am
Location: cph

Individual Points marked by a square and clickable

Post by Lars Iversen » Thu Mar 09, 2006 2:10 pm

Hi

I have a line series with about 1000 points.
I would like to have some of the points have a visible mark e.g. a square and then be able to click these points and act on the event. But I do not want the rest of the points to be marked and clickable.

Is that possible? How?

Thanks in advance
Lars Iversen

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 Mar 09, 2006 3:02 pm

Hi Lars,

Yes, this is possible. You need to do like this:

Code: Select all

		private void Form1_Load(object sender, System.EventArgs e)
		{
			line1.FillSampleValues();
			line1.Pointer.Visible=true;
		}

		private void line1_GetPointerStyle(Steema.TeeChart.Styles.CustomPoint series, Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventArgs e)
		{
			if ((series.YValues[e.ValueIndex]%2)==0)
				e.Style=Steema.TeeChart.Styles.PointerStyles.Rectangle;
			else 
				e.Style=Steema.TeeChart.Styles.PointerStyles.Nothing;
		}

		private void line1_ClickPointer(Steema.TeeChart.Styles.CustomPoint series, int valueIndex, int x, int y)
		{
			tChart1.Header.Text="Point "+valueIndex.ToString()+" clicked";
		}

    private void line1_Click(object sender, MouseEventArgs e)
    {
      //Trick to force ClickPointer event being raised  
    }
Please notice that you need to associate a series click event as well. This is because we detected that ClickPointer event is wrongly implemented and thus it wouldn't be raised. Now we are trying to implement a solution for future releases but, in the meantime, this trick is necessary.
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

Lars Iversen
Newbie
Newbie
Posts: 61
Joined: Wed Jun 22, 2005 4:00 am
Location: cph

Post by Lars Iversen » Sun Mar 12, 2006 8:57 pm

Hi Narcís

Thanks that helps a lot.
But the unmarked points are still clickable and the click event gets fired. Is there a way to avoid that or do I have to keep track of which point-indexes I should react to clicks on?

Thanks
Lars

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 Mar 13, 2006 11:49 am

Hi Lars,

The event is raised because the pointer is also visible for those points but set to Nothing. However, you can ignore them by using something like this:

Code: Select all

		private void Form1_Load(object sender, System.EventArgs e)
		{
			line1.FillSampleValues();
			line1.Pointer.Visible=true;
		}

		private void line1_GetPointerStyle(Steema.TeeChart.Styles.CustomPoint series, Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventArgs e)
		{
      if (Screenpoints(e.ValueIndex))
				e.Style=Steema.TeeChart.Styles.PointerStyles.Rectangle;
			else 
				e.Style=Steema.TeeChart.Styles.PointerStyles.Nothing;
		}

    private bool Screenpoints(int index)
    {
      return line1.YValues[index] % 2 == 0;
    }

		private void line1_ClickPointer(Steema.TeeChart.Styles.CustomPoint series, int valueIndex, int x, int y)
		{
      if (Screenpoints(valueIndex))
        tChart1.Header.Text = "Point " + valueIndex.ToString() + " clicked";
		}

    private void line1_Click(object sender, MouseEventArgs e)
    {
      //Trick to force ClickPointer event being raised  
    }
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

Lars Iversen
Newbie
Newbie
Posts: 61
Joined: Wed Jun 22, 2005 4:00 am
Location: cph

Post by Lars Iversen » Mon Mar 13, 2006 7:10 pm

Hi Narcís

But all thiss assumes that it is for the points with the value 0 that I want to be clickable. But that is not the case.
In my head it is like this:

I have many points.
Some of the points has a text-label others do not.
The points with the text label has to be clickable the rest may not be clickable.
Is it not possible to get like a "point-object" from a series and work on properties like label, yvalue, xvalue, pointerstyle etc and then when that point is clicked ask if it has a square mark as pointerstyle and work from there?
(Maybe this is real newbie question)

Thanks
Lars Iversen

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 14, 2006 12:42 pm

Hi Lars,

Screenpoints is true when the indexed point Y value is a multiple of 2. That's just an easy sample condition I used to make an example which you can change for something like this:

Code: Select all

    private bool Screenpoints(int index)
    {
      return line1[index].Label!="";
    }
to check wether a point has a text label or not. The "point-object" class you can use is Steema.TeeChart.Styles.SeriesXYPoint which is what is used in the example above when doing line1[index].
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

Lars Iversen
Newbie
Newbie
Posts: 61
Joined: Wed Jun 22, 2005 4:00 am
Location: cph

Post by Lars Iversen » Tue Mar 14, 2006 1:09 pm

Ok. Thanks.

...and once again thatnks for answering so fast.

Br
Lars

Post Reply