简体   繁体   English

散景悬停工具提示文本颜色

[英]Bokeh Hover ToolTip Text Color

I am running a bokeh app and in the templates the background color is black and text color is white.我正在运行一个散景应用程序,在模板中,背景颜色为黑色,文本颜色为白色。 This causes my tooltips text color to be white and is not readable on hover.这导致我的工具提示文本颜色为白色并且在悬停时不可读。

Code -代码 -

x = ['CPC', 'AID CHECKS']
counts = [208, 28]
print (x)
print (counts)

source = ColumnDataSource(data=dict(x=x, counts=counts))

p = figure(x_range=FactorRange(*x), plot_height=600, plot_width=990, title="NPS Locations by Security Checks")

p.xaxis.axis_label_text_font_size = "5pt"
p.xaxis.axis_label_text_font_style='bold'

p.vbar(x='x', top='counts', width=0.9, source=source)

p.add_tools(HoverTool(tooltips=[("LOCATION", "@x"), ("TOTAL", "@counts")]))


p.y_range.start = 0
p.x_range.range_padding = 0.1
p.xaxis.major_label_orientation = 1
p.xgrid.grid_line_color = None

show(p)

enter image description here在此处输入图片说明

Bokeh tooltip elements have bk-tooltip class.散景工具提示元素具有bk-tooltip类。 You can use it to override the font color with a more specific CSS selector.您可以使用它通过更具体的 CSS 选择器覆盖字体颜色。

/* Assuming you have something like this in your template, */
body {
    color: white;
}

/* this should do the trick. */
div.bk-tooltip {
    color: black;
}

This has been answered before.这个之前已经回答过了。 using .html Also there is the bokeh documentation on it, which I would highly recommend.使用 .html还有关于它的散景文档,我强烈推荐。 At first it will seem a bit overwhelming, though once you get to understand their philosophy, the documentation will be extremely helpful.乍一看似乎有点不知所措,但一旦您了解了他们的理念,文档将非常有帮助。 link to the user guide 用户指南链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM