I am trying to make the X direction grid line and tick labels fixed at mid of the visible range, whether the chart is zoomed or paned.
I had try to create custom TickProvider for my xAxis:
class CustomTickProvider: SCIDateTimeTickProvider {
private var tickCount: Int
init(tickCount: Int) {
self.tickCount = tickCount
}
override func getMajorTicks(fromAxis axis: SCIAxisCoreProtocol!) -> SCIArrayController! {
let visibleRange = axis.visibleRange
let min = visibleRange?.min.doubleData
let max = visibleRange?.max.doubleData
let array: SCIArrayController = SCIArrayController.init(type: SCIDataType.double)
let step = (max! - min!) / Double(self.tickCount - 1)
var current = min!
while current <= max! {
array.append(SCIGeneric(current))
current += step
}
return array
}
}
xAxis.tickProvider = CustomTickProvider.init(tickCount: 3)
When I set xAxis.autoTicks = true
, the grid line and tick labels will be relocated,they can't stay at the same position either.
When I set xAxis.autoTicks = false
, no grid line and tick labels will be
drawn.
How can I get the effect of fixed grid line and tick labels?