(gaugeOption, radius, centerPosition, opts, config, context)
| 1566 | } |
| 1567 | |
| 1568 | function drawGaugeLabel(gaugeOption, radius, centerPosition, opts, config, context) { |
| 1569 | radius -= gaugeOption.width / 2 + config.gaugeLabelTextMargin; |
| 1570 | |
| 1571 | let totalAngle = gaugeOption.startAngle - gaugeOption.endAngle + 1; |
| 1572 | let splitAngle = totalAngle / gaugeOption.splitLine.splitNumber; |
| 1573 | let totalNumber = gaugeOption.endNumber - gaugeOption.startNumber; |
| 1574 | let splitNumber = totalNumber / gaugeOption.splitLine.splitNumber; |
| 1575 | let nowAngle = gaugeOption.startAngle; |
| 1576 | let nowNumber = gaugeOption.startNumber; |
| 1577 | for (let i = 0; i < gaugeOption.splitLine.splitNumber + 1; i++) { |
| 1578 | var pos = { |
| 1579 | x: radius * Math.cos(nowAngle * Math.PI), |
| 1580 | y: radius * Math.sin(nowAngle * Math.PI) |
| 1581 | }; |
| 1582 | var labelText = gaugeOption.labelFormat ? gaugeOption.labelFormat(nowNumber) : nowNumber; |
| 1583 | pos.x += centerPosition.x - measureText(labelText) / 2; |
| 1584 | pos.y += centerPosition.y; |
| 1585 | var startX = pos.x; |
| 1586 | var startY = pos.y; |
| 1587 | context.beginPath(); |
| 1588 | context.setFontSize(config.fontSize); |
| 1589 | context.setFillStyle(gaugeOption.labelColor || '#666666'); |
| 1590 | context.fillText(labelText, startX, startY + config.fontSize / 2); |
| 1591 | context.closePath(); |
| 1592 | context.stroke(); |
| 1593 | |
| 1594 | nowAngle += splitAngle; |
| 1595 | if (nowAngle >= 2) { |
| 1596 | nowAngle = nowAngle % 2; |
| 1597 | } |
| 1598 | nowNumber += splitNumber; |
| 1599 | } |
| 1600 | |
| 1601 | } |
| 1602 | |
| 1603 | function drawRadarLabel(angleList, radius, centerPosition, opts, config, context) { |
| 1604 | var radarOption = opts.extra.radar || {}; |
no test coverage detected