diff --git a/App/teacher.html b/App/teacher.html index bace8a3..1bd093b 100644 --- a/App/teacher.html +++ b/App/teacher.html @@ -634,25 +634,39 @@ function _liveBar(val, min, max, goodWhen) { + ''; } +// Farbwahl nach „gut wenn" (aus _liveBar extrahiert) — für die Mini-Balken. +function _liveBarColor(pct, goodWhen) { + pct = Math.max(0, Math.min(100, pct||0)); + if (goodWhen === 'low') return pct <= 33 ? '#5a8a5e' : pct <= 66 ? '#c9913a' : '#c07a6b'; + if (goodWhen === 'mid') return '#9a9a9a'; + return pct >= 60 ? '#5a8a5e' : pct >= 30 ? '#c9913a' : '#c07a6b'; +} +// Mini-Balken UNTER der Zahl (Cockpit „Aktuell"). pct 0–100. +function _liveMiniBar(pct, color) { + pct = Math.max(0, Math.min(100, pct||0)); + return '
'; +} + var LIVE_PRIMARY_FIELDS = { farmer: [ - {k:'year', label:'Jahr', fmt:function(v){ return (v||0) + ' / 10'; }}, + {k:'year', label:'Jahr', bar:{kind:'abs',max:10,good:'mid'}, fmt:function(v){ return (v||0) + ' / 10'; }}, {k:'market_de', label:'Markt', align:'left', fmt:function(v){ return v ? '🌍 '+esc(v) : '—'; }}, - {k:'cash', label:'Konto', fmt:function(v){ + {k:'cash', label:'Konto', bar:{kind:'rel',good:'signed'}, fmt:function(v){ if (v == null) return '—'; var color = v < 0 ? '#c0392b' : '#5a8a5e'; return ''+Number(v).toLocaleString('de-AT')+' €'; }}, - {k:'hit_rate', label:'Trefferquote', fmt:function(v){ return _liveBar(v, 0, 100, 'high'); }}, - {k:'crops_used', label:'Sorten', fmt:function(v){ return (v||0) + ' / 10'; }}, - {k:'countries', label:'Länder', fmt:function(v){ return (v!=null? v : 0); }}, - {k:'fields', label:'Felder', fmt:function(v){ return (v!=null? v : 0); }}, - {k:'attempts', label:'Versuche',fmt:function(v){ return (v!=null? v : 0); }}, - {k:'co2_kg', label:'CO₂', unit:'kg', fmt:function(v){ + {k:'hit_rate', label:'Trefferquote', unit:'%', bar:{kind:'abs',max:100,good:'high'}, fmt:function(v){ return (v!=null? v : 0); }}, + {k:'crops_used', label:'Sorten', bar:{kind:'abs',max:10,good:'high'}, fmt:function(v){ return (v||0) + ' / 10'; }}, + {k:'countries', label:'Länder', bar:{kind:'rel',good:'high'}, fmt:function(v){ return (v!=null? v : 0); }}, + {k:'fields', label:'Felder', bar:{kind:'rel',good:'mid'}, fmt:function(v){ return (v!=null? v : 0); }}, + {k:'attempts', label:'Versuche',bar:{kind:'rel',good:'mid'}, fmt:function(v){ return (v!=null? v : 0); }}, + {k:'co2_kg', label:'CO₂', unit:'kg', bar:{kind:'rel',good:'low'}, fmt:function(v){ if (v == null) return '—'; return ''+Number(Math.round(v)).toLocaleString('de-AT')+''; }}, - {k:'diseases', label:'Krankheiten', align:'center', fmt:function(v){ + {k:'diseases', label:'Krankheiten', align:'center', bar:{kind:'abs',max:5,good:'low'}, fmt:function(v){ if (v == null) return '—'; var color = (v > 0) ? '#c07a6b' : '#8a8a8a'; return ''+v+''; @@ -1419,6 +1433,16 @@ async function renderLive() { html += '