import { ScaleContinuous } from '../../../../scales' ; import { ScaleType } from '../../../../scales/constants' ; import { createCustomCachedSelector } from '../../../../state/create_selector' ; import { getChartThemeSelector } from '../../../../state/selectors/get_chart_theme' ; import { withTextMeasure } from '../../../../utils/bbox/canvas_text_bbox_calculator' ; import { horizontalPad } from '../../../../utils/dimensions' ; import { getHeatmapSpecSelector } from './get_heatmap_spec' ; import { getHeatmapTableSelector } from './get_heatmap_table' ; internal export const getXAxisRightOverflow = createCustomCachedSelector ( [ getHeatmapSpecSelector , getChartThemeSelector , getHeatmapTableSelector ] , ( { xScale , timeZone , xAxisLabelFormatter } , { heatmap : { xAxisLabel : style } } , { xNumericExtent } ) => { return xScale . type !== ScaleType . Time ? 0 : typeof style . width === 'number' ? style . width / 2 : withTextMeasure ( ( measure ) => { return new ScaleContinuous ( { type : ScaleType . Time , domain : xNumericExtent , range : [ 0 , 1 ] } , { timeZone : xScale . type === ScaleType . Time ? timeZone : undefined } ) . ticks ( ) . reduce ( ( max , n ) => Math . max ( max , measure ( xAxisLabelFormatter ( n ) , { ... style } , style . fontSize ) . width + horizontalPad ( style . padding ) ) , 0 ) ; } ) / 2 ; } ) ;