Skip to content

Conversation

RCCoop
Copy link

@RCCoop RCCoop commented Feb 22, 2023

Goals ⚽

Allow for scrolling around the chart on MacOS using two-finger trackpad scrolling, which is a more natural interaction than having to click and drag.

Implementation Details 🚧

Being new to this library, I may not be doing this the most elegant way, but I added override func scrollWheel(with:) to BarLineChartViewBase, and wrapped it with #if os(macOS). To implement the scrollWheel function, I mostly copied panGestureRecognized(_:), removing options that seemed specific to GestureRecognizer implementations, and replacing the translation and velocity calculations with NSEvent versions. The end result is that you can pan around in the view using two-finger trackpad scrolling.

Testing Details 🔍

I tested by using the ChartsDemo-macOS app in both BarDemoViewController and LineDemoViewController, each with and without dragDecelerationEnabled, to zoom and scroll. It was very simple testing, but it seemed to work.

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.

1 participant