Skip to content

Commit

Permalink
Ensure datetime values are displayed as slider
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Jan 17, 2019
1 parent 9a6a630 commit 47ec0a2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions holoviews/plotting/widgets/__init__.py
Expand Up @@ -10,7 +10,7 @@
from ...core.ndmapping import item_check
from ...core.util import (
dimension_sanitizer, bytes_to_unicode, unique_iterator, unicode,
isnumeric, cross_index, wrap_tuple_streams, drop_streams
isnumeric, cross_index, wrap_tuple_streams, drop_streams, datetime_types
)
from ...core.traversal import hierarchical

Expand Down Expand Up @@ -362,9 +362,11 @@ def _get_static_widget(cls, idx, dim, mock_obj, hierarchy, init_dim_vals):
else:
next_vals = {}

if isinstance(values[0], np.datetime64):
if isinstance(values[0], datetime_types):
values = sorted(values)
dim_vals = [str(v.astype('datetime64[ns]')) for v in values]
dim_vals = [str(v.astype('datetime64[ns]'))
if isinstance(v, np.datetime64) else str(v)
for v in values]
widget_type = 'slider'
elif isnumeric(values[0]):
values = sorted(values)
Expand Down Expand Up @@ -405,7 +407,7 @@ def _get_static_widget(cls, idx, dim, mock_obj, hierarchy, init_dim_vals):
def _get_dynamic_widget(cls, idx, dim):
step = 1
if dim.values:
if all(isnumeric(v) for v in dim.values):
if all(isnumeric(v) or isinstance(v, datetime_types) for v in dim.values):
# Widgets currently detect dynamic mode by type
# this value representation is now redundant
# and should be removed in a refactor
Expand Down

0 comments on commit 47ec0a2

Please sign in to comment.