Change tracking series for tooltip with panning finger


#1

Is it possible to set the tracking of a serie to allow it to jump more freely between different graphs, without lifting the panning finger? Simply based on whatever graph is closest to the touch point of the finger.

Lift, tap-and-hold/wait just to change series does seem a bit tedious in some cases (in my case for three min-average-max graphs that never overlap).


#2

Hey Duemunk!

This is certainly possible - we thought of this when designing the crosshair - if you create a crosshair subclass like so:

@interface JumpingCrosshair : SChartCrosshair
@end

@implementation JumpingCrosshair
- (SChartCartesianSeries *)trackingSeries
{
    return nil;
}
@end

Then the crosshair will report no tracking series as it moves. This means it may jump a little unpredictably for series with points close together, but in your case, with non-overlapping series, it should work a charm! You’ll want to assign an instance of this to chart.crosshair in your chart setup code.

Let me know if you have any trouble getting it working.

Regards,

Rob


#3

It works as expected. It should be restated that is makes the tracking less predictable/sticky - even for if chart only contains one graph. 

If you want to toggle the behavior I found this solution (it simply falls back to the super class callback):

- (SChartCartesianSeries *)trackingSeries
{
if (_allowJumpingBetweenSeries)
    return nil;
else
    return [supertrackingSeries];
}

#4

I found out that this solution comes with a cost. The minute the chart is pinched to zoom, the crosshair is floating, and not sticking to the current (fake) tracking serie. This makes the solution a no-go, unless zoom interaction with the chart is disabled.

Kind of a pity, since the functionality to quickly change tracking serie while panning is really handy.

I tried using more subclass function for the crosshair, but one only gets calls on pan/pinch start. If calls for start and end was available, one might be able to grab trackingSeries from the super class, and use it temporarily. But I found this solution to work ok - for now at least.

- (SChartCartesianSeries *)trackingSeries {
	if (_allowJumpingBetweenSeries && ! temporarilyDisableJumpingBetweenSeries)
		return nil;
	else
		return [super trackingSeries];
}

- (void)crosshairChartGotPinchAndPan {
	temporarilyDisableJumpingBetweenSeries = YES;
}

- (void)showCrosshair {
	[super showCrosshair];
	
	temporarilyDisableJumpingBetweenSeries = NO;
}