| 5 | const CIRCLE = Math.PI * 2; |
| 6 | |
| 7 | function makeSectorPath(x, y, angle, radius) { |
| 8 | if (angle >= CIRCLE) { |
| 9 | return `M${x} ${y} |
| 10 | m${radius} 0 |
| 11 | a${radius} ${radius} 0 0 1 0 ${radius * 2} |
| 12 | a${radius} ${radius} 0 0 1 0 ${radius * -2}`; |
| 13 | } |
| 14 | |
| 15 | const startAngle = Math.PI / 2 - angle; |
| 16 | const endAngle = Math.PI / 2; |
| 17 | const arcFlag = angle > Math.PI ? 1 : 0; |
| 18 | const centerX = x + radius; |
| 19 | const centerY = y + radius; |
| 20 | |
| 21 | return `M${centerX} ${centerY} |
| 22 | L${centerX + Math.cos(startAngle) * radius} ${centerY - |
| 23 | Math.sin(startAngle) * radius} |
| 24 | A${radius} ${radius} 0 ${arcFlag} 0 ${centerX + |
| 25 | Math.cos(endAngle) * radius} ${centerY - Math.sin(endAngle) * radius} |
| 26 | L${centerX} ${centerY}`; |
| 27 | } |
| 28 | |
| 29 | export default class Sector extends Component { |
| 30 | static propTypes = { |