(quadrants, trace)
| 958 | } |
| 959 | |
| 960 | function scootLabels(quadrants, trace) { |
| 961 | var xHalf, |
| 962 | yHalf, |
| 963 | equatorFirst, |
| 964 | farthestX, |
| 965 | farthestY, |
| 966 | xDiffSign, |
| 967 | yDiffSign, |
| 968 | thisQuad, |
| 969 | oppositeQuad, |
| 970 | wholeSide, |
| 971 | i, |
| 972 | thisQuadOutside, |
| 973 | firstOppositeOutsidePt; |
| 974 | |
| 975 | function topFirst(a, b) { |
| 976 | return a.pxmid[1] - b.pxmid[1]; |
| 977 | } |
| 978 | function bottomFirst(a, b) { |
| 979 | return b.pxmid[1] - a.pxmid[1]; |
| 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; |
no test coverage detected
searching dependent graphs…