import { LayoutDirection } from '../../utils/common' ; import { Dimensions } from '../../utils/dimensions' ; import { GlobalChartState } from '../chart_state' ; import { createCustomCachedSelector } from '../create_selector' ; import { getLegendConfigSelector } from './get_legend_config_selector' ; import { getLegendSizeSelector } from './get_legend_size' ; const getParentDimension = ( state ) => state . parentDimensions ; internal export const getChartContainerDimensionsSelector = createCustomCachedSelector ( [ getLegendConfigSelector , getLegendSizeSelector , getParentDimension ] , ( { showLegend , legendPosition : { floating , direction } } , legendSize , parentDimensions ) : Dimensions => { if ( ! showLegend || floating ) { return parentDimensions ; } if ( direction === LayoutDirection . Vertical ) { return { left : 0 , top : 0 , width : parentDimensions . width - legendSize . width - legendSize . margin * 2 , height : parentDimensions . height , } ; } return { left : 0 , top : 0 , width : parentDimensions . width , height : parentDimensions . height - legendSize . height - legendSize . margin * 2 , } ; } ) ;