MCPcopy Index your code
hub / github.com/plotly/plotly.js / computeSectorBBox

Function computeSectorBBox

src/plots/polar/polar.js:1526–1573  ·  view source on GitHub ↗
(sector)

Source from the content-addressed store, hash-verified

1524// - sector[0] < sector[1]
1525// - counterclockwise rotation
1526function computeSectorBBox(sector) {
1527 var s0 = sector[0];
1528 var s1 = sector[1];
1529 var arc = s1 - s0;
1530 var a0 = mod(s0, 360);
1531 var a1 = a0 + arc;
1532
1533 var ax0 = Math.cos(deg2rad(a0));
1534 var ay0 = Math.sin(deg2rad(a0));
1535 var ax1 = Math.cos(deg2rad(a1));
1536 var ay1 = Math.sin(deg2rad(a1));
1537
1538 var x0, y0, x1, y1;
1539
1540 if((a0 <= 90 && a1 >= 90) || (a0 > 90 && a1 >= 450)) {
1541 y1 = 1;
1542 } else if(ay0 <= 0 && ay1 <= 0) {
1543 y1 = 0;
1544 } else {
1545 y1 = Math.max(ay0, ay1);
1546 }
1547
1548 if((a0 <= 180 && a1 >= 180) || (a0 > 180 && a1 >= 540)) {
1549 x0 = -1;
1550 } else if(ax0 >= 0 && ax1 >= 0) {
1551 x0 = 0;
1552 } else {
1553 x0 = Math.min(ax0, ax1);
1554 }
1555
1556 if((a0 <= 270 && a1 >= 270) || (a0 > 270 && a1 >= 630)) {
1557 y0 = -1;
1558 } else if(ay0 >= 0 && ay1 >= 0) {
1559 y0 = 0;
1560 } else {
1561 y0 = Math.min(ay0, ay1);
1562 }
1563
1564 if(a1 >= 360) {
1565 x1 = 1;
1566 } else if(ax0 <= 0 && ax1 <= 0) {
1567 x1 = 0;
1568 } else {
1569 x1 = Math.max(ax0, ax1);
1570 }
1571
1572 return [x0, y0, x1, y1];
1573}
1574
1575function snapToVertexAngle(a, vangles) {
1576 var fn = function(v) { return Lib.angleDist(a, v); };

Callers 1

polar.jsFile · 0.85

Calls 2

modFunction · 0.85
deg2radFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…