ChartsOrg / ChartsOrg/Charts

Setting maximum zoom scale causes a scroll problem on reaching maximum zoom scale

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

Description

## What did you do?

I set my chart's maximum zoom scale to a value by using:
```swift
barChartView.viewPortHandler.setMaximumScaleX(100.0)
```

## What did you expect to happen?

I expected my chart to be zoomed to 100x scale without problems.

## What happened instead?

My chart can be scrolled to 100x scale. But when you reach this zoom level, chart offset slightly changes and user loses their zoom position. Check the attached video.

## Charts Environment

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

## Demo Video
[Demo Video Link](https://gfycat.com/clearterrificelephantseal)

## Demo Code
```swift
import UIKit
import Charts

class ViewController: UIViewController {

@IBOutlet weak var barChartView: BarChartView!
override func viewDidLoad() {
super.viewDidLoad()

//Set Chart.
var dataSets: [BarChartDataSet] = []

for i in 1...5{
let entry = BarChartDataEntry(x: Double(i * 10), y: 10.0)
let dataSet = BarChartDataSet(values: [entry], label: String(i))
dataSets.append(dataSet)
}

barChartView.data = BarChartData(dataSets: dataSets)
barChartView.viewPortHandler.setMaximumScaleX(100.0)
}
}
```

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.