diff --git a/anki/graphs.py b/anki/graphs.py index 604b63cd6..f866d77d1 100644 --- a/anki/graphs.py +++ b/anki/graphs.py @@ -16,6 +16,7 @@ colCram = "#ff0" colIvl = "#077" colTime = "#770" colUnseen = "#000" +colSusp = "#ff0" class Graphs(object): @@ -31,7 +32,8 @@ class Graphs(object): # 0=days, 1=weeks, 2=months # period-dependent graphs self.type = type - txt = self.dueGraph() + txt = self.css + txt += self.dueGraph() txt += self.repsGraph() txt += self.ivlGraph() # other graphs @@ -39,6 +41,15 @@ class Graphs(object): txt += self.cardGraph() return "
%s
" % (anki.js.all, txt) + css = """ + +""" + # Due and cumulative due ###################################################################### @@ -314,7 +325,8 @@ order by thetype, ease""") for c, (t, col) in enumerate(( (_("Mature"), colMature), (_("Young+Learn"), colYoung), - (_("Unseen"), colUnseen))): + (_("Unseen"), colUnseen), + (_("Suspended"), colSusp))): d.append(dict(data=div[c], label=t, color=col)) # text data i = [] @@ -354,7 +366,8 @@ from cards where queue = 2 %s""" % self._limit()) select sum(case when queue=2 and ivl >= 21 then 1 else 0 end), -- mtr sum(case when queue=1 or (queue=2 and ivl < 21) then 1 else 0 end), -- yng/lrn -sum(case when queue=0 then 1 else 0 end) -- new +sum(case when queue=0 then 1 else 0 end), -- new +sum(case when queue=-1 then 1 else 0 end) -- susp %s from cards""" % self._limit()) @@ -364,7 +377,10 @@ from cards""" % self._limit()) def _graph(self, id, data, conf={}, type="bars", ylabel=_("Cards"), timeTicks=True): # display settings - conf['legend'] = {'container': "#%sLegend" % id, 'noColumns':10} + if type == "pie": + conf['legend'] = {'container': "#%sLegend" % id, 'noColumns':2} + else: + conf['legend'] = {'container': "#%sLegend" % id, 'noColumns':10} conf['series'] = dict(stack=True) if not 'yaxis' in conf: conf['yaxis'] = {} @@ -385,20 +401,19 @@ from cards""" % self._limit()) elif type == "fill": conf['series']['lines'] = dict(show=True, fill=True) elif type == "pie": - width /= 2 + width /= 2.3 height *= 1.5 ylabel = "" conf['series']['pie'] = dict( show=True, - radius=1, + radius=0.8, stroke=dict(color="#000", width=3), label=dict( show=True, - radius=1, #3/4.0, - background=dict( - opacity=1, - color='#000'))) - conf['legend'] = dict(show=False) + radius=1, + threshold=0.01)) + + #conf['legend'] = dict(show=False) return ( """ @@ -419,7 +434,7 @@ $(function () { } if (conf.series.pie) { conf.series.pie.label.formatter = function(label, series){ - return '
'+label+'
'+Math.round(series.percent)+'%%
'; + return '
'+''+label+'
'+Math.round(series.percent)+'%%
'; }; } $.plot($("#%(id)s"), %(data)s, conf); @@ -436,4 +451,4 @@ $(function () { return "" def _title(self, title, subtitle=""): - return '

%s

%s' % (title, subtitle) + return '

%s

%s' % (title, subtitle)