From 3b96a86e3cd6510349bd60b408674556e38465f9 Mon Sep 17 00:00:00 2001 From: Elliot Berman Date: Mon, 19 Nov 2018 13:08:33 -0500 Subject: [PATCH 1/2] Revert "Fixed bug in HLine/VLine datetime handling (#3075)" This reverts commit a17d01a574617711f540b6598ee1fdb69984f076. --- holoviews/plotting/bokeh/annotation.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/holoviews/plotting/bokeh/annotation.py b/holoviews/plotting/bokeh/annotation.py index a94490b4ba..80ac70fcea 100644 --- a/holoviews/plotting/bokeh/annotation.py +++ b/holoviews/plotting/bokeh/annotation.py @@ -14,13 +14,13 @@ arrow_end = {'->': NormalHead, '-[': OpenHead, '-|>': NormalHead, '-': None} -from ...core.util import dimension_sanitizer, basestring +from ...core.util import datetime_types, dimension_sanitizer, basestring from ...element import HLine from ..plot import GenericElementPlot from .element import (AnnotationPlot, CompositeElementPlot, ColorbarPlot, ElementPlot, text_properties, line_properties) from .plot import BokehPlot - +from .util import date_to_integer class TextPlot(ElementPlot, AnnotationPlot): @@ -131,6 +131,8 @@ def get_data(self, element, ranges, style): dim = 'width' if dim == 'height' else 'height' mapping['dimension'] = dim loc = element.data + if isinstance(loc, datetime_types): + loc = date_to_integer(loc) mapping['location'] = loc return (data, mapping, style) From 87a3d696759f2c38e851da1a68811bbd980dbde5 Mon Sep 17 00:00:00 2001 From: Elliot Berman Date: Mon, 19 Nov 2018 13:09:54 -0500 Subject: [PATCH 2/2] Use pandas.Timestamp.timestamp() to convert datetime to integer --- holoviews/plotting/bokeh/util.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/holoviews/plotting/bokeh/util.py b/holoviews/plotting/bokeh/util.py index f0e2768fec..22f5351f15 100644 --- a/holoviews/plotting/bokeh/util.py +++ b/holoviews/plotting/bokeh/util.py @@ -649,9 +649,9 @@ def date_to_integer(date): """ if isinstance(date, np.datetime64): date = dt64_to_dt(date) - elif pd and isinstance(date, pd.Timestamp): - date = date.to_pydatetime() - if isinstance(date, (dt.datetime, dt.date)): + if pd and isinstance(date, pd.Timestamp): + dt_int = date.timestamp()*1000 + elif isinstance(date, (dt.datetime, dt.date)): dt_int = time.mktime(date.timetuple())*1000 else: raise ValueError('Datetime type not recognized')