(d, showCommonLabel, hovermode, fullLayout, t0, g)
| 1673 | } |
| 1674 | |
| 1675 | function getHoverLabelText(d, showCommonLabel, hovermode, fullLayout, t0, g) { |
| 1676 | var name = ''; |
| 1677 | var text = ''; |
| 1678 | // to get custom 'name' labels pass cleanPoint |
| 1679 | if (d.nameOverride !== undefined) d.name = d.nameOverride; |
| 1680 | |
| 1681 | if (d.name) { |
| 1682 | if (d.trace._meta) d.name = Lib.templateString(d.name, d.trace._meta); |
| 1683 | name = plainText(d.name, d.nameLength); |
| 1684 | } |
| 1685 | |
| 1686 | var h0 = hovermode.charAt(0); |
| 1687 | var h1 = h0 === 'x' ? 'y' : 'x'; |
| 1688 | |
| 1689 | if (d.zLabel !== undefined) { |
| 1690 | if (d.xLabel !== undefined) text += 'x: ' + d.xLabel + '<br>'; |
| 1691 | if (d.yLabel !== undefined) text += 'y: ' + d.yLabel + '<br>'; |
| 1692 | if (d.trace.type !== 'choropleth' && d.trace.type !== 'choroplethmapbox' && d.trace.type !== 'choroplethmap') { |
| 1693 | text += (text ? 'z: ' : '') + d.zLabel; |
| 1694 | } |
| 1695 | } else if (showCommonLabel && d[h0 + 'Label'] === t0) { |
| 1696 | text = d[h1 + 'Label'] || ''; |
| 1697 | } else if (d.xLabel === undefined) { |
| 1698 | if (d.yLabel !== undefined && d.trace.type !== 'scattercarpet') { |
| 1699 | text = d.yLabel; |
| 1700 | } |
| 1701 | } else if (d.yLabel === undefined) text = d.xLabel; |
| 1702 | else text = '(' + d.xLabel + ', ' + d.yLabel + ')'; |
| 1703 | |
| 1704 | if ((d.text || d.text === 0) && !Array.isArray(d.text)) { |
| 1705 | text += (text ? '<br>' : '') + d.text; |
| 1706 | } |
| 1707 | |
| 1708 | // used by other modules (initially just ternary) that |
| 1709 | // manage their own hoverinfo independent of cleanPoint |
| 1710 | // the rest of this will still apply, so such modules |
| 1711 | // can still put things in (x|y|z)Label, text, and name |
| 1712 | // and hoverinfo will still determine their visibility |
| 1713 | if (d.extraText !== undefined) text += (text ? '<br>' : '') + d.extraText; |
| 1714 | |
| 1715 | // if 'text' is empty at this point, |
| 1716 | // and hovertemplate is not defined, |
| 1717 | // put 'name' in main label and don't show secondary label |
| 1718 | if (g && text === '' && !d.hovertemplate) { |
| 1719 | // if 'name' is also empty, remove entire label |
| 1720 | if (name === '') g.remove(); |
| 1721 | text = name; |
| 1722 | } |
| 1723 | |
| 1724 | // Ignore hovertemplate if hoverlabel.split is set |
| 1725 | // This ensures correct behavior of hoverlabel.split for candlestick and OHLC traces |
| 1726 | // Not very elegant but it works |
| 1727 | if (d.trace?.hoverlabel?.split) d.hovertemplate = ''; |
| 1728 | |
| 1729 | const { hovertemplate = false } = d; |
| 1730 | if (hovertemplate) { |
| 1731 | const labels = d.hovertemplateLabels || d; |
| 1732 |
no test coverage detected
searching dependent graphs…