diff --git a/docs/treemap.md b/docs/treemap.md index 66d9ab483..13686b3a6 100644 --- a/docs/treemap.md +++ b/docs/treemap.md @@ -96,9 +96,10 @@ Height of the component. #### padding -Type: `number` +Type: `number` or `Array` of `number` -The padding between the cells of the heatmap in pixels. +The padding between the cells of the heatmap in pixels. +If Array, then each element should correspond to padding for direction in `paddingDirections` parameter. #### paddingDirections (optional) diff --git a/src/treemap/index.js b/src/treemap/index.js index 8e3547718..903cf6303 100644 --- a/src/treemap/index.js +++ b/src/treemap/index.js @@ -109,9 +109,12 @@ function _applyPadding(treemapingFunction, padding, paddingDirections) { 'bottom': 'paddingBottom', 'top': 'paddingTop', }; + let i = 0; paddingDirections.forEach(direction => { const property = directionToProperty[direction]; - treemapingFunction = treemapingFunction[property](padding); + const paddingForDirection = Array.isArray(padding) ? padding[i] : padding; + i += 1; + treemapingFunction = treemapingFunction[property](paddingForDirection); }); return treemapingFunction; } @@ -211,7 +214,7 @@ Treemap.propTypes = { onLeafMouseOver: PropTypes.func, onLeafMouseOut: PropTypes.func, useCirclePacking: PropTypes.bool, - padding: PropTypes.number.isRequired, + padding: PropTypes.oneOfType([PropTypes.number, PropTypes.arrayOf(PropTypes.number)]).isRequired, paddingDirections: PropTypes.arrayOf(PropTypes.oneOf(['left', 'right', 'top', 'bottom'])), sortFunction: PropTypes.func, width: PropTypes.number.isRequired,