refacto: Adding i18n support with FR and EN as base

This commit is contained in:
gauvainboiche
2026-08-01 18:32:46 +02:00
parent 1cd6061d39
commit 683105fa3b
12 changed files with 290 additions and 200 deletions
+3 -12
View File
@@ -1,8 +1,6 @@
import { CLINICAL_THRESHOLDS } from '../../pkCore.js';
import { CLINICAL_THRESHOLDS } from '/pkCore.js';
import { t } from './i18n.js';
/**
* 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 = {};
@@ -19,7 +17,7 @@ export function updateChartAnnotations(chart, mode, currentYMax) {
borderWidth: 0,
label: {
display: true,
content: zone.name,
content: t(`zones.${zone.zoneKey}`),
color: zone.textHex,
font: { size: 11, weight: 'bold' },
position: 'center'
@@ -31,23 +29,16 @@ export function updateChartAnnotations(chart, mode, currentYMax) {
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);