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

Always display vertical scrolling indicator on horizontal bar chart #1987

Closed
Carielle opened this issue Dec 20, 2016 · 2 comments
Closed

Always display vertical scrolling indicator on horizontal bar chart #1987

Carielle opened this issue Dec 20, 2016 · 2 comments

Comments

@Carielle
Copy link

I have a horizontal bar chart that scrolls vertically so I can display many bars at a reasonable width. However, depending on the number of bars in the chart, it isn't obvious that the chart scrolls vertically, and I'm worried that my users will think that some of their data is missing because they don't realize the chart scrolls vertically. Is there a way I can force a vertical scrolling indicator to always be displayed in the chart, so it is clear to my users that the chart scrolls?

@liuxuan30
Copy link
Member

The scrolling feature is based on CoreGraphics, not UIScrollView, so there is no indicators at all if I were correct.
By default, bar chart will show all data entries, and when user zooms in, it can scroll then. If you zooms in by code in the first place, you might want to add some hint for your users, or something indicates it can scroll.

@KovtunOleg
Copy link

I know it is late answer, but I just faced the same problem, so I implemented my own scroll horizontal scroll indicator using chart delegate method:

chart.delegate = self

extension MyChartView: ChartViewDelegate {
    private func showScrollIndicator(_ show: Bool) {
        UIView.animate(withDuration: 0.3, delay: show ? 0 : 3, animations: {
            self.scrollIndicator.alpha = show ? 1.0 : 0.0
        }, completion: { _ in
            self.scrollIndicator.isHidden = !show
        })
        if show {
            showScrollIndicator(false)
        }
    }

    func chartTranslated(_ chartView: ChartViewBase, dX: CGFloat, dY: CGFloat) {
        let maxTransX = (viewPortHandler.scaleX - 1) * viewPortHandler.contentWidth
        let maxOffsetX = chartView.frame.width - scrollIndicator.frame.width
        scrollIndicatorLeadingConstraint.constant = (-viewPortHandler.transX / maxTransX) * maxOffsetX
        showScrollIndicator(true)
    }
}

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

No branches or pull requests

3 participants