Skip to content

Commit

Permalink
Take care of edge cases when calculating intervals (labelCount == 0)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Aug 15, 2016
1 parent 3b459cc commit d7769e6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion Charts/Classes/Renderers/AxisRendererBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ public class AxisRendererBase: Renderer
}

// Find out how much spacing (in y value space) between axis values
let rawInterval = range / Double(labelCount)
var rawInterval = range / Double(labelCount)
if isinf(rawInterval)
{
rawInterval = range > 0.0 && !isinf(range) ? range : 1.0
}
var interval = ChartUtils.roundToNextSignificant(number: Double(rawInterval))

// If granularity is enabled, then do not allow the interval to go below specified granularity.
Expand Down
6 changes: 5 additions & 1 deletion Charts/Classes/Renderers/YAxisRendererRadarChart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ public class YAxisRendererRadarChart: YAxisRenderer
}

// Find out how much spacing (in yValue space) between axis values
let rawInterval = range / Double(labelCount)
var rawInterval = range / Double(labelCount)
if isinf(rawInterval)
{
rawInterval = range > 0.0 && !isinf(range) ? range : 1.0
}
var interval = ChartUtils.roundToNextSignificant(number: Double(rawInterval))

// If granularity is enabled, then do not allow the interval to go below specified granularity.
Expand Down

0 comments on commit d7769e6

Please sign in to comment.