import { ComponentProps } from 'react' ; import { ChartType } from '../..' ; import { Distance , Pixels , Radius } from '../../../common/geometry' ; import { BaseDatum , Spec } from '../../../specs' ; import { SpecType } from '../../../specs/constants' ; import { buildSFProps , SFProps , useSpecFactory } from '../../../state/spec_factory' ; import { IndexedAccessorFn } from '../../../utils/accessor' ; import { Datum , LabelAccessor , ShowAccessor , ValueAccessor , ValueFormatter , stripUndefined , } from '../../../utils/common' ; import { FillFontSizeRange , FillLabelConfig } from '../../../utils/themes/partition' ; import { percentFormatter } from '../layout/config' ; import { AnimationConfig , PartitionLayout } from '../layout/types/config_types' ; import { NodeColorAccessor , ValueGetter } from '../layout/types/viewmodel_types' ; import { NodeSorter , AGGREGATE_KEY } from '../layout/utils/group_by_rollup' ; interface ExtendedFillLabelConfig extends FillLabelConfig , FillFontSizeRange { valueFormatter : ValueFormatter ; } public export interface Layer < D extends BaseDatum = Datum > { groupByRollup : IndexedAccessorFn < D > ; sortPredicate ? : NodeSorter | null ; nodeLabel ? : LabelAccessor ; fillLabel ? : Partial < ExtendedFillLabelConfig > ; showAccessor ? : ShowAccessor ; shape ? : { fillColor : string | NodeColorAccessor ; } ; } public export interface PartitionSpec < D extends BaseDatum = Datum > extends Spec , AnimationConfig { specType : typeof SpecType . Series ; chartType : typeof ChartType . Partition ; data : D [ ] ; valueAccessor : ValueAccessor < D > ; valueFormatter : ValueFormatter ; valueGetter : ValueGetter ; percentFormatter : ValueFormatter ; topGroove : Pixels ; smallMultiples : string | null ; layers : Layer < D > [ ] ; /**
     * Largest to smallest sectors are positioned in a clockwise order
     */ clockwiseSectors : boolean ; /**
     * Starts placement with the second largest slice, for the innermost pie/ring
     */ specialFirstInnermostSector : boolean ; layout : PartitionLayout ; maxRowCount : number ; alpha drilldown : boolean ; fillOutside : boolean ; radiusOutside : Radius ; fillRectangleWidth : Distance ; fillRectangleHeight : Distance ; } const buildProps = buildSFProps < PartitionSpec > ( ) ( { chartType : ChartType . Partition , specType : SpecType . Series , } , { valueAccessor : ( d ) => ( typeof d === 'number' ? d : 0 ) , valueGetter : ( n ) => n [ AGGREGATE_KEY ] , valueFormatter : ( d ) => String ( d ) , percentFormatter , topGroove : 20 , smallMultiples : '__global__small_multiples___' , layers : [ { groupByRollup : ( _ , i ) => i , nodeLabel : ( d ) => String ( d ) , showAccessor : ( ) => true , fillLabel : { } , } , ] , clockwiseSectors : true , specialFirstInnermostSector : true , layout : PartitionLayout . sunburst , drilldown : false , maxRowCount : 12 , fillOutside : false , radiusOutside : 128 , fillRectangleWidth : Infinity , fillRectangleHeight : Infinity , animation : { duration : 0 } , } ) ; public export const Partition = function < D extends BaseDatum = Datum > ( props ) { const { defaults , overrides } = buildProps ; useSpecFactory < PartitionSpec < D > > ( { ... defaults , ... stripUndefined ( props ) , ... overrides } ) ; return null ; } ; public export type PartitionProps = ComponentProps < typeof Partition > ;