Hi @Bryan,
Yeah I’ve tried the numeral formatting methods like @source_id{0} and the printf formatting methods like @source_id{%d} (and %i, %u, %s) but they all lose their accuracy?
I can get around the issue by type casting the long int into a string before creating the ColumnDataSource for now but it’s not an ideal solution.
I did some playing and found when an int has a length > 17, it always rounds to the 17th digit regardless of how it’s being formatted (bar type casting as a string before hand); test code attached for clarity (hopefully).
import numpy as np
from bokeh.plotting import figure, show
from bokeh.models import HoverTool, ColumnDataSource
source_id = np.int64(np.random.randn(100) * 12345 + 123456789876543210) # 18 digit length ids
# some data
x = np.linspace(1, 100, 100)
y = 2 * x + np.random.randn(100) * 3
# create source for plotting
source = ColumnDataSource(dict(x=x, y=y, source_id=source_id))
print(source.to_df()[:10]) # print first 10 values (displays correctly the ids)
# plotting
p = figure(title='Hover Tool Test', tools='', x_axis_label='x', y_axis_label='y', sizing_mode='stretch_width')
p.circle(source=source, x='x', y='y')
p.add_tools(HoverTool(tooltips=[('source_id', '@source_id')], formatters={'source_id': 'numeral'}))
show(p)
Cheers,
Will