skip overview graph if there's no data

This commit is contained in:
Damien Elmes 2011-03-22 07:55:03 +09:00
parent 2dc9878435
commit d0b92313e8

View file

@ -41,18 +41,23 @@ class Reviewer(object):
<hr> <hr>
<div id="placeholder" style="width:350px; height:100px;"></div> <div id="placeholder" style="width:350px; height:100px;"></div>
<span class=sub>%(fcsub)s</span> <span class=sub>%(fcsub)s</span>
<hr> <hr class=sub>
%(opts)s %(opts)s
</center> </center>
<script id="source" language="javascript" type="text/javascript"> <script id="source" language="javascript" type="text/javascript">
$(function () { $(function () {
var d = %(fcdata)s; var d = %(fcdata)s;
if (d) {
$.plot($("#placeholder"), [ $.plot($("#placeholder"), [
{ data: d, bars: { show: true, barWidth: 0.8 } } { data: d, bars: { show: true, barWidth: 0.8 } }
], { ], {
xaxis: { ticks: [[0.4, "Today"]] } xaxis: { ticks: [[0.4, "Today"]] }
}); });
} else {
$("#placeholder").hide();
$(".sub").hide();
}
}); });
</script> </script>
""" """
@ -120,8 +125,10 @@ $(function () {
] ]
def _ovForecast(self): def _ovForecast(self):
return simplejson.dumps(tuple( fc = self.mw.deck.sched.dueForecast(14)
enumerate(self.mw.deck.sched.dueForecast(14)))) if not sum(fc):
return "''"
return simplejson.dumps(tuple(enumerate(fc)))
def _ovOpts(self): def _ovOpts(self):
if self.mw.deck.qconf['newCardOrder'] == NEW_CARDS_RANDOM: if self.mw.deck.qconf['newCardOrder'] == NEW_CARDS_RANDOM: