{% extends "bigbrother/index.html" %}

{% block extrajs %}
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
  	<script type="text/javascript" src="{{ STATIC_URL }}js/jquery.flot.min.js"></script>
	<script type="text/javascript">
	$(function () {
		var weekdata = [{% for s in week %}[(new Date({{ s.added|date:"Y" }},{{ s.added|date:"n" }}, {{ s.added|date:"j" }})).getTime(), {{ s.value|stringformat:"f" }}],{% endfor %}]
		var monthdata = [{% for s in month %}[(new Date({{ s.added|date:"Y" }},{{ s.added|date:"n" }}, {{ s.added|date:"j" }})).getTime(), {{ s.value|stringformat:"f" }}],{% endfor %}]
		var yeardata = [{% for s in year %}[(new Date({{ s.added|date:"Y" }},{{ s.added|date:"n" }}, {{ s.added|date:"j" }})).getTime(), {{ s.value|stringformat:"f" }}],{% endfor %}]
	    $.plot($("#week"), [weekdata], {
				points: {show:true},
				lines: {show:true},
				xaxis: {mode: "time",
						minTickSize: [1, "day"],
						timeformat: "%y/%m/%d",
						{% with week|first as first %}
						min: (new Date({{first.added|date:"Y"}}, {{first.added|date:"n"}}, {{first.added|date:"j"}})).getTime(),
						{% endwith %}
						max: (new Date({{ lastdow|date:"Y" }}, {{ lastdow|date:"n" }}, {{ lastdow|date:"j" }})).getTime()
						}
        	});
		    $.plot($("#month"), [monthdata], {
					points: {show:true},
					lines: {show:true},
					xaxis: {mode: "time",
							minTickSize: [1, "day"],
							timeformat: "%y/%m/%d",
							{% with month|first as first %}
							min: (new Date({{first.added|date:"Y"}}, {{first.added|date:"n"}}, {{first.added|date:"j"}})).getTime(),
							{% endwith %}
							max: (new Date({{ lastdom|date:"Y" }}, {{ lastdom|date:"n" }}, {{ lastdom|date:"j" }})).getTime()
							}
	        	});
			    $.plot($("#year"), [yeardata], {
						points: {show:true},
						lines: {show:true},
						xaxis: {mode: "time",
								minTickSize: [1, "day"],
								timeformat: "%y/%m/%d",
								{% with year|first as first %}
								min: (new Date({{first.added|date:"Y"}}, {{first.added|date:"n"}}, {{first.added|date:"j"}})).getTime(),
								{% endwith %}
								max: (new Date({{ lastdoy|date:"Y" }}, {{ lastdoy|date:"n" }}, {{ lastdoy|date:"j" }})).getTime()
								}
		        	});
	});
	</script>
{% endblock %}
{% block content %}
<div id="graphcontainer">
	<h1>{{ week.0.modulename }}</h1>
	<h2>Last Week</h2>
	<div id="week" class="graph"></div>
	<h2>Last Month</h2>
	<div id="month" class="graph"></div>
	<h2>Last Year</h2>
	<div id="year" class="graph"></div>
</div>
{% endblock %}