import { ScaleCreationContext , Scales } from '@chart-parts/interfaces' ; import { scaleTime } from 'd3-scale' ; import { QuantitativeScale , TimeValue } from './QuantitativeScale' ; function setType ( result ) { result . __scaletype__ = 'time' ; } export class TimeScale extends QuantitativeScale < TimeValue , number > { protected createScale ( args ) { const domain = this . getDomain ( args ) ; const range = this . getRange ( args ) ; const result = scaleTime ( ) . domain ( domain ) . range ( range ) ; this . addCommonProperties ( result ) ; setType ( result ) ; if ( ! this . nameValue ) { throw new Error ( 'scale name must be set' ) ; } return { [ this . nameValue ] : result } ; } }