Skip to content

Commit

Permalink
feat(bar): add support for border on Bar component
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphaël Benitte committed Sep 10, 2017
1 parent cd4c166 commit 7f5ac7c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/charts/bar/Bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ const Bar = ({
defs,
fill,
borderRadius,
borderWidth,
getBorderColor,

// motion
animate,
Expand Down Expand Up @@ -154,6 +156,7 @@ const Bar = ({
{({ showTooltip, hideTooltip }) => {
const commonProps = {
borderRadius,
borderWidth,
enableLabel,
labelSkipWidth,
labelSkipHeight,
Expand Down Expand Up @@ -194,6 +197,7 @@ const Bar = ({
height: Math.max(style.height, 0),
label: getLabel(bar.data),
labelColor: getLabelTextColor(baseProps, theme),
borderColor: getBorderColor(baseProps),
})
})}
</g>
Expand All @@ -206,9 +210,10 @@ const Bar = ({
key: d.key,
...d,
...commonProps,
label: getLabel(d),
label: getLabel(d.data),
shouldRenderLabel: shouldRenderLabel(d),
labelColor: getLabelTextColor(d, theme),
borderColor: getBorderColor(d),
})
)
}
Expand Down
6 changes: 6 additions & 0 deletions src/components/charts/bar/BarItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const BarItem = ({
height,
borderRadius,
color,
borderWidth,
borderColor,

label,
shouldRenderLabel,
Expand Down Expand Up @@ -53,6 +55,8 @@ const BarItem = ({
rx={borderRadius}
ry={borderRadius}
fill={data.fill ? data.fill : color}
strokeWidth={borderWidth}
stroke={borderColor}
onMouseEnter={handleTooltip}
onMouseMove={handleTooltip}
onMouseLeave={hideTooltip}
Expand Down Expand Up @@ -89,6 +93,8 @@ BarItem.propTypes = {
height: PropTypes.number.isRequired,
color: PropTypes.string.isRequired,
borderRadius: PropTypes.number.isRequired,
borderWidth: PropTypes.number.isRequired,
borderColor: PropTypes.string.isRequired,

label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
shouldRenderLabel: PropTypes.bool.isRequired,
Expand Down
3 changes: 3 additions & 0 deletions src/components/charts/bar/enhance.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,8 @@ export default Component =>
withPropsOnChange(['label', 'labelFormat'], ({ label, labelFormat }) => ({
getLabel: getLabelGenerator(label, labelFormat),
})),
withPropsOnChange(['borderColor'], ({ borderColor }) => ({
getBorderColor: getInheritedColorGenerator(borderColor),
})),
pure
)(Component)
5 changes: 5 additions & 0 deletions src/components/charts/bar/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ export const BarPropTypes = {
.isRequired,
})
).isRequired,
borderWidth: PropTypes.number.isRequired,
borderColor: PropTypes.any.isRequired,
getBorderColor: PropTypes.func.isRequired,

// interactivity
isInteractive: PropTypes.bool,
Expand Down Expand Up @@ -107,6 +110,8 @@ export const BarDefaultProps = {

defs: [],
fill: [],
borderWidth: 0,
borderColor: 'inherit',

// interactivity
isInteractive: true,
Expand Down

0 comments on commit 7f5ac7c

Please sign in to comment.