You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, first of all thanks for this awesome library.
We are using CombinedChartView.
What did you do?
I set 1 to the setLabelCount of the YAxis class.
What did you expect to happen?
I can not set one label on y axis.
What happened instead?
I set 0 or 1 to setLabelCount or labelCount, but
they are converted to 2, because
the bottom line (base line) and the top line (ceiling line) are always drawn.
Corresponding code
AxisBase.swift
/// the number of label entries the axis should have
/// max = 25,
/// min = 2,
/// default = 6,
/// be aware that this number is not fixed and can only be approximated
@objc open var labelCount: Int
{
get
{
return _labelCount
}
set
{
_labelCount = newValue
if _labelCount > 25
{
_labelCount = 25
}
if _labelCount < 2
{
_labelCount = 2
}
forceLabelsEnabled = false
}
}
AxisRendererBase.swift
/// Sets up the axis values. Computes the desired number of labels between the two given extremes.
@objc open func computeAxisValues(min: Double, max: Double)
{
guard let axis = self.axis else { return }
let yMin = min
let yMax = max
let labelCount = axis.labelCount
let range = abs(yMax - yMin)
if labelCount == 0 || range <= 0 || range.isInfinite
{
axis.entries = [Double]()
axis.centeredEntries = [Double]()
return
}
YAxisRenderer.swift
/// draws the y-labels on the specified x-position
@objc internal func drawYLabels(
context: CGContext,
fixedPosition: CGFloat,
positions: [CGPoint],
offset: CGFloat,
textAlign: NSTextAlignment)
{
guard
let yAxis = self.axis as? YAxis
else { return }
let labelFont = yAxis.labelFont
let labelTextColor = yAxis.labelTextColor
let from = yAxis.isDrawBottomYLabelEntryEnabled ? 0 : 1
let to = yAxis.isDrawTopYLabelEntryEnabled ? yAxis.entryCount : (yAxis.entryCount - 1)
for i in stride(from: from, to: to, by: 1)
{
We only need bottom line and bottom label.
Charts Environment
Charts version/Branch/Commit Number:
3.0.4 Xcode version:
9.1 Swift version:
4.0.2 macOS version running Xcode:
10.13.6
Thanks again!
The text was updated successfully, but these errors were encountered:
have you tried forceLabelsEnabled? Otherwise, override computeAxisValues and make axis.entries contains only one data
// force label count
if axis.isForceLabelsEnabled
{
let step = Double(range) / Double(labelCount - 1)
// Ensure stops contains at least n elements.
axis.entries.removeAll(keepingCapacity: true)
axis.entries.reserveCapacity(labelCount)
var v = yMin
for _ in 0 ..< labelCount
{
axis.entries.append(v)
v += step
}
n = labelCount
}
Hi, first of all thanks for this awesome library.
We are using CombinedChartView.
What did you do?
I set 1 to the setLabelCount of the YAxis class.
What did you expect to happen?
I can not set one label on y axis.
What happened instead?
I set 0 or 1 to setLabelCount or labelCount, but
they are converted to 2, because
the bottom line (base line) and the top line (ceiling line) are always drawn.
Corresponding code
AxisBase.swift
AxisRendererBase.swift
YAxisRenderer.swift
We only need bottom line and bottom label.
Charts Environment
Charts version/Branch/Commit Number:
3.0.4
Xcode version:
9.1
Swift version:
4.0.2
macOS version running Xcode:
10.13.6
Thanks again!
The text was updated successfully, but these errors were encountered: