5.1
Combine and relabel table view switch. Remove and re-arrange some table columns Group Pets together
This commit is contained in:
+21
-44
@@ -18,7 +18,8 @@
|
||||
// label heading text
|
||||
// unit the small print under the heading ("°C", "mm/h", …)
|
||||
// unitNone true → render the unit muted+italic (no data for this day)
|
||||
// group felt | surface | ambient | precip | sky | wind | airqual | solar
|
||||
// group felt | surface | pets | ambient | precip | sky | wind |
|
||||
// airqual | solar
|
||||
// visible resolved from visibleCols / indoorMode
|
||||
// headClass extra class on the heading cell ('utci-tight-head', …)
|
||||
// cellClass extra class on the data cell ('utci-dir-cell', …)
|
||||
@@ -163,14 +164,6 @@ const soilMoistureBg = (v) => {
|
||||
return { bg: `rgba(${r},${g},${b},0.18)`, fg: '#3a2a10' };
|
||||
};
|
||||
|
||||
const deltaBg = (v) => {
|
||||
if (v == null || isNaN(v)) return 'transparent';
|
||||
if (Math.abs(v) < 1) return 'transparent';
|
||||
const x = Math.min(1, Math.abs(v) / 12);
|
||||
const a = 0.035 + x * 0.13;
|
||||
return v > 0 ? `rgba(230,140,50,${a.toFixed(3)})` : `rgba(80,135,210,${a.toFixed(3)})`;
|
||||
};
|
||||
|
||||
const burnBg = (mins, uv) => {
|
||||
if (!isFinite(mins) || uv <= 0) return 'transparent';
|
||||
if (mins >= 240) return 'transparent';
|
||||
@@ -229,6 +222,7 @@ export function buildColumnDefs(ctx) {
|
||||
...tempCol('managedT', 'Managed', '°C est.', 'felt', r => r.managedT),
|
||||
visible: indoorMode === 'on' && indoorManaged,
|
||||
},
|
||||
tempCol('utci', 'UTCI', '°C felt', 'felt', r => r.utci),
|
||||
{
|
||||
key: 'burn', label: 'Burn', unit: 'to MED', group: 'felt',
|
||||
visible: !!visibleCols.burn,
|
||||
@@ -243,25 +237,7 @@ export function buildColumnDefs(ctx) {
|
||||
};
|
||||
},
|
||||
},
|
||||
tempCol('utci', 'UTCI', '°C felt', 'felt', r => r.utci),
|
||||
{
|
||||
key: 'delta', label: 'Δ', unit: 'UTCI−Air', group: 'felt',
|
||||
visible: !!visibleCols.delta,
|
||||
render: (r) => {
|
||||
const d = r.utci - r.Ta;
|
||||
return {
|
||||
content: `${d > 0 ? '+' : ''}${fmt(d)}${u('°C')}`,
|
||||
style: {
|
||||
color: d > 3 ? '#c8601a' : d < -3 ? '#3f73c4' : '#4a3218',
|
||||
background: deltaBg(d),
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
tempCol('tmrt', 'Tmrt', '°C', 'felt', r => r.Tmrt),
|
||||
tempCol('concreteT', 'Concrete', '°C surface', 'surface', r => r.concreteT),
|
||||
tempCol('furSurfaceT', 'Fur', '°C surface', 'surface', r => r.furSurfaceT, { pet: true, petTitle: true }),
|
||||
tempCol('pawT', 'Paw', '°C surface', 'surface', r => r.pawT, { pet: true, petTitle: true }),
|
||||
tempCol('soilT', 'Soil °C', 'surface', 'surface', r => r.soilT0),
|
||||
tempCol('soilT6', 'Soil 6cm', '°C root', 'surface', r => r.soilT6),
|
||||
{
|
||||
@@ -275,10 +251,12 @@ export function buildColumnDefs(ctx) {
|
||||
};
|
||||
},
|
||||
},
|
||||
tempCol('petShadeT', 'Pet Shade', '°C', 'ambient', r => r.petShadeT, { pet: true, petTitle: true, headClass: 'utci-tight-head' }),
|
||||
tempCol('furSurfaceT', 'Fur', '°C surface', 'pets', r => r.furSurfaceT, { pet: true, petTitle: true }),
|
||||
tempCol('pawT', 'Paw', '°C surface', 'pets', r => r.pawT, { pet: true, petTitle: true }),
|
||||
tempCol('petShadeT', 'Pet Shade', '°C', 'pets', r => r.petShadeT, { pet: true, petTitle: true, headClass: 'utci-tight-head' }),
|
||||
// Pet Home reads the same indoorT figure as the Indoors column, just on
|
||||
// the pet-calibrated colour scale.
|
||||
tempCol('petHomeT', 'Pet Home', '°C est.', 'ambient', r => r.indoorT, { pet: true, petTitle: true }),
|
||||
tempCol('petHomeT', 'Pet Home', '°C est.', 'pets', r => r.indoorT, { pet: true, petTitle: true }),
|
||||
tempCol('air', 'Air', '°C', 'ambient', r => r.Ta, { headClass: 'utci-tight-head' }),
|
||||
{
|
||||
key: 'rh', label: 'RH', unit: '%', group: 'ambient',
|
||||
@@ -306,27 +284,26 @@ export function buildColumnDefs(ctx) {
|
||||
}),
|
||||
},
|
||||
{
|
||||
// Rain % carries the storm warning too: rather than spend a whole
|
||||
// column on the Lightning Potential Index, an amber ⚡ rides alongside
|
||||
// the percentage whenever LPI clears the moderate-risk threshold (5),
|
||||
// going bold at the high-risk one (25). Same thresholds the old
|
||||
// Lightning column and the Lightning-risk insight use.
|
||||
key: 'precipProb', label: 'Rain', unit: '%', group: 'precip',
|
||||
visible: !!visibleCols.precipProb, headClass: 'utci-tight-head',
|
||||
render: (r) => ({
|
||||
content: `${r.precipProb}${u('%')}`,
|
||||
style: {
|
||||
background: scaleBg(r.precipProb, 0, 100, '70,145,200'),
|
||||
color: r.precipProb >= 50 ? '#1a4a70' : r.precipProb > 0 ? '#2a6a90' : '#7a8a90',
|
||||
},
|
||||
}),
|
||||
},
|
||||
{
|
||||
key: 'lightning', label: '⚡', unit: 'LPI', group: 'precip',
|
||||
visible: !!visibleCols.lightning, headClass: 'utci-tight-head',
|
||||
render: (r) => {
|
||||
const lpi = r.lightning ?? 0;
|
||||
const storm = lpi >= 25 ? 'high' : lpi >= 5 ? 'mod' : null;
|
||||
return {
|
||||
content: lpi > 0 ? `${Math.round(lpi)}` : '',
|
||||
title: storm ? `Lightning potential ${Math.round(lpi)} J/kg — ${storm === 'high' ? 'high' : 'moderate'} risk` : undefined,
|
||||
content: html`${r.precipProb}${u('%')}${storm
|
||||
? html`<span style=${{ marginLeft: '4px', fontWeight: storm === 'high' ? 700 : 'normal', opacity: storm === 'high' ? 1 : 0.75, color: storm === 'high' ? '#7a4800' : '#6a5800' }}>⚡</span>`
|
||||
: ''}`,
|
||||
style: {
|
||||
background: lpi >= 25 ? 'rgba(255,180,0,0.25)' : lpi >= 5 ? 'rgba(255,210,0,0.15)' : 'transparent',
|
||||
color: lpi >= 25 ? '#7a4800' : lpi >= 5 ? '#6a5800' : '#7a8a90',
|
||||
textAlign: 'center',
|
||||
background: storm === 'high' ? 'rgba(255,180,0,0.25)'
|
||||
: storm === 'mod' ? 'rgba(255,210,0,0.15)'
|
||||
: scaleBg(r.precipProb, 0, 100, '70,145,200'),
|
||||
color: r.precipProb >= 50 ? '#1a4a70' : r.precipProb > 0 ? '#2a6a90' : '#7a8a90',
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user