(t, avail, textList)
| 512 | |
| 513 | // fitText sets text and font-size clipped to the specified width w. |
| 514 | function fitText(t, avail, textList) { |
| 515 | // Find first entry in textList that fits. |
| 516 | let width = avail; |
| 517 | textContext.font = FONT_SIZE + 'pt Arial'; |
| 518 | for (let i = 0; i < textList.length; i++) { |
| 519 | let text = textList[i]; |
| 520 | width = textContext.measureText(text).width; |
| 521 | if (width <= avail) { |
| 522 | t.innerText = text; |
| 523 | return; |
| 524 | } |
| 525 | } |
| 526 | |
| 527 | // Try to fit by dropping font size. |
| 528 | let text = textList[textList.length-1]; |
| 529 | const fs = Math.max(MIN_FONT_SIZE, FONT_SIZE * (avail / width)); |
| 530 | t.style.fontSize = fs + 'pt'; |
| 531 | t.innerText = text; |
| 532 | } |
| 533 | |
| 534 | // totalValue returns the positive and negative sums of the Values of stacks |
| 535 | // listed in places. |
no outgoing calls
no test coverage detected
searching dependent graphs…