Skip to content

Commit

Permalink
fix radar chart negative value rendering bug if startAtZeroEnabled is…
Browse files Browse the repository at this point in the history
… false for issue ChartsOrg#166
  • Loading branch information
liuxuan30 committed Aug 12, 2015
1 parent 78e5df8 commit f76aae9
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Charts/Classes/Renderers/ChartYAxisRendererRadarChart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,17 @@ public class ChartYAxisRendererRadarChart: ChartYAxisRenderer
}
else
{
var first = ceil(Double(yMin) / interval) * interval
var rawValue = Double(yMin) / interval
var first: Double;
// if raw value negative, we need to use floor rather than ceil
if (rawValue < 0)
{
first = floor(rawValue) * interval
}
else
{
first = ceil(Double(yMin) / interval) * interval
}

if (first == 0.0)
{ // Fix for IEEE negative zero case (Where value == -0.0, and 0.0 == -0.0)
Expand Down Expand Up @@ -132,6 +142,8 @@ public class ChartYAxisRendererRadarChart: ChartYAxisRenderer
}

_yAxis.axisMaximum = _yAxis.entries[_yAxis.entryCount - 1]
// set axisMinimum to be the minimum value.
_yAxis.axisMinimum = _yAxis.entries[0]
_yAxis.axisRange = abs(_yAxis.axisMaximum - _yAxis.axisMinimum)
}

Expand Down

0 comments on commit f76aae9

Please sign in to comment.