import { Dimension , ScaleCreationContext , Scales , Scale , } from '@chart-parts/interfaces' ; import { scalePoint } from 'd3-scale' ; import { DomainRangeScale } from '../DomainRangeScale' ; import { getBoundRange } from '../getBoundRange' ; import { optionalArgument } from '../util' ; export class PointScale extends DomainRangeScale < string [ ] , [ number , number ] , Dimension > { private alignValue ? : number ; private paddingValue ? : number ; private roundValue ? : boolean ; private stepNameValue ? : string ; /**
     * Bin alignment 0-beginning, 1=end
     */ public align ( value ? ) { this . alignValue = value ; return this ; } /**
     * The outer and inner padding value
     */ public padding ( value ? ) { this . paddingValue = value ; return this ; } public round ( value ? ) { this . roundValue = optionalArgument ( value , arguments . length , true , false ) ; return this ; } public stepName ( value ? ) { this . stepNameValue = value ; return this ; } protected createScale ( args ) { const scale = scalePoint ( ) . domain ( this . getDomain ( args ) ) . range ( this . getRange ( args ) ) ; if ( this . paddingValue !== undefined ) { scale . padding ( this . paddingValue ) ; } if ( this . alignValue !== undefined ) { scale . align ( this . alignValue ) ; } if ( this . roundValue !== undefined ) { scale . round ( this . roundValue ) ; } if ( ! this . nameValue ) { throw new Error ( 'scale name must be defined' ) ; } const result = { [ this . nameValue ] : scale } ; if ( this . stepNameValue ) { result [ this . stepNameValue as string ] = scale . step as Scale < any , number > ; } return result ; } protected handleRangeBind ( args , rangeBind ) { return getBoundRange ( args , rangeBind ) ; } }