mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-04-29 18:25:58 +00:00
DX stats table #99
This commit is contained in:
@@ -108,18 +108,6 @@ function loadSolarConditions() {
|
||||
});
|
||||
}
|
||||
|
||||
// Take a normalised number 0-1 and generate a background colour for the DX stats cells
|
||||
function dxStatsColor(t) {
|
||||
const yellow = [255, 243, 205];
|
||||
const green = [209, 231, 221];
|
||||
if (t == 0.0) {
|
||||
return "rgb(248, 215, 218)";
|
||||
} else {
|
||||
const ch = (i) => Math.round(yellow[i] + (green[i] - yellow[i]) * t);
|
||||
return `rgb(${ch(0)}, ${ch(1)}, ${ch(2)})`;
|
||||
}
|
||||
}
|
||||
|
||||
// Render the DX stats table for the currently selected DE continent
|
||||
function renderDxStats() {
|
||||
if (!dxStatsData) { return; }
|
||||
@@ -142,7 +130,8 @@ function renderDxStats() {
|
||||
const range = max - min;
|
||||
cells.forEach(function({ cell, count }) {
|
||||
const t = range > 0 ? (count - min) / range : 0;
|
||||
cell.css('background-color', dxStatsColor(t));
|
||||
const cls = t === 0 ? 'table-danger' : t < 0.05 ? 'table-warning' : 'table-success';
|
||||
cell.removeClass('table-danger table-warning table-success').addClass(cls);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user