Skip to content

Commit

Permalink
Extend 'padding property' for the treemap
Browse files Browse the repository at this point in the history
  • Loading branch information
Bi0max committed Aug 15, 2019
1 parent 6afeaec commit 89dc850
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions docs/treemap.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 5 additions & 2 deletions src/treemap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 89dc850

Please sign in to comment.