Repository: bokeh/bokeh

Issue:
Charts/Timeseries (STEP) chart is broken on Windows
Renders non sense lines

Charts/Timeseries (STEP) chart is broken on Windows
Renders non sense lines



Discussion:
Moving to `0.12` to at least re-evaluate prior to release

Still appears broken (FF and Chrome):

<img width="642" alt="screen shot 2016-04-30 at 10 42 13 am" src="https://cloud.githubusercontent.com/assets/1078448/14937016/3a569168-0ec0-11e6-9e20-f23fdb641de6.png">

Confirmed. For reference, the plot should look more like the first (Line) plot of the same example.

The problem is in the generation: if I create the plot on Windows, it looks bad everywhere, even on Linux. Creating the same on Linux and viewing on Windows works fine.

Moving to `0.12` to at least re-evaluate prior to release

Still appears broken (FF and Chrome):

<img width="642" alt="screen shot 2016-04-30 at 10 42 13 am" src="https://cloud.githubusercontent.com/assets/1078448/14937016/3a569168-0ec0-11e6-9e20-f23fdb641de6.png">

Confirmed. For reference, the plot should look more like the first (Line) plot of the same example.

The problem is in the generation: if I create the plot on Windows, it looks bad everywhere, even on Linux. Creating the same on Linux and viewing on Windows works fine.


Resolving patch:
diff --git a/bokeh/charts/builders/step_builder.py b/bokeh/charts/builders/step_builder.py
--- a/bokeh/charts/builders/step_builder.py
+++ b/bokeh/charts/builders/step_builder.py
@@ -1,7 +1,7 @@
 """This is the Bokeh charts interface. It gives you a high level API to build
 complex plot is a simple way.
 
-This is the Line class which lets you build your Line charts just
+This is the Step class which lets you build your Step charts just
 passing the arguments to the Chart class and calling the proper functions.
 """
 # -----------------------------------------------------------------------------
diff --git a/bokeh/charts/glyphs.py b/bokeh/charts/glyphs.py
--- a/bokeh/charts/glyphs.py
+++ b/bokeh/charts/glyphs.py
@@ -440,11 +440,13 @@ def build_source(self):
         elif self.y is None:
             y = self.x.index
 
-        xs = np.empty(2*len(x)-1, dtype=np.int)
+        dtype = x.dtype if hasattr(x, 'dtype') else np.int
+        xs = np.empty(2*len(x)-1, dtype=dtype)
         xs[::2] = x[:]
         xs[1::2] = x[1:]
 
-        ys = np.empty(2*len(y)-1)
+        dtype = y.dtype if hasattr(y, 'dtype') else np.float64
+        ys = np.empty(2*len(y)-1, dtype=dtype)
         ys[::2] = y[:]
         ys[1::2] = y[:-1]
 


Test patch:
diff --git a/bokeh/charts/tests/test_comp_glyphs.py b/bokeh/charts/tests/test_comp_glyphs.py
--- a/bokeh/charts/tests/test_comp_glyphs.py
+++ b/bokeh/charts/tests/test_comp_glyphs.py
@@ -70,6 +70,26 @@ def test_comp_glyph_array_input(test_data):
     assert cg.data['values'] is not None
 
 
+def test_step_glyph():
+    xx = [-2, 0, 1, 3, 4, 5, 6, 9]
+    dates = np.array(['2016-05-%02i' % i for i in range(1, 9)], dtype=np.datetime64)
+    values = [1, 2, 3, 2, 1, 5, 4, 5]
+
+    # Test with integer x
+    g = StepGlyph(x=xx, y=values)
+    data = g.renderers[0].data_source.data
+    for i in range(0, len(xx)-1):
+        assert data['x_values'][i*2+0] == xx[i+0]
+        assert data['x_values'][i*2+1] == xx[i+1]
+
+    # Test with dates (#3616)
+    g = StepGlyph(x=dates, y=values)
+    data = g.renderers[0].data_source.data
+    for i in range(0, len(xx)-1):
+        assert data['x_values'][i*2+0] == dates[i+0]
+        assert data['x_values'][i*2+1] == dates[i+1]
+
+
 # operations
 
 def test_bar_stacking():