Skip to content

Commit

Permalink
add top and bottom options to positioning center label
Browse files Browse the repository at this point in the history
  • Loading branch information
Harshita Mehta committed Jun 18, 2018
1 parent 29e613b commit 5411419
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/component/Label.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const propTypes = {
'top', 'left', 'right', 'bottom', 'inside', 'outside',
'insideLeft', 'insideRight', 'insideTop', 'insideBottom',
'insideTopLeft', 'insideBottomLeft', 'insideTopRight', 'insideBottomRight',
'insideStart', 'insideEnd', 'end', 'center',
'insideStart', 'insideEnd', 'end', 'center', 'centerTop', 'centerBottom'
]),
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),
Expand Down Expand Up @@ -130,6 +130,24 @@ const getAttrsOfPolarLabel = (props) => {
};
}

if (position === 'centerTop') {
return {
x: cx,
y: cy,
textAnchor: 'middle',
verticalAnchor: 'start',
};
}

if (position === 'centerBottom') {
return {
x: cx,
y: cy,
textAnchor: 'middle',
verticalAnchor: 'end',
};
}

const r = (innerRadius + outerRadius) / 2;
const { x, y } = polarToCartesian(cx, cy, r, midAngle);

Expand Down

0 comments on commit 5411419

Please sign in to comment.