import { ScaleCreationContext } from '@chart-parts/interfaces' ; import { ScaleQuantile , scaleQuantile } from 'd3-scale' ; import { DomainRangeScale } from './DomainRangeScale' ; import { QuantitativeValue } from './quantitative/QuantitativeScale' ; export class QuantileScale < DomainValue extends QuantitativeValue , RangeValue extends QuantitativeValue > extends DomainRangeScale < [ DomainValue , DomainValue ] , RangeValue [ ] , any > { public handleRangeBind ( ) { throw new Error ( 'cannot use range binding on Quantize scale' ) ; } public createScale ( args ) { const domain = this . getDomain ( args ) ; const range = this . getRange ( args ) ; const scale = scaleQuantile ( ) . domain ( domain ) . range ( range as any ) as ScaleQuantile < RangeValue > ; if ( ! this . nameValue ) { throw new Error ( 'scale name must be defined' ) ; } return { [ this . nameValue ] : scale , } ; } }