MCPcopy Create free account
hub / github.com/CoderOpen/waimai / drawGaugeLabel

Function drawGaugeLabel

front/components/u-charts/u-charts.js:1568–1601  ·  view source on GitHub ↗
(gaugeOption, radius, centerPosition, opts, config, context)

Source from the content-addressed store, hash-verified

1566}
1567
1568function 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
1603function drawRadarLabel(angleList, radius, centerPosition, opts, config, context) {
1604 var radarOption = opts.extra.radar || {};

Callers 1

drawGaugeDataPointsFunction · 0.85

Calls 1

measureTextFunction · 0.85

Tested by

no test coverage detected