Fixed PointerXY inverted axis bug
@@ -536,18 +536,33 @@ class PointerXYCallback(Callback):
extra_models= ['x_range', 'y_range']
on_events = ['mousemove']
+
# 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 }}
+ xstart = x_range.start;
+ xend = x_range.end;
+ if (xstart > xend) {
+ [xstart, xend] = [xend, xstart]
+ }
+ if (cb_obj.x < xstart) {
+ data['x'] = xstart;
+ } else if (cb_obj.x > xend) {
+ data['x'] = xend;
+ }
+ }
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 }}
+ ystart = y_range.start;
+ yend = y_range.end;
+ if (ystart > yend) {
+ [ystart, yend] = [yend, ystart]
+ }
+ if (cb_obj.y < ystart) {
+ data['y'] = ystart;
+ } else if (cb_obj.y > yend) {
+ data['y'] = yend;
+ }
+ }
"""
def _process_msg(self, msg):
@@ -576,10 +591,17 @@ class PointerXCallback(PointerXYCallback):
extra_models= ['x_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 }}
+ xstart = x_range.start;
+ xend = x_range.end;
+ if (xstart > xend) {
+ [xstart, xend] = [xend, xstart]
+ }
+ if (cb_obj.x < xstart) {
+ data['x'] = xstart;
+ } else if (cb_obj.x > xend) {
+ data['x'] = xend;
+ }
+ }
"""
class PointerYCallback(PointerXYCallback):
@@ -591,10 +613,17 @@ class PointerYCallback(PointerXYCallback):
extra_models= ['y_range']
code = """
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 }}
+ ystart = y_range.start;
+ yend = y_range.end;
+ if (ystart > yend) {
+ [ystart, yend] = [yend, ystart]
+ }
+ if (cb_obj.y < ystart) {
+ data['y'] = ystart;
+ } else if (cb_obj.y > yend) {
+ data['y'] = yend;
+ }
+ }
"""
class DrawCallback(PointerXYCallback):
