mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
bundle js libs; include them in report(); fix some graph ids
This commit is contained in:
parent
6ec2500eb8
commit
9c1e0befc6
3 changed files with 23 additions and 19 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
import os, sys, time, datetime, simplejson
|
||||
from anki.lang import _
|
||||
import anki.js
|
||||
|
||||
#colours for graphs
|
||||
dueYoungC = "#ffb380"
|
||||
|
@ -28,6 +29,15 @@ class Graphs(object):
|
|||
self._stats = None
|
||||
self.selective = selective
|
||||
|
||||
def report(self):
|
||||
txt = (self.dueGraph() +
|
||||
self.repsGraph() +
|
||||
self.timeGraph() +
|
||||
self.cumDueGraph() +
|
||||
self.ivlGraph() +
|
||||
self.easeGraph())
|
||||
return "<script>%s</script>%s" % (anki.js.all, txt)
|
||||
|
||||
# Due and cumulative due
|
||||
######################################################################
|
||||
|
||||
|
@ -83,7 +93,7 @@ group by due order by due""" % self._limit(),
|
|||
lrn.append((row[0], row[1]))
|
||||
yng.append((row[0], row[2]))
|
||||
mtr.append((row[0], row[3]))
|
||||
txt = self._graph(id="due", data=[
|
||||
txt = self._graph(id="reps", data=[
|
||||
dict(data=lrn, bars=dict(show=True, barWidth=0.8, align="center"),
|
||||
color=reviewNewC, label=_("Learning")),
|
||||
dict(data=yng, bars=dict(show=True, barWidth=0.8, align="center"),
|
||||
|
@ -100,13 +110,12 @@ group by due order by due""" % self._limit(),
|
|||
for row in self._stats['done']:
|
||||
lrn.append((row[0], row[4]))
|
||||
rev.append((row[0], row[5]))
|
||||
txt = self._graph(id="due", data=[
|
||||
txt = self._graph(id="time", data=[
|
||||
dict(data=lrn, bars=dict(show=True, barWidth=0.8, align="center"),
|
||||
color=lrnTimeC, label=_("Learning")),
|
||||
dict(data=rev, bars=dict(show=True, barWidth=0.8, align="center"),
|
||||
color=revTimeC, label=_("Reviews")),
|
||||
])
|
||||
self.save(txt)
|
||||
return txt
|
||||
|
||||
def _done(self):
|
||||
|
@ -212,13 +221,6 @@ $(function () {
|
|||
else:
|
||||
return ""
|
||||
|
||||
def save(self, txt):
|
||||
open(os.path.expanduser("~/test.html"), "w").write("""
|
||||
<html><head>
|
||||
<script src="jquery.min.js"></script>
|
||||
<script src="jquery.flot.min.js"></script>
|
||||
</head><body>%s</body></html>"""%txt)
|
||||
|
||||
def _addMissing(self, dic, min, max):
|
||||
for i in range(min, max+1):
|
||||
if not i in dic:
|
||||
|
|
5
anki/js.py
Normal file
5
anki/js.py
Normal file
File diff suppressed because one or more lines are too long
|
@ -22,17 +22,14 @@ def test_stats():
|
|||
# deck stats
|
||||
assert d.deckStats()
|
||||
|
||||
def test_graphs_empty():
|
||||
d = getEmptyDeck()
|
||||
assert d.graphs().report()
|
||||
|
||||
def test_graphs():
|
||||
from anki import Deck
|
||||
d = Deck(os.path.expanduser("~/test.anki"))
|
||||
g = d.graphs()
|
||||
assert g.dueGraph()
|
||||
assert g.cumDueGraph()
|
||||
assert g.ivlGraph()
|
||||
assert g.easeGraph()
|
||||
assert g.repsGraph()
|
||||
assert g.timeGraph()
|
||||
rep = g.report()
|
||||
open(os.path.expanduser("~/test.html"), "w").write(rep)
|
||||
return
|
||||
g.workDone()
|
||||
g.timeSpent()
|
||||
g.addedRecently()
|
||||
|
|
Loading…
Reference in a new issue