Skip to content

Commit 89dc850

Browse files
committed
Extend 'padding property' for the treemap
1 parent 6afeaec commit 89dc850

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

docs/treemap.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@ Height of the component.
9696

9797
#### padding
9898

99-
Type: `number`
99+
Type: `number` or `Array` of `number`
100100

101-
The padding between the cells of the heatmap in pixels.
101+
The padding between the cells of the heatmap in pixels.
102+
If Array, then each element should correspond to padding for direction in `paddingDirections` parameter.
102103

103104
#### paddingDirections (optional)
104105

src/treemap/index.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,12 @@ function _applyPadding(treemapingFunction, padding, paddingDirections) {
109109
'bottom': 'paddingBottom',
110110
'top': 'paddingTop',
111111
};
112+
let i = 0;
112113
paddingDirections.forEach(direction => {
113114
const property = directionToProperty[direction];
114-
treemapingFunction = treemapingFunction[property](padding);
115+
const paddingForDirection = Array.isArray(padding) ? padding[i] : padding;
116+
i += 1;
117+
treemapingFunction = treemapingFunction[property](paddingForDirection);
115118
});
116119
return treemapingFunction;
117120
}
@@ -211,7 +214,7 @@ Treemap.propTypes = {
211214
onLeafMouseOver: PropTypes.func,
212215
onLeafMouseOut: PropTypes.func,
213216
useCirclePacking: PropTypes.bool,
214-
padding: PropTypes.number.isRequired,
217+
padding: PropTypes.oneOfType([PropTypes.number, PropTypes.arrayOf(PropTypes.number)]).isRequired,
215218
paddingDirections: PropTypes.arrayOf(PropTypes.oneOf(['left', 'right', 'top', 'bottom'])),
216219
sortFunction: PropTypes.func,
217220
width: PropTypes.number.isRequired,

0 commit comments

Comments
 (0)