TKChart in a UIScrollview can't scroll

11 posts, 0 answers
  1. Zhang
    Zhang avatar
    4 posts
    Member since:
    Aug 2014

    Posted 18 Aug 2014 Link to this post

    I added a TKChart to a scrollview then I found out I have to drag the area outside the chart to scroll the screen. What should I do ?
  2. Adrian
    Admin
    Adrian avatar
    167 posts

    Posted 18 Aug 2014 Link to this post

    Hello Zhang,

    Thank you for using our controls.

    TKChart inherits from UIView, so you can use its userInteractionEnabled property to ignore or process user interactions to the chart. You should set this property to NO, and the touch event will be handled by the scroll view. Please consider the code snippet below:
    chart.userInteractionEnabled = NO;

    I hope this helps. Do not hesitate to contact us if you need further assistance.

    Regards,
    Adrian
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. DevCraft banner
  4. Zhang
    Zhang avatar
    4 posts
    Member since:
    Aug 2014

    Posted 18 Aug 2014 in reply to Adrian Link to this post

    Yes, that's right. 
  5. Zhang
    Zhang avatar
    4 posts
    Member since:
    Aug 2014

    Posted 18 Aug 2014 in reply to Adrian Link to this post

    Is there a win win option that allowing user to have interaction with chart in a scrollview ?
  6. Adrian
    Admin
    Adrian avatar
    167 posts

    Posted 18 Aug 2014 Link to this post

    Hi Zhang,

    Currently it is not possible to disable specific user interactions in TKChart. We plan to add this functionality in one of our future versions. The issue is logged in our feedback portal and you can use the following link to track the issues status..

    You can work around the issue by using a tap gesture recognizer. You still should set the userInteractionEnabled property to NO, so that the scroll view can handle touch events. Then you should add UITapGestureRecognizer to TKChart's parent view which will handle the tap for the selection. Consider the code snippet below:
    - (void)viewDidLoad
    {
        //...
         
        [scrollView addSubview:_chart];
         
        //...
        UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)];
        [scrollView addGestureRecognizer:tapRecognizer];
    }
     
    - (void)tap:(UITapGestureRecognizer *)gestureRecognizer
    {
        CGPoint touchPoint = [gestureRecognizer locationInView:_chart.plotView];
        TKChartSelectionInfo *hitTestInfo = [_chart hitTestForPoint:touchPoint];
        [_chart select:hitTestInfo];
    }

    You should also allow selection by setting the series selectionMode property to the desired value: 
    series.selectionMode = TKChartSeriesSelectionModeSeries;

    If you need further assistance I will be glad to help.

    Regards,
    Adrian
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  7. Zhang
    Zhang avatar
    4 posts
    Member since:
    Aug 2014

    Posted 18 Aug 2014 in reply to Adrian Link to this post

    Thanks, it works very well!! And I found out if I TKChartSeriesSelectionModeSeries only allows me to select the whole series, but TKChartSeriesSelectionModeDataPoint is able to select individual column.

    series.selectionMode = TKChartSeriesSelectionModeDataPoint;
  8. Adrian
    Admin
    Adrian avatar
    167 posts

    Posted 19 Aug 2014 Link to this post

    Hi Zhang,

    I am glad to hear that I could be of help.

    I will be happy to assist you if you have further questions.

    Regards,
    Adrian
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  9. Zachary
    Zachary avatar
    3 posts
    Member since:
    Apr 2016

    Posted 15 Apr Link to this post

    Hello Adrian,

     

    I have been following the issue status using the link you provided. It says that the functionality was completed in October of 2015, but I can't seem to find the documentation for it. Can you point me in the right direction?

     

    To clarify exactly what I am looking to accomplish with this functionality:

    Issue: I have a TKChart inside of a UITableViewCell (and therefore, a UIScrollView as the parent of the UITableView that contains the cell). When I scroll the UITableView, everything works fine unless I a touch within the TKChart, in which case I cannot scroll the UITableView as usual. 

    Solution: Ideally, I can disable specific user interactions that are disallowing the touch to pass through to the UITableView's scrollView, and thereby scroll as usual.

    Thanks for your help.

    Zach

     

  10. Adrian
    Admin
    Adrian avatar
    167 posts

    Posted 20 Apr Link to this post

    Hello, Zachary,

    Please find my response in the other support thread.

    Regards,
    Adrian
    Telerik
    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
  11. Zachary
    Zachary avatar
    3 posts
    Member since:
    Apr 2016

    Posted 20 Apr Link to this post

    Hello Adrian,

     

    Can you post the link to your other support thread.

     

    And on that note -- I've noticed that the links I included in my note have been stripped out of the post. How do you suggest I share these with you going forward?

     

    Thank you,

    Zach

  12. Zachary
    Zachary avatar
    3 posts
    Member since:
    Apr 2016

    Posted 20 Apr in reply to Zachary Link to this post

    Ah, I just saw the ticket response. I will review and get back to you. Thank you Adrian.

     

    Zach

Back to Top
DevCraft banner