From ccab177f546b77bce1bb5b54e5c5792f91baadac Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 22 Aug 2022 14:26:33 +1000 Subject: [PATCH] Add a 'zero stock' threshold line to the part scheduling tab (#3587) --- InvenTree/templates/js/translated/part.js | 34 ++++++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/InvenTree/templates/js/translated/part.js b/InvenTree/templates/js/translated/part.js index 18f7539957..ebb2949d28 100644 --- a/InvenTree/templates/js/translated/part.js +++ b/InvenTree/templates/js/translated/part.js @@ -2539,15 +2539,34 @@ function loadPartSchedulingChart(canvas_id, part_id) { ], }; + var t_min = quantity_scheduled[0].x; + var t_max = quantity_scheduled[quantity_scheduled.length - 1].x; + + // Construct a 'zero stock' threshold line + data.datasets.push({ + data: [ + { + x: t_min, + y: 0, + }, + { + x: t_max, + y: 0, + } + ], + borderColor: 'rgba(250, 50, 50, 0.75)', + label: 'zero-stock-level', + }); + + // Construct a 'minimum stock' threshold line if (part_info.minimum_stock) { - // Construct a 'minimum stock' threshold line var minimum_stock_curve = [ { - x: quantity_scheduled[0].x, + x: t_min, y: part_info.minimum_stock, }, { - x: quantity_scheduled[quantity_scheduled.length - 1].x, + x: t_max, y: part_info.minimum_stock, } ]; @@ -2626,7 +2645,14 @@ function loadPartSchedulingChart(canvas_id, part_id) { return `{% trans "Quantity" %}: ${item.raw.y}${delta}`; } } - } + }, + legend: { + labels: { + filter: function(item, chart) { + return !item.text.includes('zero-stock-level'); + } + } + }, }, } });