Skip to content

Commit 29200a1

Browse files
Render hover labels through MathJax when the whole label is one tex expression
Fixes #559. Hover labels unconditionally set data-notex, which blocks convertToTspans from ever handing them to MathJax, so a hover string like "$\alpha$" rendered as literal source instead of the typeset symbol. Axis titles and annotations already support this; hover never did because convertToTspans drops any text outside the $...$ delimiters, and most hover strings mix formatted values with literal text, so blanket-enabling it would silently lose content. This only lifts the restriction when the whole label is one tex expression (isPureTex), which convertToTspans can render without dropping anything, and applies it to every hover label surface: the main per-point label, the secondary trace-name label, the shared axis label, and the "unified hover" legend-based label. Enabling this exposes a second, previously moot problem: MathJax typesets asynchronously, so the label's box is sized from a degenerate placeholder measurement before the real content exists. hover.js now runs its existing (idempotent) sizing and overlap- avoidance pass a second time once typesetting finishes, and svg_text_utils gains repositionMathGroup to move the already-rendered math group to match, since convertToTspans only positions it once, at typeset time. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent f618df5 commit 29200a1

5 files changed

Lines changed: 582 additions & 236 deletions

File tree

draftlogs/PRNUMBER_fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fix hover labels ignoring MathJax for text that is a single tex expression [[#PRNUMBER](https://github.com/plotly/plotly.js/pull/PRNUMBER)]

0 commit comments

Comments
 (0)