{% extends "admin/base_site_gridpivot.html" %} {% load i18n %} {% block contextmenus %} {% include "buffercontext.html" %} {% include "itemcontext.html" %} {% include "locationcontext.html" %}
{% endblock %} {% block tools %}{% if args.0 %} {% include "buffertabs.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-5)/20.0); // Loop over all graph cells $("#grid_frozen").find(".graph").each(function(index) { // Collect the graph data var d1=[], d2=[], d3=[]; 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']]; d1.push([j,data[0]]);{% if args.0 %} d2.push([j-0.25,data[1]]); d3.push([j+0.25,data[2]]); {% endif %}j = j + 1; } } first = false; // Draw the graph {% if not args.0 %}$(this).height($(this).parent().height());{% endif %} Flotr.draw({% if args.0 %}$("#graph").get(0){% else %}this{% endif %},[ {% if args.0 %}// Bars { data: d2, label: "{{_("produced")|capfirst}}", bars : { show : true, fillOpacity: 1, barWidth : 0.45, lineWidth : 1, shadowSize : 0, } }, { data: d3, label: "{{_("consumed")|capfirst}}", bars : { show : true, fillOpacity: 1, barWidth : 0.45, lineWidth : 1, shadowSize : 0 } },{% endif %} // Lines { data: d1, label: "{{_("start inventory")|capfirst}}", lines : { fillOpacity: 1, shadowSize : 0,{% if args.0 %} fill: false,{% else %} fill: true, fillColor: '#CCDDFF',{% endif %} show : true } }], { HtmlText: false, {% 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','#8BBA00'], parseFloat: false }); }); } function crosses (cellvalue, options, rowdata) { var result = cellvalue[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[2] != 0.0 || cellvalue[1] != 0.0) result += cellvalue[3] + ""; else result += cellvalue[3]; return result; }; {% endblock %} {% block extra_grid %}loadComplete: drawGraphs, {% endblock %}