SwiftChart icon indicating copy to clipboard operation
SwiftChart copied to clipboard

Not triggering didFinishTouchingChart()

Open kevinlieser opened this issue 9 years ago • 12 comments

After Touching the Chart and lift my finger the function didFinishTouchingChart() does not get fired. Is that right? I thought this method get fired after i'm finished touching the chart.

kevinlieser avatar Mar 01 '16 11:03 kevinlieser

Hi @kevinlieser,

nope: the user will "finish" touching the chart only swiping left/right outside the chart. I honestly don't remember why I needed it working this way :sweat_smile:

gpbl avatar Mar 01 '16 11:03 gpbl

Thanks @gpbl, Don't understand that. Why is the Method called like this? It should be called "didSwipeOutOfChart()" ;-) Okay, then i have to search another way to get the "touchUp" event. Any suggestions?

Anyway, thanks for this nice Library!

kevinlieser avatar Mar 01 '16 12:03 kevinlieser

You are right, the name is wrong :smile: It shouldn't be hard to implement a didEndTouchingChart, let me try first.

gpbl avatar Mar 01 '16 12:03 gpbl

Just replaced this in Chart.swift Line 721

override public func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) { handleTouchEvents(touches, event: event) }

with

override public func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) { handleTouchEvents(touches, event: event) drawHighlightLineFromLeftPosition(-1) delegate?.didFinishTouchingChart(self) }

In my optionion it does not matter wether the user swipes out left/right or lift the finger. ;-) BTW: The last Chart point is not touchable (or really really bad) when using Chart without margins to left/right.

kevinlieser avatar Mar 01 '16 12:03 kevinlieser

Great thanks! I won't change however the behavior of that method for backward compatibility, so I'd prefer to add a new delegate method.

gpbl avatar Mar 01 '16 12:03 gpbl

Yes, that would be nice and clean :-) I've edited my solution - forgot the drawHighlightLineFromLeftPosition(-1) to remove the line

kevinlieser avatar Mar 01 '16 12:03 kevinlieser

Removing the highlight line may be a undesired behavior. Say, for example, the user wants to display something related to the highlighted value: removing the highlight line would hide the reference to the selected value. I think it would be better to add a removeHighlightLine method, or something like that.

gpbl avatar Mar 01 '16 12:03 gpbl

Yes, for sure. But for my project this small workaround (untill you have an update) works ;-) On FingerUp all selected data get hidden and the "overall" data gets shown. Thats why i remove the line on TouchUp.

kevinlieser avatar Mar 01 '16 12:03 kevinlieser

Short question - is there a way to round the Chart lines (like a wave instead of sharp edges)? Sorry for Offtopic and thanks!

kevinlieser avatar Mar 01 '16 20:03 kevinlieser

Nope, not yet!

gpbl avatar Mar 01 '16 20:03 gpbl

+1 for an ability to trigger didFinishTouchingChart whenever touchesEnd

bensaufley avatar Jul 10 '16 18:07 bensaufley

@gpbl @bensaufley @kevinlieser Hi all,

I've submitted a pull request to fix this issue. Please see #62

rickvdl avatar Apr 11 '17 07:04 rickvdl