This is a migrated thread and some comments may be shown as answers.

TKChart in a UIScrollview can't scroll

10 Answers 114 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Zhang
Top achievements
Rank 1
Zhang asked on 18 Aug 2014, 07:27 AM
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 ?

10 Answers, 1 is accepted

Sort by
0
Adrian
Telerik team
answered on 18 Aug 2014, 07:49 AM
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.

 
0
Zhang
Top achievements
Rank 1
answered on 18 Aug 2014, 08:02 AM
Yes, that's right. 
0
Zhang
Top achievements
Rank 1
answered on 18 Aug 2014, 08:06 AM
Is there a win win option that allowing user to have interaction with chart in a scrollview ?
0
Adrian
Telerik team
answered on 18 Aug 2014, 02:19 PM
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.

 
0
Zhang
Top achievements
Rank 1
answered on 19 Aug 2014, 12:50 AM
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;
0
Adrian
Telerik team
answered on 19 Aug 2014, 07:56 AM
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.

 
0
Zachary
Top achievements
Rank 1
answered on 15 Apr 2016, 06:03 PM

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

 

0
Adrian
Telerik team
answered on 20 Apr 2016, 01:08 PM
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
0
Zachary
Top achievements
Rank 1
answered on 20 Apr 2016, 02:01 PM

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

0
Zachary
Top achievements
Rank 1
answered on 20 Apr 2016, 02:03 PM

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

 

Zach

Tags
Chart
Asked by
Zhang
Top achievements
Rank 1
Answers by
Adrian
Telerik team
Zhang
Top achievements
Rank 1
Zachary
Top achievements
Rank 1
Share this question
or