Is there a way to get the location of an IGDataPoint (IGCategoryPoint in my case) in the chart? I need to do so after a tap on a series line, but `chartView:tapForSeries:withItem:atPoint:` isn't really what I want. There seems to be no property on the IGDataPoint to extract its location nor a method on the chart or series to extract the location out of a data point...
Hi Rogelio,
Thank you for the reply.
What you could do in order to get the screen coordinates of a given point is to use the converToScreen method of its axes. If the axis is category axis, you should use the index of the point as parameter and if it is numeric you should use the value of the data point. This way if the series is a column series you will get the top center of the column, if it is a line - the center of the marker.
Let me know if you have any additional questions.
What about a IGCategoryDateTimeXAxis? I can't pass a date to convertToScreen:. Can't find a way to convert the date into a numeric value.
You can use the same approach with dates. You only need to convert the date to a NSTimeInterval:
Date to pixels:
NSDate *date = [NSDate date];
NSTimeInterval ticks = [date timeIntervalSince1970];
CGFloat x = [xAxis convertToScreen:ticks];
And backwards:
CGFloat x1 = 100;
NSTimeInterval ticks1 = [xAxis convertFromScreen:x1];
NSDate *date1 = [NSDate dateWithTimeIntervalSince1970:ticks1];
Couldn't get that to work:
Date: 2014-10-23 09:45:00 +0000 (item.date)Resulting time interval: 1414057500 ([item.date timeIntervalSince1970];)Resulting x coordinate: -23130822 ([series.xAxis convertToScreen:[item.date timeIntervalSince1970]];)
It appears to be a bug in the date time axis. Internally we're handling time in milliseconds, but the conversion method assumes interval in seconds.We'll be sure to fix the problem for the next service release. In the meantime, you can work around this by multiplying your time value (ticks) by 1000 before passing it to convertToScreen method.
Sorry for the inconvenience.
Any insights into why that isn't working?