Cartesian Custom Annotation click

8 posts, 0 answers
  1. Itamar
    Itamar avatar
    31 posts
    Member since:
    Mar 2016

    Posted 26 Dec 2016 Link to this post


    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
  2. Adrian
    Admin
    Adrian avatar
    174 posts

    Posted 29 Dec 2016 Link to this post

    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
  3. Itamar
    Itamar avatar
    31 posts
    Member since:
    Mar 2016

    Posted 29 Dec 2016 in reply to Adrian Link to this post


    Thanks for the answer 
    I need this for xamarin android 
    We work with CartesianCustomAnnotation , ContentRenderer
    Thanks
  4. Victor
    Admin
    Victor avatar
    1358 posts

    Posted 03 Jan Link to this post

    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
  5. Itamar
    Itamar avatar
    31 posts
    Member since:
    Mar 2016

    Posted 08 Mar in reply to Victor Link to this post

    How can I get the coordinates (x int, y date) when the user clicks on the charts?

  6. Deyan
    Admin
    Deyan avatar
    2147 posts

    Posted 13 Mar Link to this post

    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
  7. Itamar
    Itamar avatar
    31 posts
    Member since:
    Mar 2016

    Posted 16 Mar in reply to Deyan Link to this post

    I already tried that and it didn’t work
    I try with OnTouchListener
     And OnTouchClickListener
    Nothing works
    Can you send me working code example 
  8. Deyan
    Admin
    Deyan avatar
    2147 posts

    Posted 20 Mar Link to this post

    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
Back to Top