Add a 'zero stock' threshold line to the part scheduling tab (#3587)

This commit is contained in:
Oliver 2022-08-22 14:26:33 +10:00 committed by GitHub
parent 9c79333efd
commit ccab177f54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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');
}
}
},
},
}
});