Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix for fix #1488, #1564 #1565

Merged
merged 2 commits into from
Sep 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/Charts/Components/AxisBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ open class AxisBase: ComponentBase
/// This is useful especially for grouped BarChart.
open var centerAxisLabelsEnabled: Bool
{
get { return _centerAxisLabelsEnabled && entryCount > 1 }
get { return _centerAxisLabelsEnabled && entryCount > 0 }
set { _centerAxisLabelsEnabled = newValue }
}

Expand Down
15 changes: 5 additions & 10 deletions Source/Charts/Renderers/AxisRendererBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,8 @@ open class AxisRendererBase: Renderer
// Use one order of magnitude higher, to avoid intervals like 0.9 or 90
interval = floor(10.0 * Double(intervalMagnitude))
}

let centeringEnabled = axis.centerAxisLabelsEnabled
var n = centeringEnabled ? 1 : 0

var n = 1

// force label count
if axis.isForceLabelsEnabled
Expand All @@ -158,7 +157,7 @@ open class AxisRendererBase: Renderer

var first = interval == 0.0 ? 0.0 : ceil(yMin / interval) * interval

if centeringEnabled
if axis.centerAxisLabelsEnabled
{
first -= interval
}
Expand Down Expand Up @@ -204,16 +203,12 @@ open class AxisRendererBase: Renderer
axis.decimals = 0
}

if centeringEnabled
if axis.centerAxisLabelsEnabled
{
axis.centeredEntries.reserveCapacity(n)
axis.centeredEntries.removeAll()

var offset: Double = 0.0
if axis.entries.count > 1
{
offset = (axis.entries[1] - axis.entries[0]) / 2.0
}
let offset: Double = interval / 2.0

for i in 0 ..< n
{
Expand Down