diff --git a/anki/graphs.py b/anki/graphs.py index 2f16d3d8f..d5eb487d9 100644 --- a/anki/graphs.py +++ b/anki/graphs.py @@ -3,6 +3,7 @@ # License: GNU GPL, version 3 or later; http://www.gnu.org/copyleft/gpl.html import os, sys, time, datetime, simplejson +from anki.utils import fmtTimeSpan from anki.lang import _ import anki.js @@ -23,6 +24,8 @@ class Graphs(object): self._stats = None self.selective = selective self.type = 0 + self.width = 600 + self.height = 200 def report(self, type=0): # 0=days, 1=weeks, 2=months @@ -122,9 +125,7 @@ group by day order by day""" % (self._limit(), lim), (1, colLearn, _("Learn")), (5, colCram, _("Cram")))) txt = plot("reps", reptitle, repdata, ylabel=_("Answers"), - info=_("""\ -The number of cards you have answered. Answering the same card twice \ -counts as two answers.""")) + info=_("The number of questions you have answered.")) # time (timdata, timsum) = self._splitRepData(d, ( (8, colMature, _("Mature")), @@ -136,10 +137,13 @@ counts as two answers.""")) t = _("Minutes") else: t = _("Hours") - txt += plot("time", timetitle, timdata, ylabel=t, info=_("""\ -Time spent answering cards.""")) + txt += plot("time", timetitle, timdata, ylabel=t, info=_( + "The time taken to answer the questions.")) return txt + def _ansInfo(self, data): + return "" + def _splitRepData(self, data, spec): sep = {} tot = 0 @@ -198,7 +202,7 @@ group by day order by day""" % lim, ###################################################################### def ivlGraph(self): - (ivls, all, avg) = self._ivls() + (ivls, all, avg, max) = self._ivls() tot = 0 totd = [] if not ivls or not all: @@ -212,9 +216,9 @@ group by day order by day""" % lim, bars={'show': False}, lines=dict(show=True), stack=False) ], conf=dict( yaxes=[dict(), dict(position="right", max=105)]), - info=_("""\ -Intervals in the review queue. New cards and cards in (re)learning \ -are not included.""") + "
" + (_("Average interval: %d") % avg))
+ info=_("Delays until reviews are shown again."))
+ txt += _("Average interval: %s") % fmtTimeSpan(avg*86400)
+ txt += "
" + _("Longest interval: %s") % fmtTimeSpan(max*86400)
return txt
def _ivls(self):
@@ -224,15 +228,14 @@ are not included.""") + "
" + (_("Average interval: %d") % avg)) chunk = 7; lim = " and grp <= 52" else: chunk = 30; lim = "" - return (self.deck.db.all(""" + data = [self.deck.db.all(""" select ivl / :chunk as grp, count() from cards where queue = 2 %s %s group by grp -order by grp""" % (self._limit(), lim), chunk=chunk), - self.deck.db.scalar(""" -select count() from cards where queue = 2 %s""" % self._limit()), - self.deck.db.scalar(""" -select avg(ivl) from cards where queue = 2 %s""" % self._limit())) +order by grp""" % (self._limit(), lim), chunk=chunk)] + return data + list(self.deck.db.first(""" +select count(), avg(ivl), max(ivl) from cards where queue = 2 %s""" % + self._limit())) # Intervals ###################################################################### @@ -247,23 +250,27 @@ select avg(ivl) from cards where queue = 2 %s""" % self._limit())) (_("Unseen"), colUnseen))): d.append(dict(data=div[c], label=t, color=col)) # text data - info = [] - def line(a, b): - info.append("
" + self._line(i, _("Lowest ease factor"), "%d%%" % low) + self._line(i, _("Average ease factor"), "%d%%" % avg) + self._line(i, _("Highest ease factor"), "%d%%" % high) + info = "
" info += _('''\ A card's ease factor is the size of the next interval \ -when you answer "good"''') - txt = self._graph(id="cards", title=_("Cards"), data=d, - info=info, type="pie") +when you answer "good" on a review.''') + txt = "
%s | %s |
""" % self.width + + " | ".join(i) + + " |
%(ylab)s |
-
-- - | - - %(info)s + |
+
+
+
|