1

I am trying to programatically show the crosshair and tooltip for the last datapoint in a chart after it loads. The below code is what I have so far. The crosshair shows in the right place, but the tooltip shows up way to the left and is too small to fit the text.

int num = [self.activeTrendsResult sChart:self.activeChart numberOfDataPointsForSeriesAtIndex:0];
id<SChartData>data = [self.activeTrendsResult sChart:self.activeChart dataPointAtIndex:num-1 forSeriesAtIndex:0];
double x = [[data sChartXValue] doubleValue];
double y = [[data sChartYValue] doubleValue];
SChartPoint p;
p.x = x;
p.y = y;

[self.activeChart.crosshair moveToFloatingPosition:p onXAxis:self.activeChart.xAxis onYAxis:self.activeChart.yAxis];
[self.activeChart.crosshair.tooltip setResolvedDataPoint:p fromSeries:self.activeChart.series[0] fromChart:self.activeChart];
[self.activeChart.crosshair.tooltip setPosition:self.activeChart.crosshair.trackingPoint onCanvas:self.activeChart.canvas];

Any help would be much appreciated.

nickbona
  • 1,374
  • 1
  • 11
  • 23

1 Answers1

0

To do this I used:

[self.chartView.crosshair showAtPoint:point inChart:self.chartView];

Where point from extracted from the Gesture recogniser using:

CGPoint point = [sender locationInView:self.chartView];
Ants
  • 1,338
  • 16
  • 27