@@ -267,18 +267,6 @@ def selectable_axes_plot(
267
267
** kwargs ,
268
268
)
269
269
270
- if tools is None :
271
- base_tooltips = [("File:" , "@filename" ), (x_axis_label , "$x{0.00}" )]
272
-
273
- if "intensity" in y_label .lower ():
274
- original_col = f"{ y_label } _original"
275
- base_tooltips .append ((y_axis_label , f"@{{{ original_col } }}{{0.00}}" ))
276
- else :
277
- base_tooltips .append ((y_axis_label , "$y{0.00}" ))
278
-
279
- coordinate_hover = HoverTool (tooltips = base_tooltips , mode = "mouse" )
280
- p .add_tools (coordinate_hover )
281
-
282
270
p .toolbar .logo = "grey"
283
271
284
272
if tools :
@@ -312,6 +300,7 @@ def selectable_axes_plot(
312
300
labels = [shrink_label (label ) for label in original_labels ]
313
301
314
302
plot_columns = []
303
+ hover_tools = []
315
304
316
305
for ind , df_ in enumerate (df ):
317
306
if skip_plot :
@@ -330,6 +319,17 @@ def selectable_axes_plot(
330
319
331
320
source = ColumnDataSource (df_with_filename )
332
321
322
+ current_tooltips = [("File:" , "@filename" ), (x_axis_label , "$x{0.00}" )]
323
+
324
+ if "intensity" in y_label .lower ():
325
+ original_col = f"{ y_label } _original"
326
+ if original_col in source .data :
327
+ current_tooltips .append ((y_axis_label , f"@{{{ original_col } }}{{0.00}}" ))
328
+ else :
329
+ current_tooltips .append ((y_axis_label , f"@{{{ y_default } }}" ))
330
+ else :
331
+ current_tooltips .append ((y_axis_label , f"@{{{ y_default } }}{{0.00}}" ))
332
+
333
333
if color_options :
334
334
color = {"field" : color_options [0 ], "transform" : color_mapper }
335
335
line_color = "black"
@@ -381,6 +381,14 @@ def selectable_axes_plot(
381
381
else None
382
382
)
383
383
384
+ line_hover = None
385
+ if lines :
386
+ line_hover = HoverTool (
387
+ tooltips = current_tooltips , mode = "mouse" , renderers = [lines ], line_policy = "nearest"
388
+ )
389
+ p .add_tools (line_hover )
390
+ hover_tools .append (line_hover )
391
+
384
392
if y_aux :
385
393
for y in y_aux :
386
394
aux_lines = ( # noqa
@@ -403,7 +411,7 @@ def selectable_axes_plot(
403
411
line1 = lines ,
404
412
source = source ,
405
413
xaxis = p .xaxis [0 ],
406
- hover_tool = coordinate_hover ,
414
+ hover_tool = line_hover ,
407
415
),
408
416
code = SELECTABLE_CALLBACK_x ,
409
417
)
@@ -416,7 +424,7 @@ def selectable_axes_plot(
416
424
line1 = lines ,
417
425
source = source ,
418
426
yaxis = p .yaxis [0 ],
419
- hover_tool = coordinate_hover ,
427
+ hover_tool = line_hover ,
420
428
),
421
429
code = SELECTABLE_CALLBACK_y ,
422
430
)
0 commit comments