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:
@@ -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,
|
||||||
|
|||||||
+13
-13
@@ -1,22 +1,20 @@
|
|||||||
$(document).ready(function() {
|
// ══════════════════════════════════════════════════════════════
|
||||||
|
// HASHRATE AUTO-SCALING (global scope — reused by layout.pug chart scripts)
|
||||||
|
// The server sends hashrate already divided by nethash_units ("G"),
|
||||||
|
// so values arrive in GH/s. We scale to keep the display 1–999.
|
||||||
|
// ══════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
// ══════════════════════════════════════════════════════════════
|
var HASH_UNITS = [
|
||||||
// HASHRATE AUTO-SCALING
|
|
||||||
// The server sends hashrate already divided by nethash_units ("G"),
|
|
||||||
// so values arrive in GH/s. We scale to keep the display 1–999.
|
|
||||||
// ══════════════════════════════════════════════════════════════
|
|
||||||
|
|
||||||
var HASH_UNITS = [
|
|
||||||
{ div: 1e6, label: 'PH/s' },
|
{ div: 1e6, label: 'PH/s' },
|
||||||
{ div: 1e3, label: 'TH/s' },
|
{ div: 1e3, label: 'TH/s' },
|
||||||
{ div: 1, label: 'GH/s' },
|
{ div: 1, label: 'GH/s' },
|
||||||
{ div: 1e-3, label: 'MH/s' },
|
{ div: 1e-3, label: 'MH/s' },
|
||||||
{ div: 1e-6, label: 'KH/s' },
|
{ div: 1e-6, label: 'KH/s' },
|
||||||
{ div: 1e-9, label: 'H/s' }
|
{ div: 1e-9, label: 'H/s' }
|
||||||
];
|
];
|
||||||
|
|
||||||
// Returns {num, unit} where 1 ≤ |num| < 1000 (best fit)
|
// Returns {num, unit} where 1 ≤ |num| < 1000 (best fit)
|
||||||
function scaleFromGH(gh) {
|
function scaleFromGH(gh) {
|
||||||
var abs = Math.abs(gh);
|
var abs = Math.abs(gh);
|
||||||
for (var i = 0; i < HASH_UNITS.length; i++) {
|
for (var i = 0; i < HASH_UNITS.length; i++) {
|
||||||
if (abs >= HASH_UNITS[i].div) {
|
if (abs >= HASH_UNITS[i].div) {
|
||||||
@@ -24,7 +22,9 @@ $(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() {
|
||||||
@@ -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
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user