(params: TooltipParams)
| 90 | } |
| 91 | |
| 92 | function formatCandlestickRowHtml(params: TooltipParams): string { |
| 93 | const [, open, close, low, high] = params.value as readonly [number, number, number, number, number]; |
| 94 | |
| 95 | const safeName = escapeHtml(resolveSeriesName(params)); |
| 96 | const safeColor = escapeHtml(sanitizeCssColor(params.color)); |
| 97 | |
| 98 | // Format OHLC values |
| 99 | const openStr = formatNumber(open); |
| 100 | const highStr = formatNumber(high); |
| 101 | const lowStr = formatNumber(low); |
| 102 | const closeStr = formatNumber(close); |
| 103 | |
| 104 | // Determine direction and arrow |
| 105 | const isUp = close > open; |
| 106 | const arrow = isUp ? '\u25B2' : '\u25BC'; // ▲ or ▼ |
| 107 | const arrowColor = isUp ? '#22c55e' : '#ef4444'; |
| 108 | const percentChange = formatPercentChange(open, close); |
| 109 | |
| 110 | const ohlcText = `O: ${openStr} H: ${highStr} L: ${lowStr} C: ${closeStr}`; |
| 111 | const safeOHLC = escapeHtml(ohlcText); |
| 112 | const safeArrow = escapeHtml(arrow); |
| 113 | const safePercent = escapeHtml(percentChange); |
| 114 | const safeArrowColor = escapeHtml(arrowColor); |
| 115 | |
| 116 | return [ |
| 117 | '<div style="display:flex;flex-direction:column;gap:4px;">', |
| 118 | // Series name row |
| 119 | '<div style="display:flex;align-items:center;gap:8px;">', |
| 120 | `<span style="width:8px;height:8px;border-radius:999px;flex:0 0 auto;background-color:${safeColor};"></span>`, |
| 121 | `<span style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:600;">${safeName}</span>`, |
| 122 | '</div>', |
| 123 | // OHLC values row |
| 124 | `<div style="font-variant-numeric:tabular-nums;white-space:nowrap;font-size:0.9em;">${safeOHLC}</div>`, |
| 125 | // Change row with arrow |
| 126 | '<div style="display:flex;align-items:center;gap:6px;font-variant-numeric:tabular-nums;">', |
| 127 | `<span style="color:${safeArrowColor};font-weight:700;">${safeArrow}</span>`, |
| 128 | `<span style="color:${safeArrowColor};font-weight:600;">${safePercent}</span>`, |
| 129 | '</div>', |
| 130 | '</div>', |
| 131 | ].join(''); |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * Default tooltip formatter for candlestick series in item mode. |
no test coverage detected