ChartsOrg / ChartsOrg/Charts

moveViewToX doesn't work on HorizontalBarChart

Open
#3,909 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
28k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

* [x ] I've read, understood, and done my best to follow the [*CONTRIBUTING guidelines](https://github.com/jjatie/Charts/blob/master/CONTRIBUTING.md).

## What did you do?

I have a horizontal bar chart with values in it, I want to show the top values of the bar chart so the labels don't overlap and the user can scroll it to see more. I can set the visibleXRangeMaximum to fix the overlap, but I cannot for the life of me get it to scroll to the top. If I set `.axisMinimum` it will lock in properly, but then I cannot scroll the chart. Here are the lines I put in the `ChartsDemo-iOS-Swift` project's `HorizontalBarChartViewController` to reproduce the problem. Note that I've also tried doing `dataSet.count - 1` in place of `chartView.chartXMax` which produces the same problem.

```swift
chartView.setVisibleXRangeMaximum(100)
chartView.moveViewToX(chartView.chartXMax)
```

## What did you expect to happen?
Horizontal bar chart should move to the top of the chart with a maximum window of 100.
## What happened instead?
Horizontal bar chart does apply visible x-range maximum but does not move to the top of the chart. It stays at the bottom with the correct x-range max set.
## Charts Environment

**Charts version/Branch/Commit Number:** 3.2.2
**Xcode version:** 10.1
**Swift version:** 4.2
**Platform(s) running Charts:** iOS
**macOS version running Xcode:** 12.14.1

## Demo Project

Use the Horizontal Bar Chart in the `ChartsDemo-iOS-Swift` demo project and throw the two lines of code above at the end of `updateChartData()` to reproduce. If you don't see it, I can fork, just let me know.

If I'm not being clear, let me know and I'm happy to answer any questions. If you've got a workaround or I'm doing something wrong, please let me know. Thanks in advance. :)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.