(_x, _y, maxSize, textWidth, textHeight)
| 138817 | const width = $.width, height = $.height, bm0 = bitmaps[0], // where labels have been placed |
| 138818 | bm1 = bitmaps[1]; // area outlines |
| 138819 | function tryLabel(_x, _y, maxSize, textWidth, textHeight) { |
| 138820 | const x = $.invert(_x), y = $.invert(_y); |
| 138821 | let lo = maxSize, hi = height, mid; |
| 138822 | if (!outOfBounds(x, y, textWidth, textHeight, width, height) && !collision($, x, y, textHeight, textWidth, lo, bm0, bm1) && !collision($, x, y, textHeight, textWidth, textHeight, bm0, null)) { |
| 138823 | // if the label fits at the current sample point, |
| 138824 | // perform binary search to find the largest font size that fits |
| 138825 | while(hi - lo >= 1){ |
| 138826 | mid = (lo + hi) / 2; |
| 138827 | if (collision($, x, y, textHeight, textWidth, mid, bm0, bm1)) hi = mid; |
| 138828 | else lo = mid; |
| 138829 | } // place label if current lower bound exceeds prior max font size |
| 138830 | if (lo > maxSize) return [ |
| 138831 | x, |
| 138832 | y, |
| 138833 | lo, |
| 138834 | true |
| 138835 | ]; |
| 138836 | } |
| 138837 | } // try to place a label within an input area mark |
| 138838 | return function(d) { |
| 138839 | const items = d.datum.datum.items[markIndex].items, // area points |
| 138840 | n = items.length, // number of points |
no test coverage detected