import { RGBATupleToString } from '../../../../common/color_library_wrappers' ; import { LegendItem } from '../../../../common/legend' ; import { createCustomCachedSelector } from '../../../../state/create_selector' ; import { DebugState , DebugStateLegend } from '../../../../state/types' ; import { Position } from '../../../../utils/common' ; import { getChartThemeSelector } from './../../../../state/selectors/get_chart_theme' ; import { computeLegendSelector } from './compute_legend' ; import { getHeatmapGeometries } from './geometries' ; import { getHighlightedAreaSelector , getHighlightedDataSelector } from './get_highlighted_area' ; internal export const getDebugStateSelector = createCustomCachedSelector ( [ getHeatmapGeometries , computeLegendSelector , getHighlightedAreaSelector , getHighlightedDataSelector , getChartThemeSelector , ] , ( geoms , legend , pickedArea , highlightedData , { heatmap } ) : DebugState => { return { legend : getLegendState ( legend ) , axes : { x : [ { id : 'x' , position : Position . Left , labels : geoms . heatmapViewModel . xValues . map ( ( { text } ) => text ) , values : geoms . heatmapViewModel . xValues . map ( ( { value } ) => value ) , gridlines : geoms . heatmapViewModel . gridLines . x . map ( ( line ) => ( { x : line . x1 , y : line . y2 } ) ) , } , ] , y : [ { id : 'y' , position : Position . Bottom , labels : geoms . heatmapViewModel . yValues . map ( ( { text } ) => text ) , values : geoms . heatmapViewModel . yValues . map ( ( { value } ) => value ) , gridlines : geoms . heatmapViewModel . gridLines . y . map ( ( line ) => ( { x : line . x2 , y : line . y1 } ) ) , } , ] , } , heatmap : { cells : geoms . heatmapViewModel . cells . map ( ( cell ) => ( { x : cell . x , y : cell . y , fill : RGBATupleToString ( cell . fill . color ) , formatted : cell . formatted , value : cell . value , valueShown : heatmap . cell . label . visible && Number . isFinite ( geoms . heatmapViewModel . cellFontSize ( cell ) ) , } ) ) , selection : { area : pickedArea , data : highlightedData , } , } , } ; } ) ; function getLegendState ( legendItems ) { const items = legendItems . filter ( ( { isSeriesHidden } ) => ! isSeriesHidden ) . map ( ( { label : name , color , seriesIdentifiers : [ { key } ] } ) => ( { key , name , color , } ) ) ; return { items } ; }