fix: Docker deployment

This commit is contained in:
gauvainboiche
2026-08-01 18:22:30 +02:00
parent 4fee4c4eb9
commit 1cd6061d39
6 changed files with 128 additions and 59 deletions
+36 -8
View File
@@ -1,30 +1,58 @@
import { CLINICAL_THRESHOLDS } from '../pkCore.js';
import { CLINICAL_THRESHOLDS } from '../../pkCore.js';
export function createChartAnnotations(mode) {
/**
* Recalcule et applique les zones de couleur en fonction du mode et du Y max actuel
*/
export function updateChartAnnotations(chart, mode, currentYMax) {
const thresholds = CLINICAL_THRESHOLDS[mode];
const annotations = {};
thresholds.zones.forEach((zone, index) => {
// Évite d'étendre la dernière zone à l'infini sur le graphe
const yMax = zone.max === Infinity ? thresholds.maxScale : zone.max;
if (zone.min < currentYMax) {
const zoneMax = zone.max === Infinity ? currentYMax : zone.max;
if (zone.min < thresholds.maxScale) {
annotations[`zone_${index}`] = {
type: 'box',
yMin: zone.min,
yMax: Math.min(yMax, thresholds.maxScale),
yMax: Math.min(zoneMax, currentYMax),
backgroundColor: zone.color,
borderWidth: 0,
label: {
display: true,
content: zone.name,
color: zone.textHex,
font: { size: 14, weight: 'bold' },
font: { size: 11, weight: 'bold' },
position: 'center'
}
};
}
});
return annotations;
chart.options.plugins.annotation.annotations = annotations;
}
/**
* Ajuste l'échelle Y de manière dynamique :
* - Échelle par défaut (500 ou 1000)
* - Si un pic dépasse cette valeur, l'axe monte à 110 % du pic max.
*/
export function adjustChartYScale(chart, mode, datasets) {
const defaultMax = CLINICAL_THRESHOLDS[mode].maxScale;
let highestValue = 0;
// Trouve la valeur la plus haute parmi toutes les courbes actives
datasets.forEach(ds => {
ds.data.forEach(val => {
if (val > highestValue) highestValue = val;
});
});
// Calcul du Y max : 110 % de la valeur max si dépassement, sinon valeur par défaut
let targetYMax = defaultMax;
if (highestValue > defaultMax) {
targetYMax = Math.ceil(highestValue * 1.1);
}
chart.options.scales.y.max = targetYMax;
updateChartAnnotations(chart, mode, targetYMax);
}