import { RefObject } from 'react' ; import { ChartType } from '../..' ; import { BackwardRef , GlobalChartState , InternalChartState } from '../../../state/chart_state' ; import { InitStatus } from '../../../state/selectors/get_internal_is_intialized' ; import { DebugState } from '../../../state/types' ; import { Dimensions } from '../../../utils/dimensions' ; import { render } from '../renderer/dom/layered_partition_chart' ; import { computeLegendSelector } from './selectors/compute_legend' ; import { getChartTypeDescriptionSelector } from './selectors/get_chart_type_description' ; import { getPointerCursorSelector } from './selectors/get_cursor_pointer' ; import { getDebugStateSelector } from './selectors/get_debug_state' ; import { getLegendItemsExtra } from './selectors/get_legend_items_extra' ; import { getLegendItemsLabels } from './selectors/get_legend_items_labels' ; import { isTooltipVisibleSelector } from './selectors/is_tooltip_visible' ; 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 { getPartitionSpec } from './selectors/partition_spec' ; import { getTooltipInfoSelector } from './selectors/tooltip' ; internal export class PartitionState implements InternalChartState { chartType = ChartType . Partition ; onElementClickCaller : ( state : GlobalChartState ) => void ; onElementOverCaller : ( state : GlobalChartState ) => void ; onElementOutCaller : ( state : GlobalChartState ) => void ; constructor ( ) { this . onElementClickCaller = createOnElementClickCaller ( ) ; this . onElementOverCaller = createOnElementOverCaller ( ) ; this . onElementOutCaller = createOnElementOutCaller ( ) ; } isInitialized ( globalState ) { return getPartitionSpec ( globalState ) !== null ? InitStatus . Initialized : InitStatus . SpecNotInitialized ; } isBrushAvailable ( ) { return false ; } isBrushing ( ) { return false ; } isChartEmpty ( ) { return false ; } getLegendItemsLabels ( globalState ) { return getLegendItemsLabels ( globalState ) ; } getLegendItems ( globalState ) { return computeLegendSelector ( globalState ) ; } getLegendExtraValues ( globalState ) { return getLegendItemsExtra ( globalState ) ; } chartRenderer ( containerRef , forwardStageRef ) { return render ( containerRef , forwardStageRef ) ; } getPointerCursor ( globalState ) { return getPointerCursorSelector ( globalState ) ; } isTooltipVisible ( globalState ) { return { visible : isTooltipVisibleSelector ( globalState ) , isExternal : false , } ; } getTooltipInfo ( globalState ) { return getTooltipInfoSelector ( globalState ) ; } getTooltipAnchor ( state ) { const { position } = state . interactions . pointer . current ; return { isRotated : false , x : position . x , width : 0 , y : position . y , height : 0 , } ; } eventCallbacks ( globalState ) { this . onElementOverCaller ( globalState ) ; this . onElementOutCaller ( globalState ) ; this . onElementClickCaller ( globalState ) ; } getProjectionContainerArea ( ) { return { width : 0 , height : 0 , top : 0 , left : 0 } ; } getMainProjectionArea ( ) { return { width : 0 , height : 0 , top : 0 , left : 0 } ; } getBrushArea ( ) { return null ; } getDebugState ( state ) { return getDebugStateSelector ( state ) ; } getChartTypeDescription ( state ) { return getChartTypeDescriptionSelector ( state ) ; } }