Annotations with SChartDateTimeAxis


#1

I’m running into some issues while trying to show annotations on my graph whose x axis is a date time. The X value is always way outside of the bounds. 

In my toggledSelectionForPoint delegate method I try to map the data point X value to its pixel value for the annotation, but the output is always wrong.

double xPoint = [chart.xAxis pixelValueForDataValue:dataPoint.xValue];
double yPoint = [chart.yAxis pixelValueForDataValue:dataPoint.yValue];

NSLog(@"xValue - %@", dataPoint.xValue);
NSLog(@"xPoint = %f",xPoint);
NSLog(@"yPoint = %f",yPoint);

The value outputted is as follows:

2014-07-17 10:02:30.803 ChartTest[5882:60b] xValue - 2810275200
2014-07-17 10:02:30.804 ChartTest[5882:60b] xPoint = 1159474.000000
2014-07-17 10:02:30.804 ChartTest[5882:60b] yPoint = 40.996597

#2

I have the same issue.


#3

Hi Guys,

Could I ask what version of ShinobiControls you are using? Using version 2.7.0, I loaded up our getting started sample and set the delegate, changed the styling so I could see the individual data points, and added the following delegate method (copying the method that brianantonelli is using).

-(void)sChart:(ShinobiChart *)chart toggledSelectionForPoint:(SChartDataPoint *)dataPoint inSeries:(SChartSeries *)series atPixelCoordinate:(CGPoint)pixelPoint {
    
    double xPixel = [chart.xAxis pixelValueForDataValue:dataPoint.xValue];
    double yPixel = [chart.yAxis pixelValueForDataValue:dataPoint.yValue];
    
    NSLog(@"x: %f, y:%f", xPixel, yPixel);
}

When I click about my chart, I get values I’d expect. For example, when I pan the chart so that a datapoint is in the very top left corner of my chart and click said datapoint, I get a coordinate with an X and Y of very close to zero.

If you’re not on our latest version, I suggest updating to see whether you still experience the problem.

Regards,

Jan