Add attributes to customize hover text font
See original GitHub issueThe font attribute doesn’t affect the text in the “hoverlayer” div. At the moment, it doesn’t look like there’s a way to specify that hover text font family.
Here’s a minimal example. The font for the axis labels gets changed, but not for the hover text.
<html>
<body>
<div id="plotly-div"></div>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<script>
var trace1 = { x: [0, 1], y: [4, 5] };
var trace2 = { x: [0, 1], y: [4, 5] };
var data = [trace1, trace2];
var layout = { "font": { "family": "Comic Sans MS" } };
Plotly.plot('plotly-div', data, layout);
</script>
</body>
</html>
Note: I used Comic Sans MS because it’s obvious, not because I actually want it in my chart 😃
Semi-related: The “font” property is mislabeled as “textfont” in the docs). “textfont” doesn’t appear to do anything.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:3
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Hover text and formatting in Python - Plotly
Hover label text and colors default to trace colors in hover modes other than unified , and can be globally set via the...
Read more >How to create hover text using HTML and CSS
There are two ways you can create a hover text for your HTML elements: ... Create hover text by adding the title attribute....
Read more >Use Hover Text to see enlarged text for items you select on ...
Use Hover Text to see enlarged text for items you select on Apple TV. Turn on Hover Text to see magnified text for...
Read more >Change font-family of mouse-over text - Stack Overflow
As far as I know, there is no way to customize the basic title element. You can try using different tooltip libraies. Seriously,...
Read more >hover - CSS: Cascading Style Sheets - MDN Web Docs
It is generally triggered when the user hovers over an element with the cursor (mouse pointer). Try it. CSS Demo: :hover. Reset. HTML...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@mheilman you could hook on a hover event handler (example).
Something like
But, yeah, there’s no way customize the font of the hover labels in the plot API at the moment.
I’m renaming this issue as a feature request.
Ah, OK, thanks for the clarification on
textfont
.It’d be nice to be able to set the hover text because I don’t think it’s possible now to have a consistent font in a scatter plot other than with the default font. I think CSS would just get overridden because the font is set explicitly in the tag using the
style
attribute, and one can’t edit thatstyle
attribute with, e.g.,querySelectorAll(".hovertext text").forEach(...)
because those text elements are only added when the user hovers over them.I could be missing something, though. Maybe there’s some way to change the mouse over event, but that seems complicated.
Thanks.