Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed conversion of Pandas Timestamp to integer for Bokeh #3186

Merged
merged 2 commits into from
Nov 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions holoviews/plotting/bokeh/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions holoviews/plotting/bokeh/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down