Fix hashrate chart: auto-scale tooltip units, remove green block lines

- layout.pug: formatNetworkChartValue now calls scaleFromGH() for
  Hashrate labels instead of appending the fixed (GH/s) unit, so
  tooltip values match the Y-axis auto-scaled unit (MH/s…PH/s)
- custom.js: promote HASH_UNITS and scaleFromGH to global scope so
  layout.pug inline scripts can reuse them; fix unused 'mutations' param
- settings.json.tmpl: disable block_line on both charts (was green
  rgba(0,128,0)); color updated to purple rgba(120,60,220,0.25)
This commit is contained in:
2026-04-29 22:20:58 +02:00
parent 93bc951b6a
commit f4c47a72ac
3 changed files with 36 additions and 30 deletions
+2 -2
View File
@@ -107,7 +107,7 @@
"line_color": "rgba(54,162,235,1)", "line_color": "rgba(54,162,235,1)",
"fill_color": "rgba(54,162,235,0.2)", "fill_color": "rgba(54,162,235,0.2)",
"crosshair_color": "#aaa", "crosshair_color": "#aaa",
"block_line": { "enabled": true, "block_line_color": "rgba(0,128,0,0.2)" }, "block_line": { "enabled": false, "block_line_color": "rgba(120,60,220,0.25)" },
"round_decimals": 3, "round_decimals": 3,
"chart_height": 320, "chart_height": 320,
"full_row": false, "full_row": false,
@@ -123,7 +123,7 @@
"pos_line_color": "rgba(255,161,0,1)", "pos_line_color": "rgba(255,161,0,1)",
"pos_fill_color": "rgba(255,161,0,0.2)", "pos_fill_color": "rgba(255,161,0,0.2)",
"crosshair_color": "#aaa", "crosshair_color": "#aaa",
"block_line": { "enabled": true, "block_line_color": "rgba(0,128,0,0.2)" }, "block_line": { "enabled": false, "block_line_color": "rgba(120,60,220,0.25)" },
"round_decimals": 3, "round_decimals": 3,
"chart_height": 320, "chart_height": 320,
"full_row": false, "full_row": false,
+4 -4
View File
@@ -1,7 +1,5 @@
$(document).ready(function() {
// ══════════════════════════════════════════════════════════════ // ══════════════════════════════════════════════════════════════
// HASHRATE AUTO-SCALING // HASHRATE AUTO-SCALING (global scope — reused by layout.pug chart scripts)
// The server sends hashrate already divided by nethash_units ("G"), // The server sends hashrate already divided by nethash_units ("G"),
// so values arrive in GH/s. We scale to keep the display 1999. // so values arrive in GH/s. We scale to keep the display 1999.
// ══════════════════════════════════════════════════════════════ // ══════════════════════════════════════════════════════════════
@@ -26,6 +24,8 @@ $(document).ready(function() {
return { num: gh, unit: 'GH/s' }; return { num: gh, unit: 'GH/s' };
} }
$(document).ready(function() {
// ── Panel: reformat #hashrate + update unit label ───────────── // ── Panel: reformat #hashrate + update unit label ─────────────
function refreshHashratePanel() { function refreshHashratePanel() {
var $el = $('#hashrate'); var $el = $('#hashrate');
@@ -58,7 +58,7 @@ $(document).ready(function() {
}); });
// Start watching once #hashrate appears in the DOM // Start watching once #hashrate appears in the DOM
var _panelWatcher = new MutationObserver(function(mutations, obs) { var _panelWatcher = new MutationObserver(function(_mutations, obs) {
var el = document.getElementById('hashrate'); var el = document.getElementById('hashrate');
if (el) { if (el) {
obs.disconnect(); obs.disconnect();
+10 -4
View File
@@ -540,6 +540,15 @@ html(lang='en')
return Math.floor(timestamp * 1000 / (60 * 1000)) * (60 * 1000); return Math.floor(timestamp * 1000 / (60 * 1000)) * (60 * 1000);
} }
function formatNetworkChartValue(val, roundDecimals, lbl, returnNum) { function formatNetworkChartValue(val, roundDecimals, lbl, returnNum) {
if (returnNum)
return (val || 0);
if (lbl == 'Hashrate' && typeof scaleFromGH === 'function') {
var s = scaleFromGH(val || 0);
var dec = Math.abs(s.num) >= 100 ? 0 : Math.abs(s.num) >= 10 ? 1 : 2;
return s.num.toFixed(dec) + ' ' + s.unit;
}
let max = 20; let max = 20;
if (roundDecimals != -1) if (roundDecimals != -1)
@@ -551,10 +560,7 @@ html(lang='en')
max = decimalCount; max = decimalCount;
} }
if (returnNum) return Number((val || 0)).toLocaleString('en',{'minimumFractionDigits':0,'maximumFractionDigits':max,'useGrouping':true});
return (val || 0);
else
return Number((val || 0)).toLocaleString('en',{'minimumFractionDigits':0,'maximumFractionDigits':max,'useGrouping':true}) + (lbl == 'Hashrate' ? ' ' + getNetHashUnits() : '');
} }
function populateHourChartData(result) { function populateHourChartData(result) {
const roundedDataMap = new Map(); const roundedDataMap = new Map();