ChartsOrg / ChartsOrg/Charts

App crash when zooming in

Open
#4,028 7 comments 3 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?
Pinched to zoom in the graph

## What did you expect to happen?
The graph should zoom in

## What happened instead?
App crashed

## Charts Environment

pod 'Socket.IO-Client-Swift', '~> 13.1.0'
10.1 (10B61)
Swift 4
iOS11.2
macOS 10.13.6

## Demo Project
This is a company application, I can not send it.

## detalis:
When zooming in the graph, we get this - CODE FROM THE POD:

/// Sets up the axis values. Computes the desired number of labels between the two given extremes.

///////////////////////////////// MIN and MAX are NaN /////////////////////////////////

@objc open func computeAxisValues(min: Double, max: Double)
{
guard let axis = self.axis else { return }

let yMin = min
let yMax = max

let labelCount = axis.labelCount
let range = abs(yMax - yMin)

if labelCount == 0 || range <= 0 || range.isInfinite
{
axis.entries = [Double]()
axis.centeredEntries = [Double]()
return
}

// Find out how much spacing (in y value space) between axis values
let rawInterval = range / Double(labelCount)
var interval = rawInterval.roundedToNextSignficant()

// If granularity is enabled, then do not allow the interval to go below specified granularity.
// This is used to avoid repeated values when rounding values for display.
if axis.granularityEnabled
{
interval = interval < axis.granularity ? axis.granularity : interval
}

// Normalize interval
let intervalMagnitude = pow(10.0, Double(Int(log10(interval)))).roundedToNextSignficant() <- THE LINE WITH THE CRASH

![Screen Shot 2019-06-16 at 12 43 28](https://user-images.githubusercontent.com/8232693/59563397-300e5e00-9042-11e9-804a-f3ec37ea8384.png)
![Screen Shot 2019-06-16 at 12 42 05](https://user-images.githubusercontent.com/8232693/59563398-300e5e00-9042-11e9-8ad7-4dabb59faaf8.png)
![Screen Shot 2019-06-16 at 12 39 55](https://user-images.githubusercontent.com/8232693/59563399-300e5e00-9042-11e9-8f0d-343ee2fc0480.png)

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.