(series, opts, config, context, radius, center)
| 1628 | } |
| 1629 | |
| 1630 | function drawPieText(series, opts, config, context, radius, center) { |
| 1631 | var lineRadius = config.pieChartLinePadding; |
| 1632 | var textObjectCollection = []; |
| 1633 | var lastTextObject = null; |
| 1634 | |
| 1635 | var seriesConvert = series.map(function(item) { |
| 1636 | var text = item.format ? item.format(+item._proportion_.toFixed(2)) : util.toFixed(item._proportion_.toFixed(4) * 100) +'%'; |
| 1637 | if(item._rose_proportion_) item._proportion_=item._rose_proportion_; |
| 1638 | var arc = 2 * Math.PI - (item._start_ + 2 * Math.PI * item._proportion_ / 2); |
| 1639 | var color = item.color; |
| 1640 | var radius = item._radius_; |
| 1641 | return { |
| 1642 | arc: arc, |
| 1643 | text: text, |
| 1644 | color: color, |
| 1645 | radius: radius, |
| 1646 | textColor: item.textColor, |
| 1647 | textSize: item.textSize, |
| 1648 | }; |
| 1649 | }); |
| 1650 | for (let i = 0; i < seriesConvert.length; i++) { |
| 1651 | let item = seriesConvert[i]; |
| 1652 | // line end |
| 1653 | let orginX1 = Math.cos(item.arc) * (item.radius + lineRadius); |
| 1654 | let orginY1 = Math.sin(item.arc) * (item.radius + lineRadius); |
| 1655 | |
| 1656 | // line start |
| 1657 | let orginX2 = Math.cos(item.arc) * item.radius; |
| 1658 | let orginY2 = Math.sin(item.arc) * item.radius; |
| 1659 | |
| 1660 | // text start |
| 1661 | let orginX3 = orginX1 >= 0 ? orginX1 + config.pieChartTextPadding : orginX1 - config.pieChartTextPadding; |
| 1662 | let orginY3 = orginY1; |
| 1663 | let textWidth = measureText(item.text); |
| 1664 | let startY = orginY3; |
| 1665 | |
| 1666 | if (lastTextObject && util.isSameXCoordinateArea(lastTextObject.start, { |
| 1667 | x: orginX3 |
| 1668 | })) { |
| 1669 | if (orginX3 > 0) { |
| 1670 | startY = Math.min(orginY3, lastTextObject.start.y); |
| 1671 | } else if (orginX1 < 0) { |
| 1672 | startY = Math.max(orginY3, lastTextObject.start.y); |
| 1673 | } else { |
| 1674 | if (orginY3 > 0) { |
| 1675 | startY = Math.max(orginY3, lastTextObject.start.y); |
| 1676 | } else { |
| 1677 | startY = Math.min(orginY3, lastTextObject.start.y); |
| 1678 | } |
| 1679 | } |
| 1680 | } |
| 1681 | if (orginX3 < 0) { |
| 1682 | orginX3 -= textWidth; |
| 1683 | } |
| 1684 | |
| 1685 | let textObject = { |
| 1686 | lineStart: { |
| 1687 | x: orginX2, |
no test coverage detected