import { withTextMeasure } from '../../../../utils/bbox/canvas_text_bbox_calculator' ; import { Dimensions } from '../../../../utils/dimensions' ; import { PartitionStyle } from '../../../../utils/themes/partition' ; import { Layer , PartitionSpec } from '../../specs' ; import { VALUE_GETTERS } from '../config' ; import { PartitionSmallMultiplesModel , RawTextGetter , ShapeTreeNode , ShapeViewModel , ValueGetter , } from '../types/viewmodel_types' ; import { DEPTH_KEY , HierarchyOfArrays } from '../utils/group_by_rollup' ; import { BackgroundStyle } from './../../../../utils/themes/theme' ; import { shapeViewModel } from './viewmodel' ; function rawTextGetter ( layers ) { return ( node ) => { const accessorFn = layers [ node [ DEPTH_KEY ] - 1 ] . nodeLabel || ( ( d ) => d ) ; return `${ accessorFn ( node . dataName ) }` ; } ; } internal export function valueGetterFunction ( valueGetter ) { return typeof valueGetter === 'function' ? valueGetter : VALUE_GETTERS [ valueGetter ] ; } internal export function getShapeViewModel ( spec , parentDimensions , tree , backgroundStyle , style , panelModel ) { return withTextMeasure ( ( measureText ) => { return shapeViewModel ( measureText , spec , style , parentDimensions , rawTextGetter ( spec . layers ) , valueGetterFunction ( spec . valueGetter ) , tree , backgroundStyle , panelModel ) ; } ) ; }