- {nodes.map((node, index) => {
- // throw out the rootest node
- if (hideRootNode && !index) {
- return null;
- }
+function TreemapDOM(props) {
+ const {
+ animation,
+ className,
+ height,
+ hideRootNode,
+ getLabel,
+ mode,
+ nodes,
+ width,
+ scales,
+ style
+ } = props;
+ const useCirclePacking = mode === 'circlePack';
+ return (
+
+ {nodes.map((node, index) => {
+ // throw out the rootest node
+ if (hideRootNode && !index) {
+ return null;
+ }
- const nodeProps = {
- animation,
- node,
- getLabel,
- ...this.props,
- x0: useCirclePacking ? node.x : node.x0,
- x1: useCirclePacking ? node.x : node.x1,
- y0: useCirclePacking ? node.y : node.y0,
- y1: useCirclePacking ? node.y : node.y1,
- r: useCirclePacking ? node.r : 1,
- scales,
- style
- };
- return ;
- })}
-
- );
- }
+ const nodeProps = {
+ animation,
+ node,
+ getLabel,
+ ...props,
+ x0: useCirclePacking ? node.x : node.x0,
+ x1: useCirclePacking ? node.x : node.x1,
+ y0: useCirclePacking ? node.y : node.y0,
+ y1: useCirclePacking ? node.y : node.y1,
+ r: useCirclePacking ? node.r : 1,
+ scales,
+ style
+ };
+ return
;
+ })}
+
+ );
}
TreemapDOM.displayName = 'TreemapDOM';
diff --git a/src/treemap/treemap-leaf.js b/src/treemap/treemap-leaf.js
index 170424f82..899f0c9d6 100644
--- a/src/treemap/treemap-leaf.js
+++ b/src/treemap/treemap-leaf.js
@@ -39,65 +39,64 @@ const ANIMATED_PROPS = [
'r'
];
-class TreemapLeaf extends React.Component {
- render() {
- const {
- animation,
- getLabel,
- mode,
- node,
- onLeafClick,
- onLeafMouseOver,
- onLeafMouseOut,
- r,
- scales,
- x0,
- x1,
- y0,
- y1,
- style
- } = this.props;
-
- if (animation) {
- return (
- onLeafMouseOver(node, event)}
- onMouseLeave={event => onLeafMouseOut(node, event)}
- onClick={event => onLeafClick(node, event)}
- style={leafStyle}
- >
-
{title}
-
+ onLeafMouseOver(node, event)}
+ onMouseLeave={event => onLeafMouseOut(node, event)}
+ onClick={event => onLeafClick(node, event)}
+ style={leafStyle}
+ >
+
{title}
+
+ );
}
+
TreemapLeaf.propTypes = {
animation: AnimationPropType,
height: PropTypes.number.isRequired,