diff --git a/holoviews/plotting/bokeh/chart.py b/holoviews/plotting/bokeh/chart.py index 0bbd705ada..17ef699835 100644 --- a/holoviews/plotting/bokeh/chart.py +++ b/holoviews/plotting/bokeh/chart.py @@ -922,7 +922,8 @@ def get_data(self, element, ranges, style): is_dt = isdatetime(xvals) if is_dt or xvals.dtype.kind not in 'OU': xdiff = np.abs(np.diff(xvals)) - if len(np.unique(xdiff)) == 1 and xdiff[0] == 0: + diff_size = len(np.unique(xdiff)) + if diff_size == 0 or (diff_size == 1 and xdiff[0] == 0): xdiff = 1 if is_dt: width *= xdiff.astype('timedelta64[ms]').astype(np.int64) diff --git a/holoviews/tests/plotting/bokeh/test_barplot.py b/holoviews/tests/plotting/bokeh/test_barplot.py index fd16dbd7bb..46345442f3 100644 --- a/holoviews/tests/plotting/bokeh/test_barplot.py +++ b/holoviews/tests/plotting/bokeh/test_barplot.py @@ -37,6 +37,14 @@ def test_empty_bars(self): for v in source.data.values(): self.assertEqual(len(v), 0) + def test_bars_single_value(self): + df = pd.DataFrame({"time": [1], "value": [-1]}) + bars = Bars(df) + plot = bokeh_renderer.get_plot(bars) + source = plot.handles['source'] + assert source.data['time'], np.array([1]) + assert source.data['value'], np.array([-1]) + def test_bars_grouped_categories(self): bars = Bars([('A', 0, 1), ('A', 1, -1), ('B', 0, 2)], kdims=['Index', 'Category'], vdims=['Value'])