6 Answers, 1 is accepted
It would still be great to have a method to do this for you, or at least the ability to inset the plotView inside the TKChart frame, but I was able to hack together a solution.
-(void)edgeSwipe:(UIScreenEdgePanGestureRecognizer*)swipe
{
TKChartSeries *series = self.chartView.series.firstObject;
TKChartSelectionInfo *selection;
TKChartDataPoint *tkpoint = [series visiblePoints].lastObject;
TKChartSeriesRender *render = [[TKChartSeriesRender alloc]init];
render.bounds = self.chartView.plotView.bounds;
CGPoint truePoint = [render locationOfPoint:tkpoint inSeries:series];
switch (swipe.state) {
case UIGestureRecognizerStateBegan:{
[self hideAnnotation];
selection = [[TKChartSelectionInfo alloc]initWithSeries:series dataPointIndex:self.plotDataItems.count-1];
break;
}
case UIGestureRecognizerStateChanged:{
CGPoint point = [swipe locationInView:self.chartView.plotView];
for (int i = self.plotDataItems.count-1; i > 1; --i) {
float xLoc = [render locationOfXNumericValue:i+1 inSeries:series];
float xLocBack = [render locationOfXNumericValue:i inSeries:series];
if (point.x > xLoc || fabsf(point.x - xLoc) < fabsf(point.x - xLocBack)){
tkpoint = [series visiblePoints][i];
break;
}else if (point.x > xLocBack){
tkpoint = [series visiblePoints][i-1];
break;
}
}
truePoint = [render locationOfPoint:tkpoint inSeries:series];
selection = [self.chartView.plotView hitTestForPoint:truePoint];
break;
}
case UIGestureRecognizerStateEnded:
[self showAnnotation];
break;
default:
break;
}
if (selection) {
[self.chartView.trackball showAtPoint:truePoint];
[self chart:self.chartView trackballDidTrackSelection:@[selection]];
}
}
I am glad to hear that you have came up with a solution.
Since you are interested in plot view insets, you can use the plotViewInsets property for this purpose.
In case you have any other questions or concerns, do not hesitate to contact us.
Regards,
Sophi
Telerik
The appearance of the trackball on the edges of the chart is expected behavior. This is how the chart is meant to be implemented in order to achieve better visual look.
TKChart does not provide setup, for showing the full trackball on the edges of the chart, at this point of time.
Regards,
Sophi
Telerik
Thank you for your feedback and reference.
We will consider including similar feature in the TKChart.
Regards,
Sophi
Telerik