Bokeh Hover ToolTip Text Color

问题描述 投票:0回答:1

我正在运行bokeh应用程序,并且在模板中背景颜色为黑色,文本颜色为白色。这导致我的工具提示文本颜色为白色,并且悬停时无法读取。

代码-

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

python bokeh
1个回答
0
投票

Bokeh工具提示元素具有bk-tooltip类。您可以使用它使用更特定的CSS选择器覆盖字体颜色。

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

/* this should do the trick. */
div.bk-tooltip {
    color: black;
}
© www.soinside.com 2019 - 2024. All rights reserved.