Skip to content

Commit

Permalink
Improved formatting of the PointerXYCallback JS code
Browse files Browse the repository at this point in the history
  • Loading branch information
jlstevens committed May 15, 2017
1 parent 2c03724 commit 689b312
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions holoviews/plotting/bokeh/callbacks.py
Expand Up @@ -520,8 +520,19 @@ class PointerXYCallback(Callback):
attributes = {'x': 'cb_obj.x', 'y': 'cb_obj.y'}
models = ['plot', 'x_range', 'y_range']
on_events = ['mousemove']
code = ("if (x_range.type.endsWith('Range1d')) { if (cb_obj.x < x_range.start) { data['x'] = x_range.start } else if (cb_obj.x > x_range.end) { data['x'] = x_range.end }}; "
+ "if (y_range.type.endsWith('Range1d')) { if (cb_obj.y < y_range.start) { data['y'] = y_range.start } else if (cb_obj.y > y_range.end) { data['y'] = y_range.end }}")
# Clip x and y values to available axis range
code = """
if (x_range.type.endsWith('Range1d')) {
if (cb_obj.x < x_range.start) {
data['x'] = x_range.start }
else if (cb_obj.x > x_range.end) {
data['x'] = x_range.end }}
if (y_range.type.endsWith('Range1d')) {
if (cb_obj.y < y_range.start) {
data['y'] = y_range.start }
else if (cb_obj.y > y_range.end) {
data['y'] = y_range.end }}
"""


class PointerXCallback(PointerXYCallback):
Expand Down

0 comments on commit 689b312

Please sign in to comment.