diff --git a/Source/Charts/Components/AxisBase.swift b/Source/Charts/Components/AxisBase.swift index 55276007ec..638d735aa5 100644 --- a/Source/Charts/Components/AxisBase.swift +++ b/Source/Charts/Components/AxisBase.swift @@ -213,6 +213,16 @@ open class AxisBase: ComponentBase /// the total range of values this axis covers @objc open var axisRange = Double(0) + /// The minumum number of labels on the axis + @objc open var axisMinLabels = Int(2) { + didSet { axisMinLabels = axisMinLabels > 0 ? axisMinLabels : oldValue } + } + + /// The maximum number of labels on the axis + @objc open var axisMaxLabels = Int(25) { + didSet { axisMinLabels = axisMaxLabels > 0 ? axisMaxLabels : oldValue } + } + /// the number of label entries the axis should have /// max = 25, /// min = 2, @@ -228,13 +238,13 @@ open class AxisBase: ComponentBase { _labelCount = newValue - if _labelCount > 25 + if _labelCount > axisMaxLabels { - _labelCount = 25 + _labelCount = axisMaxLabels } - if _labelCount < 2 + if _labelCount < axisMinLabels { - _labelCount = 2 + _labelCount = axisMinLabels } forceLabelsEnabled = false