This is a migrated thread and some comments may be shown as answers.
Cartesian Custom Annotation click
7 Answers 20 Views
This is a migrated thread and some comments may be shown as answers.
Itamar
Top achievements
Rank 1
Itamar asked on 26 Dec 2016, 01:42 PM

Hello 
We using Cartesian Custom Annotation to draw icon on the horizontal Axis (date time category) 
We need to know when the user click on this annotation
How can we implement this?
Thanks

7 Answers, 1 is accepted

Sort by
0
Adrian
Telerik team
answered on 29 Dec 2016, 12:01 PM
Hello Itamar,

The easiest way to achieve this is using a TKChartViewAnnotation. You can draw your icon to a view and attach a tap recognizer to it and then create a view annotation with the icon view. Here is a sample code snippet:
public override void ViewDidLoad ()
{
    base.ViewDidLoad ();
 
    //...
 
 
    UIView icon = new UIView(new CGRect(0, 0, 50, 50));
    icon.BackgroundColor = UIColor.Red;
 
    UITapGestureRecognizer tapRecognizer = new UITapGestureRecognizer(this, new ObjCRuntime.Selector("DidTapIcon"));
    icon.AddGestureRecognizer(tapRecognizer);
    chart.AddAnnotation (new TKChartViewAnnotation(icon, new NSNumber(550), new NSNumber(90), chart.Series[0]));           
}
 
[Export ("DidTapIcon")]
public void DidTapIcon()
{
    Console.WriteLine("Tapped");
}


I hope this helps.

Regards,
Adrian
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Itamar
Top achievements
Rank 1
answered on 29 Dec 2016, 12:11 PM

Thanks for the answer 
I need this for xamarin android 
We work with CartesianCustomAnnotation , ContentRenderer
Thanks
0
Victor
Telerik team
answered on 03 Jan 2017, 11:39 AM
Hi Itamar,

Thank you for writing.
I confirm that this is a bug on our side and we are aware of it.
For now the workaround is to set the old zoom and pan after your annotation is added.

Regards,
Victor
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Itamar
Top achievements
Rank 1
answered on 08 Mar 2017, 09:29 PM
How can I get the coordinates (x int, y date) when the user clicks on the charts?

0
Deyan
Telerik team
answered on 13 Mar 2017, 07:52 AM
Hi,

This might help:

http://stackoverflow.com/questions/1967039/onclicklistener-x-y-location-of-event

Although its written in Java, the C# code will not be much different.

Regards,
Deyan
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Itamar
Top achievements
Rank 1
answered on 16 Mar 2017, 09:59 AM
I already tried that and it didn’t work
I try with OnTouchListener
 And OnTouchClickListener
Nothing works
Can you send me working code example 
0
Deyan
Telerik team
answered on 20 Mar 2017, 12:57 PM
Hello Itamar,

Thanks for writing back.

Can you please send me the full source you are using to reproduce the behavior as I am not able to on my side? Setting a touch listener on my chart allows me to receive touch events and handle them (this should be working with Xamarin.Android in pretty much the same way.): 

cartesianChart.setOnTouchListener(new View.OnTouchListener() {
           @Override
           public boolean onTouch(View v, MotionEvent event) {
               if (v != null){
                   if (event.getAction() == MotionEvent.ACTION_UP) {
                       float xCoord = event.getX();
                       float yCoord = event.getY();
 
                   }
 
               }
               return false;
           }
       });


Do you have any behaviors that consume touch events on the chart enabled - like PanAndZoom for example?

Thanks.

Regards,
Deyan
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Chart
Asked by
Itamar
Top achievements
Rank 1
Answers by
Adrian
Telerik team
Itamar
Top achievements
Rank 1
Victor
Telerik team
Deyan
Telerik team
Share this question
or