mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 22:42:25 -04:00
add footer and background to graphs
This commit is contained in:
parent
133d4c2e8e
commit
23b24d30f3
2 changed files with 31 additions and 3 deletions
|
@ -104,18 +104,22 @@ class CollectionStats(object):
|
||||||
self.height = 200
|
self.height = 200
|
||||||
self.wholeCollection = False
|
self.wholeCollection = False
|
||||||
|
|
||||||
def report(self, type=0):
|
def report(self, type=0, background=False):
|
||||||
# 0=days, 1=weeks, 2=months
|
# 0=days, 1=weeks, 2=months
|
||||||
# period-dependent graphs
|
# period-dependent graphs
|
||||||
self.type = type
|
self.type = type
|
||||||
txt = self.css
|
from statsbg import bg
|
||||||
|
if not background:
|
||||||
|
bg = ""
|
||||||
|
txt = self.css % bg
|
||||||
txt += self.dueGraph()
|
txt += self.dueGraph()
|
||||||
txt += self.repsGraph()
|
txt += self.repsGraph()
|
||||||
txt += self.ivlGraph()
|
txt += self.ivlGraph()
|
||||||
# other graphs
|
# other graphs & info
|
||||||
txt += self.hourGraph()
|
txt += self.hourGraph()
|
||||||
txt += self.easeGraph()
|
txt += self.easeGraph()
|
||||||
txt += self.cardGraph()
|
txt += self.cardGraph()
|
||||||
|
txt += self.footer()
|
||||||
return "<script>%s\n</script><center>%s</center>" % (
|
return "<script>%s\n</script><center>%s</center>" % (
|
||||||
anki.js.jquery+anki.js.plot, txt)
|
anki.js.jquery+anki.js.plot, txt)
|
||||||
|
|
||||||
|
@ -123,6 +127,7 @@ class CollectionStats(object):
|
||||||
<style>
|
<style>
|
||||||
h1 { margin-bottom: 0; margin-top: 1em; }
|
h1 { margin-bottom: 0; margin-top: 1em; }
|
||||||
.pielabel { text-align:center; padding:0px; color:white; }
|
.pielabel { text-align:center; padding:0px; color:white; }
|
||||||
|
body {background-image: url(data:image/png;base64,%s); }
|
||||||
</style>
|
</style>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -643,6 +648,26 @@ sum(case when queue=0 then 1 else 0 end), -- new
|
||||||
sum(case when queue=-1 then 1 else 0 end) -- susp
|
sum(case when queue=-1 then 1 else 0 end) -- susp
|
||||||
from cards where did in %s""" % self._limit())
|
from cards where did in %s""" % self._limit())
|
||||||
|
|
||||||
|
# Footer
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
def footer(self):
|
||||||
|
b = "<br><br><font size=1>"
|
||||||
|
b += _("Generated on %s") % time.asctime(time.localtime(time.time()))
|
||||||
|
b += "<br>"
|
||||||
|
if self.wholeCollection:
|
||||||
|
deck = _("whole collection")
|
||||||
|
else:
|
||||||
|
deck = self.col.decks.current()['name']
|
||||||
|
b += _("Scope: %s") % deck
|
||||||
|
b += "<br>"
|
||||||
|
b += _("Period: %s") % [
|
||||||
|
_("1 month"),
|
||||||
|
_("1 year"),
|
||||||
|
_("deck life")
|
||||||
|
][self.type]
|
||||||
|
return b
|
||||||
|
|
||||||
# Tools
|
# Tools
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
|
3
anki/statsbg.py
Normal file
3
anki/statsbg.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
bg = """\
|
||||||
|
iVBORw0KGgoAAAANSUhEUgAAAHkAAAAmCAMAAADX/MRZAAAAG1BMVEXx8fHw8PDu7u7r6+vs7Ozv7+/t7e3p6enq6up7fRD2AAABM0lEQVR42u1WwXIFIQiLiKz//8XtrLbo9kFmz5WrDIHEKLijSA1Dpdwpzf6eXY+oJu07RPsVRpV2B34qo1mMbm2gi8bIXQeq1QTV2m9nmHNhzKXx6NZGgyu6o46SVuNhu8nImSlY5prEx+hOjzpyXwYJQwfqygf2uSapGfGy5FxVp7AZxTPnwQeCuZool70QYV2GD3zgI6ltJzXMaRZR7DJEOSCkZjdeNbvFTAaIvfAS8TP3l2uvXpp7iSNzf3ljEC/NvZQjc395Y6rY3kflXoqQub/6/rYiKc1lJ8KmjWHTtDDZH9ps/DFhZdce76y8a6PO33tTIyvNnlDEwvJPE0RTS/xWSuKdyrRH8i3yzysW1k0dRVaZy86EzTo729DZhs42dLahsw2dbehsQ2cb+t/b0Bc91VD1igpPDwAAAABJRU5ErkJggg==
|
||||||
|
"""
|
Loading…
Reference in a new issue