import React , { RefObject } from 'react' ; import { ChartType } from '../..' ; import { BrushTool } from '../../../components/brush/brush' ; import { Tooltip } from '../../../components/tooltip' ; import { InternalChartState , GlobalChartState , BackwardRef } from '../../../state/chart_state' ; import { getChartContainerDimensionsSelector } from '../../../state/selectors/get_chart_container_dimensions' ; import { InitStatus } from '../../../state/selectors/get_internal_is_intialized' ; import { Dimensions } from '../../../utils/dimensions' ; import { Heatmap } from '../renderer/canvas/connected_component' ; import { HighlighterFromBrush } from '../renderer/dom/highlighter_brush' ; import { computeChartElementSizesSelector } from './selectors/compute_chart_dimensions' ; import { computeLegendSelector } from './selectors/compute_legend' ; import { getBrushAreaSelector } from './selectors/get_brush_area' ; import { getPointerCursorSelector } from './selectors/get_cursor_pointer' ; import { getDebugStateSelector } from './selectors/get_debug_state' ; import { getLegendItemsLabelsSelector } from './selectors/get_legend_items_labels' ; import { getTooltipAnchorSelector } from './selectors/get_tooltip_anchor' ; import { getSpecOrNull } from './selectors/heatmap_spec' ; import { isBrushAvailableSelector } from './selectors/is_brush_available' ; import { isBrushingSelector } from './selectors/is_brushing' ; import { isEmptySelector } from './selectors/is_empty' ; import { isTooltipVisibleSelector } from './selectors/is_tooltip_visible' ; import { createOnBrushEndCaller } from './selectors/on_brush_end_caller' ; import { createOnElementClickCaller } from './selectors/on_element_click_caller' ; import { createOnElementOutCaller } from './selectors/on_element_out_caller' ; import { createOnElementOverCaller } from './selectors/on_element_over_caller' ; import { getTooltipInfoSelector } from './selectors/tooltip' ; const EMPTY_MAP = new Map ( ) ; internal export class HeatmapState implements InternalChartState { chartType = ChartType . Heatmap ; onElementClickCaller : ( state : GlobalChartState ) => void = createOnElementClickCaller ( ) ; onElementOverCaller : ( state : GlobalChartState ) => void = createOnElementOverCaller ( ) ; onElementOutCaller : ( state : GlobalChartState ) => void = createOnElementOutCaller ( ) ; onBrushEndCaller : ( state : GlobalChartState ) => void = createOnBrushEndCaller ( ) ; isInitialized ( globalState ) { return getSpecOrNull ( globalState ) !== null ? InitStatus . Initialized : InitStatus . ChartNotInitialized ; } isBrushAvailable ( globalState ) { return isBrushAvailableSelector ( globalState ) ; } isBrushing ( globalState ) { return isBrushingSelector ( globalState ) ; } isChartEmpty ( globalState ) { return isEmptySelector ( globalState ) ; } getLegendItems ( globalState ) { return computeLegendSelector ( globalState ) ; } getLegendItemsLabels ( globalState ) { return getLegendItemsLabelsSelector ( globalState ) ; } getLegendExtraValues ( ) { return EMPTY_MAP ; } chartRenderer ( containerRef , forwardStageRef ) { return ( < > < Tooltip getChartContainerRef = { containerRef } / > < Heatmap forwardStageRef = { forwardStageRef } /> < BrushTool / > < HighlighterFromBrush /> < />); } getPointerCursor ( globalState ) { return getPointerCursorSelector ( globalState ) ; } isTooltipVisible ( globalState ) { return { visible : isTooltipVisibleSelector ( globalState ) , isExternal : false } ; } getTooltipInfo ( globalState ) { return getTooltipInfoSelector ( globalState ) ; } getTooltipAnchor ( globalState ) { return getTooltipAnchorSelector ( globalState ) ; } getProjectionContainerArea ( globalState ) { return getChartContainerDimensionsSelector ( globalState ) ; } getMainProjectionArea ( globalState ) { return computeChartElementSizesSelector ( globalState ) . grid ; } getBrushArea ( globalState ) { return getBrushAreaSelector ( globalState ) ; } getDebugState ( globalState ) { return getDebugStateSelector ( globalState ) ; } getChartTypeDescription ( ) { return 'Heatmap chart' ; } eventCallbacks ( globalState ) { this . onElementOverCaller ( globalState ) ; this . onElementOutCaller ( globalState ) ; this . onElementClickCaller ( globalState ) ; this . onBrushEndCaller ( globalState ) ; } }