Hello, I have a feeling that customJSHover is not being called on my jupyter notebook leading to ‘???’ or ‘Nan’ when hovering. As a quick example, I took the simple mercator example that uses customJSHover to give latitude and longitude
from bokeh.io import curdoc
from bokeh.models import HoverTool, CustomJSHover
from bokeh.plotting import figure
from bokeh.tile_providers import CARTODBPOSITRON, get_provider
# range bounds supplied in web mercator coordinates
p = figure(x_range=(-2000000, 6000000), y_range=(-1000000, 7000000),
x_axis_type="mercator", y_axis_type="mercator")
p.add_tile(get_provider(CARTODBPOSITRON))
p.circle(x=[0, 2000000, 4000000], y=[4000000, 2000000, 0], size=30)
code = """
var projections = require("core/util/projections");
var x = special_vars.x
var y = special_vars.y
var coords = projections.wgs84_mercator.inverse([x, y])
return coords[%d].toFixed(2)
"""
p.add_tools(HoverTool(
tooltips=[
( 'lon', '@x{custom}' ),
( 'lat', '@y{custom}' ),
],
formatters={
'x' : CustomJSHover(code=code % 0),
'y' : CustomJSHover(code=code % 1),
}
))
show(p)
This is the code I ran but when I hover its shows the x and y values of the circles, so the values are 2000000 or 4000000. I believe it is not calling customJSHover and instead just grabbing the x and y values. If I change the names of the formatters to not be x or y then hovering just shows ‘???’. I don’t know what I am doing wrong.
If it helps my jupyter version is 4.4.0