import { ScaleBand } from '../../../../scales' ; import { DEFAULT_SM_PANEL_PADDING , RelativeBandsPadding } from '../../../../specs/small_multiples' ; import { createCustomCachedSelector } from '../../../../state/create_selector' ; import { getSmallMultiplesSpec } from '../../../../state/selectors/get_small_multiples_spec' ; import { OrdinalDomain } from '../../../../utils/domain' ; import { computeChartDimensionsSelector } from './compute_chart_dimensions' ; import { computeSeriesDomainsSelector } from './compute_series_domains' ; internal export interface SmallMultipleScales { horizontal : ScaleBand < number | string > ; vertical : ScaleBand < number | string > ; } internal export const computeSmallMultipleScalesSelector = createCustomCachedSelector ( [ computeSeriesDomainsSelector , computeChartDimensionsSelector , getSmallMultiplesSpec ] , ( { smHDomain , smVDomain } , { chartDimensions : { width , height } } , smSpec ) : SmallMultipleScales => { return { horizontal : getScale ( smHDomain , width , smSpec && smSpec [ 0 ] . style ?. horizontalPanelPadding ) , vertical : getScale ( smVDomain , height , smSpec && smSpec [ 0 ] . style ?. verticalPanelPadding ) , } ; } ) ; internal export function getScale ( domain , maxRange , padding = DEFAULT_SM_PANEL_PADDING ) { const singlePanelSmallMultiple = domain . length <= 1 ; return new ScaleBand ( domain , [ 0 , maxRange ] , undefined , singlePanelSmallMultiple ? 0 : padding ) ; }