{% extends "admin/base_site_gridpivot.html" %} {% load i18n %} {% block contextmenus %} {% include "itemcontext.html" %}
{% endblock %} {% block tools %}{% if args.0 %} {% include "itemtabs.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=[], 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']]; {% if args.0 %}d1.push([j-0.25,data[0]]); d2.push([j+0.25,data[1]]); {% else %}d1.push([j,data[0]]); {% endif %}d3.push([j,data[2]]); 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 %},[ // Bars { data: d1, label: "{{_("demand")|capfirst}}", bars : { show : true, fillOpacity: 1, barWidth : {% if args.0 %}0.45{% else %}0.9{% endif %}, lineWidth : 1, shadowSize : 0, } }, {% if args.0 %}{ data: d2, label: "{{_("supply")|capfirst}}", bars : { show : true, fillOpacity: 1, barWidth : 0.45, lineWidth : 1, shadowSize : 0 } },{% endif %} // Lines { data: d3, label: "{{_("backlog")|capfirst}}", lines : { fillOpacity: 1, shadowSize : 0, fill: false, show : true, lineWidth: 1 } }], { 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','#8BBA00','#F6BD0F'], parseFloat: false }); }); } function crosses (cellvalue, options, rowdata) { var result = cellvalue[0] + '
'; if (cellvalue[0] != 0.0) var result = cellvalue[0] + "
"; else var result = '0.0
'; if (cellvalue[1] != 0.0) result += cellvalue[1] + "
"; else result += '0.0
'; result += cellvalue[2]; return result; }; {% endblock %} {% block extra_grid %}loadComplete: drawGraphs, {% endblock %}