import { LayerValue } from '../../../../specs' ; import { Point } from '../../../../utils/point' ; import { ContinuousDomainFocus } from '../../renderer/canvas/partition' ; import { MODEL_KEY } from '../config' ; import { QuadViewModel , ShapeViewModel } from '../types/viewmodel_types' ; import { AGGREGATE_KEY , DEPTH_KEY , getNodeName , PARENT_KEY , PATH_KEY , SORT_INDEX_KEY } from '../utils/group_by_rollup' ; internal export const pickedShapes = ( models , { x , y } , foci ) : QuadViewModel [ ] => models . flatMap ( ( { diskCenter , pickQuads } ) => pickQuads ( x - diskCenter . x , y - diskCenter . y , foci [ 0 ] ) ) ; internal export function pickShapesLayerValues ( shapes ) { const maxDepth = shapes . reduce ( ( acc , curr ) => Math . max ( acc , curr . depth ) , 0 ) ; return shapes . filter ( ( { depth } ) => depth === maxDepth ) . map < Array < LayerValue > > ( ( viewModel ) => { const values = [ { smAccessorValue : viewModel . smAccessorValue , groupByRollup : viewModel . dataName , value : viewModel [ AGGREGATE_KEY ] , depth : viewModel [ DEPTH_KEY ] , sortIndex : viewModel [ SORT_INDEX_KEY ] , path : viewModel [ PATH_KEY ] , } , ] ; let node = viewModel [ MODEL_KEY ] ; while ( node [ DEPTH_KEY ] > 0 ) { const value = node [ AGGREGATE_KEY ] ; const dataName = getNodeName ( node ) ; values . push ( { smAccessorValue : viewModel . smAccessorValue , groupByRollup : dataName , value , depth : node [ DEPTH_KEY ] , sortIndex : node [ SORT_INDEX_KEY ] , path : node [ PATH_KEY ] , } ) ; node = node [ PARENT_KEY ] ; } return values . reverse ( ) ; } ) ; }