import { connect } from 'react-redux' ; import { GlobalChartState } from '../../../../state/chart_state' ; import { getChartContainerDimensionsSelector } from '../../../../state/selectors/get_chart_container_dimensions' ; import { getInternalIsInitializedSelector , InitStatus } from '../../../../state/selectors/get_internal_is_intialized' ; import { partitionDrilldownFocus , partitionMultiGeometries } from '../../state/selectors/geometries' ; import { legendHoverHighlightNodes } from '../../state/selectors/get_highlighted_shapes' ; import { HighlighterComponent , HighlighterProps , DEFAULT_PROPS , highlightSetMapper } from './highlighter' ; const legendMapStateToProps = ( state ) : HighlighterProps => { if ( getInternalIsInitializedSelector ( state ) !== InitStatus . Initialized ) { return DEFAULT_PROPS ; } const { chartId } = state ; const geometries = legendHoverHighlightNodes ( state ) ; const geometriesFoci = partitionDrilldownFocus ( state ) ; const canvasDimension = getChartContainerDimensionsSelector ( state ) ; const multiGeometries = partitionMultiGeometries ( state ) ; const highlightMapper = highlightSetMapper ( geometries , geometriesFoci ) ; const highlightSets = multiGeometries . map ( highlightMapper ) ; return { chartId , initialized : true , renderAsOverlay : false , canvasDimension , highlightSets , } ; } ; internal export const HighlighterFromLegend = connect ( legendMapStateToProps ) ( HighlighterComponent ) ;