import { jsx, TextStyleProps } from '@antv/f-engine'; import Coord from '../../coord/base'; import { DataRecord } from '../../chart/Data'; import { TreemapProps as TreemapBaseProps, RecordNode } from './withTreemap'; export interface TreemapProps extends TreemapBaseProps { label?: boolean | TextStyleProps; onClick?: (record: RecordNode) => void; } export default ( props: TreemapProps & { coord: Coord } // Coord 在 withTreemap 被转成 Coord 类型了,所以这里需要重新定义 ) => { const { nodes, coord, onClick, label = false } = props; if (coord.isPolar) { const { center } = coord; const { x, y } = center; return ( {nodes.map((node) => { const { xMin, xMax, yMin, yMax, color, style } = node; return ( onClick(node) : null} /> ); })} ); } return ( {nodes.map((node) => { const { key, xMin, xMax, yMin, yMax, color, style } = node; return ( onClick(node) : null} /> {label && ( )} ); })} ); };