Repository: bokeh/bokeh

Issue:
Expose the wheel zoom speed in Python
The sensitivity of the wheel zoom cannot be configured on the Python side. However, there is a `speed` property which can be set on the JS side. It would be better to expose this property to the Python side too.

Expose the wheel zoom speed in Python
The sensitivity of the wheel zoom cannot be configured on the Python side. However, there is a `speed` property which can be set on the JS side. It would be better to expose this property to the Python side too.



Discussion:
@liuyxpp we are actually in the middle of a big clean-up to ensure that the properties on the python and JS side match each other. 

@havocp WheelZoomTool has a default for `speed` on the JS side (https://github.com/bokeh/bokeh/blob/master/bokehjs/src/coffee/tool/gestures/wheel_zoom_tool.coffee#L119) but not a python property.

However running the test in #3099 doesn't pick up this discrepancy. Thoughts?

Maybe the test only picks up differences in defaults not when there's missing properties?

@birdsarah maybe https://github.com/bokeh/bokeh/blob/master/bokehjs/src/coffee/tool/gestures/wheel_zoom_tool.coffee#L113

great spot @bryevdv, do you know why that would be?

Why that line exists? @havoc added that to get things working at all. Currently the client models add all kind of new attributes with abandon and most of them should not get serialized back to the server. But a few like this one should be, but were just overlooked. We should have been more careful in the first place and made client only "viewmodel" objects to store any new, extra, "not intended to be serialized" data, and and kept the main models pure and 1-1 in sync with Python (no extra attrs added). We still should do this some day. 

> On Nov 15, 2015, at 00:16, Sarah Bird notifications@github.com wrote:
> 
> great spot @bryevdv, do you know why that would be?
> 
> —
> Reply to this email directly or view it on GitHub.

Python would raise an exception at one point if it saw an unknown property... now it just warns. So I was having to mark tons of props as nonserializable. It sounds like the better fix here was to simply add the prop to Python.

thanks for the background @havocp and @bryevdv still learning how the all the pieces of the properties mechanism works.

We can certainly expose the speed, but unless we can also find a way to make a given speed somewhat uniform across browsers I am dubious of the utility. But changing to `feature` in any case. 

Reopening because the PR was reverted by https://github.com/bokeh/bokeh/pull/4831

@liuyxpp we are actually in the middle of a big clean-up to ensure that the properties on the python and JS side match each other. 

@havocp WheelZoomTool has a default for `speed` on the JS side (https://github.com/bokeh/bokeh/blob/master/bokehjs/src/coffee/tool/gestures/wheel_zoom_tool.coffee#L119) but not a python property.

However running the test in #3099 doesn't pick up this discrepancy. Thoughts?

Maybe the test only picks up differences in defaults not when there's missing properties?

@birdsarah maybe https://github.com/bokeh/bokeh/blob/master/bokehjs/src/coffee/tool/gestures/wheel_zoom_tool.coffee#L113

great spot @bryevdv, do you know why that would be?

Why that line exists? @havoc added that to get things working at all. Currently the client models add all kind of new attributes with abandon and most of them should not get serialized back to the server. But a few like this one should be, but were just overlooked. We should have been more careful in the first place and made client only "viewmodel" objects to store any new, extra, "not intended to be serialized" data, and and kept the main models pure and 1-1 in sync with Python (no extra attrs added). We still should do this some day. 

> On Nov 15, 2015, at 00:16, Sarah Bird notifications@github.com wrote:
> 
> great spot @bryevdv, do you know why that would be?
> 
> —
> Reply to this email directly or view it on GitHub.

Python would raise an exception at one point if it saw an unknown property... now it just warns. So I was having to mark tons of props as nonserializable. It sounds like the better fix here was to simply add the prop to Python.

thanks for the background @havocp and @bryevdv still learning how the all the pieces of the properties mechanism works.

We can certainly expose the speed, but unless we can also find a way to make a given speed somewhat uniform across browsers I am dubious of the utility. But changing to `feature` in any case. 

Reopening because the PR was reverted by https://github.com/bokeh/bokeh/pull/4831


Resolving patch:
diff --git a/bokeh/models/tools.py b/bokeh/models/tools.py
--- a/bokeh/models/tools.py
+++ b/bokeh/models/tools.py
@@ -224,6 +224,15 @@ class WheelZoomTool(Scroll):
     zoom out more smoothly, at the cost of losing the focus position.
     """)
 
+    zoom_on_axis = Bool(default=True, help="""
+    Whether scrolling on an axis (outside the central plot area) should
+    zoom that dimension.
+    """)
+
+    speed = Float(default=1/600, help="""
+    Speed at which the wheel zooms. Default is 1/600. Optimal range is between
+    0.001 and 0.09. High values will be clipped. Speed may very between browsers.
+    """)
 
 class SaveTool(Action):
     ''' *toolbar icon*: |save_icon|
diff --git a/examples/models/file/dateaxis.py b/examples/models/file/dateaxis.py
--- a/examples/models/file/dateaxis.py
+++ b/examples/models/file/dateaxis.py
@@ -36,7 +36,7 @@
 plot.add_layout(DatetimeAxis(), 'below')
 plot.add_layout(DatetimeAxis(), 'left')
 
-plot.add_tools(PanTool(), WheelZoomTool())
+plot.add_tools(PanTool(), WheelZoomTool(zoom_on_axis=False, speed=1/5000.))
 
 doc = Document()
 doc.add_root(plot)


Test patch: