{% extends "admin/base_site_gridpivot.html" %} {% load i18n %} {% block extrahead %}{{block.super}} {% endblock %} {% block contextmenus %} {% include "operationcontext.html" %} {% include "locationcontext.html" %}
{% endblock %} {% block tools %}{% if args.0 %} {% include "operationtabs.html" %} {% endif %}{{block.super}} {% endblock %} {% block before_table %}{% if args.0 %}
{% endif %}{% endblock %} {% block crosses %} {% if args.0 %}$(function(){ // Resize top graph var h = $(window).height(); $("#graph").width($(window).width()-55).height(h>800 || h<480 ? 400 : h-380); });{% endif %} function drawGraphs(jsondata) { var cols = jQuery("#grid").jqGrid('getGridParam', 'colModel'); var x_major = []; var x_minor = []; var first = true; var ticks = Math.ceil((cols.length-4)/20.0); // Loop over all graph cells $("#grid_frozen").find(".graph").each(function(index) { // Collect the graph data var d1=[], d2=[]; var j = 0; for (var i in cols) { if ('startdate' in cols[i]) { if (first) { x_minor.push([j,cols[i]['name']]); if (j % ticks == 0) x_major.push([j,cols[i]['name']]); } var data = jsondata['rows'][index][cols[i]['name']]; {% if args.0 %}d1.push([j-0.25,data[1]]); d2.push([j+0.25,data[3]]); {% else %}d1.push([j,data[1]]); {% endif %}j = j + 1; } } first = false; // Draw the graph Flotr.draw({% if args.0 %}$("#graph").get(0){% else %}this{% endif %},[ { data:d1, label:"{{_("total starts")|capfirst}}" }{% if args.0 %}, { data:d2, label:"{{_("total ends")|capfirst}}" }{% endif %} ], { HtmlText: false, bars : { show : true, fillOpacity: 1, barWidth : {% if args.0 %}0.45{% else %}0.9{% endif %}, lineWidth : 1, shadowSize : 0 }, {% if args.0 %} legend : { position: 'ne', backgroundOpacity: 1, }, grid : { verticalLines : false, horizontalLines : true, }, xaxis: { ticks: x_major, }, yaxis: { title: '{{_("units")|capfirst}}', titleAngle: 90 }, {% else %} legend: { show: false }, grid : { verticalLines : false, horizontalLines : false, outlineWidth: 0 }, xaxis: { showLabels: false }, yaxis: { showLabels: false }, {% endif %} mouse : { track : true, relative : true, trackFormatter: function(obj) { return x_minor[Math.round(obj.x)][1] + "
" + obj.y; // TODO not good JSON.stringify(obj); } }, colors: ['#2B95EC','#F6BD0F'], parseFloat: false }); }); } function graph(cellvalue, options, rowdata) { return '
'; }; function crosses (cellvalue, options, rowdata) { if (cellvalue[0] != 0.0) var result = cellvalue[0] + "
"; else result = '0.0
'; if (cellvalue[1] != 0.0) result += cellvalue[1] + "
"; else result += '0.0
'; if (cellvalue[2] != 0.0) result += cellvalue[2] + "
"; else result += '0.0
'; if (cellvalue[3] != 0.0) result += cellvalue[3] + ""; else result += cellvalue[3]; return result; }; {% endblock %} {% block extra_grid %}loadComplete: drawGraphs, {% endblock %}