| 14 | import * as TickGenerators from "./tickGenerators"; |
| 15 | |
| 16 | export class QuantitativeScale<D> extends Scale<D, number> implements ITransformableScale { |
| 17 | protected static _DEFAULT_NUM_TICKS = 10; |
| 18 | private _tickGenerator: TickGenerators.ITickGenerator<D> = (scale: QuantitativeScale<D>) => scale.defaultTicks(); |
| 19 | private _padProportion = 0.05; |
| 20 | private _paddingExceptionsProviders: Utils.Set<Scales.IPaddingExceptionsProvider<D>>; |
| 21 | private _domainMin: D; |
| 22 | private _domainMax: D; |
| 23 | private _snappingDomainEnabled = true; |
| 24 | |
| 25 | /** |
| 26 | * A QuantitativeScale is a Scale that maps number-like values to numbers. |
| 27 | * It is invertible and continuous. |
| 28 | * |
| 29 | * @constructor |
| 30 | */ |
| 31 | constructor() { |
| 32 | super(); |
| 33 | this._paddingExceptionsProviders = new Utils.Set<Scales.IPaddingExceptionsProvider<D>>(); |
| 34 | } |
| 35 | |
| 36 | public autoDomain() { |
| 37 | this._domainMin = null; |
| 38 | this._domainMax = null; |
| 39 | super.autoDomain(); |
| 40 | return this; |
| 41 | } |
| 42 | |
| 43 | public autoDomainIfAutomaticMode() { |
| 44 | if (this._domainMin != null && this._domainMax != null) { |
| 45 | this._setDomain([this._domainMin, this._domainMax]); |
| 46 | return; |
| 47 | } |
| 48 | |
| 49 | const computedExtent = this._getExtent(); |
| 50 | |
| 51 | if (this._domainMin != null) { |
| 52 | let maxValue = computedExtent[1]; |
| 53 | if (this._domainMin >= maxValue) { |
| 54 | maxValue = this._expandSingleValueDomain([this._domainMin, this._domainMin])[1]; |
| 55 | } |
| 56 | this._setDomain([this._domainMin, maxValue]); |
| 57 | return; |
| 58 | } |
| 59 | |
| 60 | if (this._domainMax != null) { |
| 61 | let minValue = computedExtent[0]; |
| 62 | if (this._domainMax <= minValue) { |
| 63 | minValue = this._expandSingleValueDomain([this._domainMax, this._domainMax])[0]; |
| 64 | } |
| 65 | this._setDomain([minValue, this._domainMax]); |
| 66 | return; |
| 67 | } |
| 68 | |
| 69 | super.autoDomainIfAutomaticMode(); |
| 70 | } |
| 71 | |
| 72 | protected _getUnboundedExtent(ignoreAttachState = false): D[] { |
| 73 | const includedValues = this._getAllIncludedValues(ignoreAttachState); |
nothing calls this directly
no test coverage detected