Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
When `floor(10.0 * intervalMagnitude)` is 0.0, we use the old value to avoid crash at `axis.decimals = Int(ceil(-log10(interval)))`
  • Loading branch information
liuxuan30 authored and Konstantin Zyrianov committed Feb 20, 2018
1 parent fe16641 commit c6fc998
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Source/Charts/Renderers/AxisRendererBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ open class AxisRendererBase: Renderer
if intervalSigDigit > 5
{
// Use one order of magnitude higher, to avoid intervals like 0.9 or 90
interval = floor(10.0 * Double(intervalMagnitude))
// if it's 0.0 after floor(), we use the old value
interval = floor(10.0 * intervalMagnitude) == 0.0 ? interval : floor(10.0 * intervalMagnitude)
}

var n = axis.centerAxisLabelsEnabled ? 1 : 0
Expand Down
6 changes: 3 additions & 3 deletions Source/Charts/Renderers/YAxisRendererRadarChart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ open class YAxisRendererRadarChart: YAxisRenderer

if intervalSigDigit > 5
{
// Use one order of magnitude higher, to avoid intervals like 0.9 or
// 90
interval = floor(10 * intervalMagnitude)
// Use one order of magnitude higher, to avoid intervals like 0.9 or 90
// if it's 0.0 after floor(), we use the old value
interval = floor(10.0 * intervalMagnitude) == 0.0 ? interval : floor(10.0 * intervalMagnitude)
}

let centeringEnabled = axis.isCenterAxisLabelsEnabled
Expand Down

0 comments on commit c6fc998

Please sign in to comment.