web/views/plots.py
changeset 2009 b1e2b9e4c809
parent 1991 8a9d8f1ee100
child 2161 200481e7b156
equal deleted inserted replaced
2008:640a59bf5c68 2009:b1e2b9e4c809
    13 from simplejson import dumps
    13 from simplejson import dumps
    14 
    14 
    15 from logilab.common import flatten
    15 from logilab.common import flatten
    16 from logilab.mtconverter import html_escape
    16 from logilab.mtconverter import html_escape
    17 
    17 
    18 from cubicweb.utils import make_uid, UStringIO
    18 from cubicweb.utils import make_uid, UStringIO, datetime2ticks
    19 from cubicweb.vregistry import objectify_selector
    19 from cubicweb.vregistry import objectify_selector
    20 from cubicweb.web.views import baseviews
    20 from cubicweb.web.views import baseviews
    21 
    21 
    22 @objectify_selector
    22 @objectify_selector
    23 def at_least_two_columns(cls, req, rset, *args, **kwargs):
    23 def at_least_two_columns(cls, req, rset, *args, **kwargs):
    57     for x, y in zip(abscissa, plot):
    57     for x, y in zip(abscissa, plot):
    58         if x is None or y is None:
    58         if x is None or y is None:
    59             continue
    59             continue
    60         filtered.append( (x, y) )
    60         filtered.append( (x, y) )
    61     return sorted(filtered)
    61     return sorted(filtered)
    62 
       
    63 def datetime2ticks(date):
       
    64     return time.mktime(date.timetuple()) * 1000
       
    65 
    62 
    66 class PlotWidget(object):
    63 class PlotWidget(object):
    67     # XXX refactor with cubicweb.web.views.htmlwidgets.HtmlWidget
    64     # XXX refactor with cubicweb.web.views.htmlwidgets.HtmlWidget
    68     def _initialize_stream(self, w=None):
    65     def _initialize_stream(self, w=None):
    69         if w:
    66         if w: