mirror of
https://github.com/klinecharts/KLineChart.git
synced 2024-11-25 16:22:43 +08:00
fix: fix custom axis not effective
This commit is contained in:
parent
2ee8acf85a
commit
fcc802c4c6
@ -14,7 +14,7 @@
|
||||
|
||||
import { CandleType } from '../common/Styles'
|
||||
import type Bounding from '../common/Bounding'
|
||||
import { isNumber, isString, isValid, merge } from '../common/utils/typeChecks'
|
||||
import { isFunction, isNumber, isString, isValid, merge } from '../common/utils/typeChecks'
|
||||
import { index10, getPrecision, nice, round } from '../common/utils/number'
|
||||
import { calcTextWidth } from '../common/utils/canvas'
|
||||
import { formatPrecision } from '../common/utils/format'
|
||||
@ -305,6 +305,13 @@ export default abstract class YAxisImp extends AxisImp implements YAxis {
|
||||
validY = y
|
||||
}
|
||||
})
|
||||
if (isFunction(this.createTicks)) {
|
||||
return this.createTicks({
|
||||
range: this.getRange(),
|
||||
bounding: this.getBounding(),
|
||||
defaultTicks: optimalTicks
|
||||
})
|
||||
}
|
||||
return optimalTicks
|
||||
}
|
||||
|
||||
|
@ -59,18 +59,17 @@ export default abstract class DrawPane<C extends Axis = Axis> extends Pane {
|
||||
|
||||
setOptions (options: PaneOptions): this {
|
||||
const paneId = this.getId()
|
||||
let name = options.axis?.name ?? 'normal'
|
||||
if (paneId === PaneIdConstants.CANDLE) {
|
||||
if (paneId === PaneIdConstants.CANDLE || paneId === PaneIdConstants.X_AXIS) {
|
||||
const axisName = options.axis?.name
|
||||
if (
|
||||
!isValid(this._axis) ||
|
||||
(this._options.axis.name !== name)
|
||||
(isValid(axisName) && this._options.axis.name !== axisName)
|
||||
) {
|
||||
this._axis = this.createAxisComponent(name)
|
||||
this._axis = this.createAxisComponent(axisName ?? 'normal')
|
||||
}
|
||||
} else {
|
||||
name = 'normal'
|
||||
if (!isValid(this._axis)) {
|
||||
this._axis = this.createAxisComponent(name)
|
||||
this._axis = this.createAxisComponent('normal')
|
||||
}
|
||||
}
|
||||
if (this._axis instanceof YAxisImp) {
|
||||
@ -78,8 +77,8 @@ export default abstract class DrawPane<C extends Axis = Axis> extends Pane {
|
||||
}
|
||||
merge(this._options, options)
|
||||
this._axis.override({
|
||||
name,
|
||||
...this._options.axis
|
||||
...this._options.axis,
|
||||
name: options.axis?.name ?? 'normal',
|
||||
})
|
||||
let container: Nullable<HTMLElement> = null
|
||||
let cursor = 'default'
|
||||
|
Loading…
Reference in New Issue
Block a user