Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow turning off drag in X and Y axes separately. #2413

Merged
merged 2 commits into from
Sep 7, 2017

Conversation

maciejtrybilo
Copy link
Contributor

@maciejtrybilo maciejtrybilo commented May 5, 2017

Currently if a chart is inside a scroll view and drag is enabled, the chart pan gesture recognizes all pan events and the containing scroll view doesn't work.

This PR allows enabling/disabling drag in either axis separately. Probably the most common use case would be enabling scale only in the X direction and enabling drag only in the X direction, so a vertically scrolling scroll view can work normally:

chartView.scaleYEnabled = false
chartView.scaleXEnabled = true
chartView.dragYEnabled = false

@codecov-io
Copy link

codecov-io commented May 5, 2017

Codecov Report

Merging #2413 into master will decrease coverage by 0.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2413      +/-   ##
==========================================
- Coverage   19.65%   19.64%   -0.02%     
==========================================
  Files         112      112              
  Lines       13714    13727      +13     
==========================================
  Hits         2696     2696              
- Misses      11018    11031      +13
Impacted Files Coverage Δ
Source/Charts/Charts/BarLineChartViewBase.swift 23.16% <0%> (-0.29%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3ab1ebd...629c548. Read the comment docs.

@liuxuan30 liuxuan30 requested a review from danielgindi May 8, 2017 08:43
@hernanarber
Copy link

+1 on that Request

@kashifshaikh
Copy link

+1 - I made a similar change, but your is much better!

@liuxuan30
Copy link
Member

wow I missed this.. Will try to review and merge

@@ -29,6 +29,8 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
fileprivate var _pinchZoomEnabled = false
fileprivate var _doubleTapToZoomEnabled = true
fileprivate var _dragEnabled = true
fileprivate var _dragYEnabled = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we change to false by default? Ideally this should be set by user explicitly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dragEnabled is true by default. Having dragYEnabled false by default would change the current default behaviour.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, my bad. Lots of || and !..

@liuxuan30 liuxuan30 merged commit 19750f7 into ChartsOrg:master Sep 7, 2017
@maciejtrybilo maciejtrybilo deleted the dragXYEnabled branch September 7, 2017 09:10
@danielgindi
Copy link
Collaborator

Seems like you are disabling the beginning of the drag gesture if it's in the wrong direction,
but then changing directions in the middle of a gesture is allowed... Am I missing something?

danielgindi added a commit that referenced this pull request Sep 8, 2017
@maciejtrybilo
Copy link
Contributor Author

I've only tested it when the chart is in a scroll view itself, so this didn't come up. Thanks!

@liuxuan30
Copy link
Member

@danielgindi you are back 😃

@danielgindi
Copy link
Collaborator

Hey I'm always here, watching over you ;-)
Since I have a sweet little daughter, my time distribution is different.
Now she entered a little kindergarden so I can login sometimes at nights and do some maintenance and improvements.
By the way - you and @petester42 are doing such a great job. It's great that you're taking care of this when I can't!

@liuxuan30
Copy link
Member

Thanks! Hope your daughter sleep well. My 8-month boy would wake up several times in the evening, kind of killing me.. haha
still, some feature PRs need you help, especially when thinking about android. We are able to help review and merge some:)

PeterSrost pushed a commit to sokol8/Charts that referenced this pull request Oct 31, 2018
Allow turning off drag in X and Y axes separately.
PeterSrost pushed a commit to sokol8/Charts that referenced this pull request Oct 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants