This question is locked. New answers and comments are not allowed.
I created TKChartLine with TKChartLineSeries, then I want to perform some function if I tap one of the points in series I added (with point's X as parameter). How to do this?
7 Answers, 1 is accepted
0
Hello Muhammad,
You can use the chart:didSelectPoint: method from TKChartDelegate like demonstrated in this help article. Do not hesitate to write back if you need further assistance.
Regards,
Jack
Telerik
You can use the chart:didSelectPoint: method from TKChartDelegate like demonstrated in this help article. Do not hesitate to write back if you need further assistance.
Regards,
Jack
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
Muhammad
Top achievements
Rank 1
answered on 08 Jan 2015, 09:09 AM
Thanks for your reply :)
I have used that method but unfortunately the function is not called..
here is my code:
am I missing something?
I have used that method but unfortunately the function is not called..
here is my code:
#import "ViewController.h"
#import <TelerikUI/TelerikUI.h>
@interface ViewController () <TKChartDelegate>
@property (strong, nonatomic) UIScrollView *scrollView;
@property (strong, nonatomic) TKChart *chart;
@end
@implementation ViewController
- (
void
)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0.0f, self.navigationController.navigationBar.frame.size.height, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame))];
[self.scrollView setUserInteractionEnabled:YES];
[self.scrollView setBackgroundColor:[UIColor blackColor]];
[self.scrollView setContentSize:CGSizeMake(CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame) + 1000)];
[self.view addSubview:self.scrollView];
// Membuat chart
self.chart = [[TKChart alloc] initWithFrame:CGRectInset(self.view.bounds, 10, 10)];
self.chart.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.chart.delegate = self;
[self.scrollView addSubview:self.chart];
NSMutableArray *randomNumericData = [[NSMutableArray alloc] init];
TKChartDataPoint *point;
for
(
int
i = 0; i < 10; i++) {
point = [[TKChartDataPoint alloc] initWithX:@(i) Y:@(arc4random()%100)];
[randomNumericData addObject:point];
}
TKChartLineSeries *series = [[TKChartLineSeries alloc] initWithItems:randomNumericData];
[series setSelectionMode:TKChartSeriesSelectionModeDataPoint];
[series.style setPointShape:[[TKPredefinedShape alloc] initWithType:TKShapeTypeCircle andSize:CGSizeMake(18.0f, 18.0f)]];
[self.chart addSeries:series];
self.chart.title.hidden = NO;
self.chart.title.text = @
"My graphic"
;
self.chart.legend.hidden = NO;
self.chart.allowAnimations = YES;
self.chart.xAxis.allowZoom = YES;
}
- (
void
)chart:(TKChart *)chart didSelectPoint:(id<TKChartData>)point inSeries:(TKChartSeries *)series atIndex:(NSInteger)index
{
NSLog(@
"A point tapped!"
);
}
- (
void
)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
am I missing something?
0
Muhammad
Top achievements
Rank 1
answered on 08 Jan 2015, 09:58 AM
By the way, circle point's color did changed when I tapped it, but chart:didSelectPoint: method didn't called
0
Accepted
Hello Muhammad,
I tested your code with our latest official release - Q3 2014 1204. The method is being called. Please, could you confirm that you are using our latest release?
Regards,
Jack
Telerik
I tested your code with our latest official release - Q3 2014 1204. The method is being called. Please, could you confirm that you are using our latest release?
Regards,
Jack
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
Muhammad
Top achievements
Rank 1
answered on 13 Jan 2015, 12:34 PM
Hello Jack,
I updated the framework to latest release, and yeah, it worked. Thank you! :)
I updated the framework to latest release, and yeah, it worked. Thank you! :)
0
Giang
Top achievements
Rank 1
answered on 30 Mar 2015, 05:10 AM
I am trying event didSelectPoint in Swift with Telerik framework version Q1 2015 but it doesn't work. Neither this event in the solution TelerikUIExamplesInSwift. Could you double check that this event (or other similar events) works in Swift in Q1 2015. Many thanks.
0
Hi Giang,
Thank you for contacting us.
I tried to reproduce the described issue in Swift with our latest release, but I couldn't. The didSelectPoint method is called only if the selectionMode property of your series is set to TKChartSelectionMode.DataPoint like in the code snippet below:
Could you, please, confirm that the selection mode of your series is set to data point?
I am looking forward to your reply.
Regards,
Adrian
Telerik
Thank you for contacting us.
I tried to reproduce the described issue in Swift with our latest release, but I couldn't. The didSelectPoint method is called only if the selectionMode property of your series is set to TKChartSelectionMode.DataPoint like in the code snippet below:
series
.selectionMode
= TKChartSeriesSelectionMode
.DataPoint
Could you, please, confirm that the selection mode of your series is set to data point?
I am looking forward to your reply.
Regards,
Adrian
Telerik
See What's Next in App Development. Register for TelerikNEXT.