(thisPt, prevPt)
| 980 | } |
| 981 | |
| 982 | function scootOneLabel(thisPt, prevPt) { |
| 983 | if (!prevPt) prevPt = {}; |
| 984 | |
| 985 | var prevOuterY = prevPt.labelExtraY + (yHalf ? prevPt.yLabelMax : prevPt.yLabelMin); |
| 986 | var thisInnerY = yHalf ? thisPt.yLabelMin : thisPt.yLabelMax; |
| 987 | var thisOuterY = yHalf ? thisPt.yLabelMax : thisPt.yLabelMin; |
| 988 | var thisSliceOuterY = thisPt.cyFinal + farthestY(thisPt.px0[1], thisPt.px1[1]); |
| 989 | var newExtraY = prevOuterY - thisInnerY; |
| 990 | |
| 991 | var xBuffer, i, otherPt, otherOuterY, otherOuterX, newExtraX; |
| 992 | |
| 993 | // make sure this label doesn't overlap other labels |
| 994 | // this *only* has us move these labels vertically |
| 995 | if (newExtraY * yDiffSign > 0) thisPt.labelExtraY = newExtraY; |
| 996 | |
| 997 | // make sure this label doesn't overlap any slices |
| 998 | if (!Lib.isArrayOrTypedArray(trace.pull)) return; // this can only happen with array pulls |
| 999 | |
| 1000 | for (i = 0; i < wholeSide.length; i++) { |
| 1001 | otherPt = wholeSide[i]; |
| 1002 | |
| 1003 | // overlap can only happen if the other point is pulled more than this one |
| 1004 | if ( |
| 1005 | otherPt === thisPt || |
| 1006 | (helpers.castOption(trace.pull, thisPt.pts) || 0) >= (helpers.castOption(trace.pull, otherPt.pts) || 0) |
| 1007 | ) { |
| 1008 | continue; |
| 1009 | } |
| 1010 | |
| 1011 | if ((thisPt.pxmid[1] - otherPt.pxmid[1]) * yDiffSign > 0) { |
| 1012 | // closer to the equator - by construction all of these happen first |
| 1013 | // move the text vertically to get away from these slices |
| 1014 | otherOuterY = otherPt.cyFinal + farthestY(otherPt.px0[1], otherPt.px1[1]); |
| 1015 | newExtraY = otherOuterY - thisInnerY - thisPt.labelExtraY; |
| 1016 | |
| 1017 | if (newExtraY * yDiffSign > 0) thisPt.labelExtraY += newExtraY; |
| 1018 | } else if ((thisOuterY + thisPt.labelExtraY - thisSliceOuterY) * yDiffSign > 0) { |
| 1019 | // farther from the equator - happens after we've done all the |
| 1020 | // vertical moving we're going to do |
| 1021 | // move horizontally to get away from these more polar slices |
| 1022 | |
| 1023 | // if we're moving horz. based on a slice that's several slices away from this one |
| 1024 | // then we need some extra space for the lines to labels between them |
| 1025 | xBuffer = 3 * xDiffSign * Math.abs(i - wholeSide.indexOf(thisPt)); |
| 1026 | |
| 1027 | otherOuterX = otherPt.cxFinal + farthestX(otherPt.px0[0], otherPt.px1[0]); |
| 1028 | newExtraX = otherOuterX + xBuffer - (thisPt.cxFinal + thisPt.pxmid[0]) - thisPt.labelExtraX; |
| 1029 | |
| 1030 | if (newExtraX * xDiffSign > 0) thisPt.labelExtraX += newExtraX; |
| 1031 | } |
| 1032 | } |
| 1033 | } |
| 1034 | |
| 1035 | for (yHalf = 0; yHalf < 2; yHalf++) { |
| 1036 | equatorFirst = yHalf ? topFirst : bottomFirst; |
no outgoing calls
no test coverage detected
searching dependent graphs…