mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 07:22:23 -04:00
break reps graph into separate graphs; exclude cumulative line from stack
This commit is contained in:
parent
b9848c8cd9
commit
40706f3493
2 changed files with 35 additions and 18 deletions
|
@ -28,7 +28,9 @@ class Graphs(object):
|
||||||
txt = (self.dueGraph(0, 30, _("Due/Day")) +
|
txt = (self.dueGraph(0, 30, _("Due/Day")) +
|
||||||
self.dueGraph(0, 52, _("Due/Week"), chunk=7) +
|
self.dueGraph(0, 52, _("Due/Week"), chunk=7) +
|
||||||
self.dueGraph(0, None, _("Due/Month"), chunk=30) +
|
self.dueGraph(0, None, _("Due/Month"), chunk=30) +
|
||||||
self.repsGraph() +
|
self.repsGraph(30, _("Reviewed/Day")) +
|
||||||
|
self.repsGraph(52, _("Reviewed/Week"), chunk=7) +
|
||||||
|
self.repsGraph(None, _("Reviewed/Month"), chunk=30) +
|
||||||
self.timeGraph() +
|
self.timeGraph() +
|
||||||
self.ivlGraph() +
|
self.ivlGraph() +
|
||||||
self.easeGraph())
|
self.easeGraph())
|
||||||
|
@ -52,9 +54,9 @@ class Graphs(object):
|
||||||
dict(data=mtr, color=colMature, label=_("Mature")),
|
dict(data=mtr, color=colMature, label=_("Mature")),
|
||||||
dict(data=yng, color=colYoung, label=_("Young")),
|
dict(data=yng, color=colYoung, label=_("Young")),
|
||||||
dict(data=totd, color=colCum, label=_("Cumulative"), yaxis=2,
|
dict(data=totd, color=colCum, label=_("Cumulative"), yaxis=2,
|
||||||
bars={'show': False}, lines=dict(show=True))
|
bars={'show': False}, lines=dict(show=True), stack=False)
|
||||||
], conf=dict(
|
], conf=dict(
|
||||||
#xaxis=dict(tickDecimals=0),
|
xaxis=dict(tickDecimals=0),
|
||||||
yaxes=[dict(), dict(position="right")]))
|
yaxes=[dict(), dict(position="right")]))
|
||||||
return txt
|
return txt
|
||||||
|
|
||||||
|
@ -78,26 +80,37 @@ group by day order by day""" % (self._limit(), lim),
|
||||||
# Reps and time spent
|
# Reps and time spent
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
def repsGraph(self):
|
def repsGraph(self, days, title, chunk=1):
|
||||||
self._calcStats()
|
d = self._done(days, chunk)
|
||||||
lrn = []
|
lrn = []
|
||||||
yng = []
|
yng = []
|
||||||
mtr = []
|
mtr = []
|
||||||
lapse = []
|
lapse = []
|
||||||
cram = []
|
cram = []
|
||||||
for row in self._stats['done']:
|
tot = 0
|
||||||
|
totd = []
|
||||||
|
for row in d:
|
||||||
lrn.append((row[0], row[1]))
|
lrn.append((row[0], row[1]))
|
||||||
yng.append((row[0], row[2]))
|
yng.append((row[0], row[2]))
|
||||||
mtr.append((row[0], row[3]))
|
mtr.append((row[0], row[3]))
|
||||||
lapse.append((row[0], row[4]))
|
lapse.append((row[0], row[4]))
|
||||||
cram.append((row[0], row[5]))
|
cram.append((row[0], row[5]))
|
||||||
txt = self._graph(id="reps", title=_("Repetitions"), data=[
|
tot += row[1]+row[2]+row[3]+row[4]+row[5]
|
||||||
|
totd.append((row[0], tot))
|
||||||
|
conf = dict(
|
||||||
|
xaxis=dict(tickDecimals=0),
|
||||||
|
yaxes=[dict(), dict(position="right")])
|
||||||
|
if days is not None:
|
||||||
|
conf['xaxis']['min'] = -days
|
||||||
|
txt = self._graph(id=hash(title), title=title, data=[
|
||||||
dict(data=mtr, color=colMature, label=_("Mature")),
|
dict(data=mtr, color=colMature, label=_("Mature")),
|
||||||
dict(data=yng, color=colYoung, label=_("Young")),
|
dict(data=yng, color=colYoung, label=_("Young")),
|
||||||
dict(data=lapse, color=colRelearn, label=_("Relearning")),
|
dict(data=lapse, color=colRelearn, label=_("Relearning")),
|
||||||
dict(data=lrn, color=colLearn, label=_("Learning")),
|
dict(data=lrn, color=colLearn, label=_("Learning")),
|
||||||
dict(data=cram, color=colCram, label=_("Cramming")),
|
dict(data=cram, color=colCram, label=_("Cramming")),
|
||||||
])
|
dict(data=totd, color=colCum, label=_("Cumulative"), yaxis=2,
|
||||||
|
bars={'show': False}, lines=dict(show=True), stack=False)
|
||||||
|
], conf=conf)
|
||||||
return txt
|
return txt
|
||||||
|
|
||||||
def timeGraph(self):
|
def timeGraph(self):
|
||||||
|
@ -122,11 +135,15 @@ group by day order by day""" % (self._limit(), lim),
|
||||||
])
|
])
|
||||||
return txt
|
return txt
|
||||||
|
|
||||||
def _done(self):
|
def _done(self, num=7, chunk=1):
|
||||||
# without selective for now
|
# without selective for now
|
||||||
|
lim = ""
|
||||||
|
if num is not None:
|
||||||
|
lim += "where time > %d" % (
|
||||||
|
(self.deck.sched.dayCutoff-(num*chunk*86400))*1000)
|
||||||
return self.deck.db.all("""
|
return self.deck.db.all("""
|
||||||
select
|
select
|
||||||
cast((time/1000 - :cut) / 86400.0 as int)+1 as day,
|
(cast((time/1000 - :cut) / 86400.0 as int)+1)/:chunk as day,
|
||||||
sum(case when type = 0 then 1 else 0 end), -- lrn count
|
sum(case when type = 0 then 1 else 0 end), -- lrn count
|
||||||
sum(case when type = 1 and lastIvl < 21 then 1 else 0 end), -- yng count
|
sum(case when type = 1 and lastIvl < 21 then 1 else 0 end), -- yng count
|
||||||
sum(case when type = 1 and lastIvl >= 21 then 1 else 0 end), -- mtr count
|
sum(case when type = 1 and lastIvl >= 21 then 1 else 0 end), -- mtr count
|
||||||
|
@ -138,7 +155,10 @@ sum(case when type = 1 and lastIvl < 21 then taken/1000 else 0 end)/3600.0,
|
||||||
sum(case when type = 1 and lastIvl >= 21 then taken/1000 else 0 end)/3600.0,
|
sum(case when type = 1 and lastIvl >= 21 then taken/1000 else 0 end)/3600.0,
|
||||||
sum(case when type = 2 then taken/1000 else 0 end)/3600.0, -- lapse time
|
sum(case when type = 2 then taken/1000 else 0 end)/3600.0, -- lapse time
|
||||||
sum(case when type = 3 then taken/1000 else 0 end)/3600.0 -- cram time
|
sum(case when type = 3 then taken/1000 else 0 end)/3600.0 -- cram time
|
||||||
from revlog group by day order by day""", cut=self.deck.sched.dayCutoff)
|
from revlog %s
|
||||||
|
group by day order by day""" % lim,
|
||||||
|
cut=self.deck.sched.dayCutoff,
|
||||||
|
chunk=chunk)
|
||||||
|
|
||||||
# Intervals
|
# Intervals
|
||||||
######################################################################
|
######################################################################
|
||||||
|
@ -221,7 +241,9 @@ order by thetype, ease""")
|
||||||
"""
|
"""
|
||||||
<h1>%(title)s</h1>
|
<h1>%(title)s</h1>
|
||||||
<table width=%(tw)s>
|
<table width=%(tw)s>
|
||||||
<tr><td><div id="%(id)s" style="width:%(w)s; height:%(h)s;"></div></td>
|
<tr>
|
||||||
|
<td><div style="-webkit-transform: rotate(-90deg);-moz-transform: rotate(-90deg);">Cards</div></td>
|
||||||
|
<td><div id="%(id)s" style="width:%(w)s; height:%(h)s;"></div></td>
|
||||||
<td width=100 valign=top><br><div id=%(id)sLegend></div></td></tr></table>
|
<td width=100 valign=top><br><div id=%(id)sLegend></div></td></tr></table>
|
||||||
<script>
|
<script>
|
||||||
$(function () {
|
$(function () {
|
||||||
|
@ -237,8 +259,3 @@ $(function () {
|
||||||
return self.deck.sched._groupLimit("rev")
|
return self.deck.sched._groupLimit("rev")
|
||||||
else:
|
else:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
def _addMissing(self, dic, min, max):
|
|
||||||
for i in range(min, max+1):
|
|
||||||
if not i in dic:
|
|
||||||
dic[i] = 0
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ def test_graphs_empty():
|
||||||
|
|
||||||
def test_graphs():
|
def test_graphs():
|
||||||
from anki import Deck
|
from anki import Deck
|
||||||
d = Deck(os.path.expanduser("~/test.anki"))
|
d = Deck(os.path.expanduser("~/rapid.anki"))
|
||||||
g = d.graphs()
|
g = d.graphs()
|
||||||
rep = g.report()
|
rep = g.report()
|
||||||
open(os.path.expanduser("~/test.html"), "w").write(rep)
|
open(os.path.expanduser("~/test.html"), "w").write(rep)
|
||||||
|
|
Loading…
Reference in a new issue