import { TooltipInfo } from '../../../../components/tooltip/types' ; import { LabelAccessor , ValueFormatter } from '../../../../utils/common' ; import { percentValueGetter , sumValueGetter } from '../config' ; import { QuadViewModel , ValueGetter } from '../types/viewmodel_types' ; import { valueGetterFunction } from './scenegraph' ; internal export const EMPTY_TOOLTIP = Object . freeze ( { header : null , values : [ ] , } ) ; internal export function getTooltipInfo ( pickedShapes , labelFormatters , valueGetter , valueFormatter , percentFormatter , id ) { if ( ! valueFormatter || ! labelFormatters ) { return EMPTY_TOOLTIP ; } const tooltipInfo = { header : null , values : [ ] , } ; const valueGetterFun = valueGetterFunction ( valueGetter ) ; const primaryValueGetterFun = valueGetterFun === percentValueGetter ? sumValueGetter : valueGetterFun ; pickedShapes . forEach ( ( shape ) => { const formatter = labelFormatters [ shape . depth - 1 ] ; const value = primaryValueGetterFun ( shape ) ; tooltipInfo . values . push ( { label : formatter ? formatter ( shape . dataName ) : shape . dataName , color : shape . fillColor , isHighlighted : false , isVisible : true , seriesIdentifier : { specId : id , key : id , } , value , formattedValue : `${ valueFormatter ( value ) } (${ percentFormatter ( percentValueGetter ( shape ) ) })` , valueAccessor : shape . depth , } ) ; } ) ; return tooltipInfo ; }