Repository: bokeh/bokeh

Issue:
[FEATURE]add scientific notation to supported number formats
I am using RangeSlider and have examples with very small numbers (eg 10^-7 or smaller). The displayed limits on the slider show as 0.

 I am using bokeh 1.2.

It would be great if you could add scientific notation as a supported format, as for NumeralTickFormatter. I could imagine "0E[.]000" to specify it.

Thanks,

Richard
[FEATURE]add scientific notation to supported number formats
I am using RangeSlider and have examples with very small numbers (eg 10^-7 or smaller). The displayed limits on the slider show as 0.

 I am using bokeh 1.2.

It would be great if you could add scientific notation as a supported format, as for NumeralTickFormatter. I could imagine "0E[.]000" to specify it.

Thanks,

Richard


Discussion:

Resolving patch:
diff --git a/bokeh/models/widgets/sliders.py b/bokeh/models/widgets/sliders.py
--- a/bokeh/models/widgets/sliders.py
+++ b/bokeh/models/widgets/sliders.py
@@ -28,8 +28,10 @@
     Bool,
     Color,
     Datetime,
+    Either,
     Enum,
     Float,
+    Instance,
     Int,
     Override,
     String,
@@ -37,6 +39,7 @@
 )
 from ...core.validation import error
 from ...core.validation.errors import EQUAL_SLIDER_START_END
+from ..formatters import TickFormatter
 from .widget import Widget
 
 #-----------------------------------------------------------------------------
@@ -63,6 +66,7 @@ def __init__(self, **kwargs):
         if 'start' in kwargs and 'end' in kwargs:
             if kwargs['start'] == kwargs['end']:
                 raise ValueError("Slider 'start' and 'end' cannot be equal.")
+
         super().__init__(**kwargs)
 
     title = String(default="", help="""
@@ -73,7 +77,7 @@ def __init__(self, **kwargs):
     Whether or not show slider's value.
     """)
 
-    format = String(help="""
+    format = Either(String, Instance(TickFormatter), help="""
     """)
 
     direction = Enum("ltr", "rtl", help="""


Test patch:
diff --git a/tests/integration/widgets/test_range_slider.py b/tests/integration/widgets/test_range_slider.py
--- a/tests/integration/widgets/test_range_slider.py
+++ b/tests/integration/widgets/test_range_slider.py
@@ -35,6 +35,7 @@
     Range1d,
     RangeSlider,
 )
+from bokeh.models.formatters import BasicTickFormatter
 
 #-----------------------------------------------------------------------------
 # Tests
@@ -94,6 +95,20 @@ def test_displays_title(self, bokeh_model_page) -> None:
 
         assert page.has_no_console_errors()
 
+    def test_displays_title_scientific(self, bokeh_model_page) -> None:
+        slider = RangeSlider(start=0, end=10e-6, step=1e-6, value=(1e-6, 8e-6), title="bar",
+            format=BasicTickFormatter(precision=2), css_classes=["foo"], width=300)
+
+        page = bokeh_model_page(slider)
+
+        el = page.driver.find_element_by_css_selector('.foo')
+        assert len(el.find_elements_by_css_selector('div.bk-input-group > div')) == 2
+
+        assert get_title_text(page.driver, ".foo") == "bar: 1.00e-6 .. 8.00e-6"
+        assert get_title_value(page.driver, ".foo") == "1.00e-6 .. 8.00e-6"
+
+        assert page.has_no_console_errors()
+
     def test_title_updates(self, bokeh_model_page) -> None:
         slider = RangeSlider(start=0, end=10, value=(1, 9), title="bar", css_classes=["foo"], width=300)