Add square-root scale mapping
This commit is contained in:
@@ -318,6 +318,8 @@
|
||||
<div class="mode-toggle" role="group" aria-label="Scale mapping">
|
||||
<button type="button" class="mode-btn active" data-scale="linear"
|
||||
title="Values spaced evenly along the scale">Linear</button>
|
||||
<button type="button" class="mode-btn" data-scale="sqrt"
|
||||
title="Square-root scale — ticks crowd at the low end; used for RMS current/power meters. Min must be ≥ 0">√</button>
|
||||
<button type="button" class="mode-btn" data-scale="log"
|
||||
title="Values spaced logarithmically — requires min and max greater than 0">Log</button>
|
||||
</div>
|
||||
@@ -433,11 +435,13 @@
|
||||
}
|
||||
if (btn.dataset.scale !== undefined) {
|
||||
document.getElementById('scale-type').value = btn.dataset.scale;
|
||||
const minInput = document.querySelector('input[name="min"]');
|
||||
const maxInput = document.querySelector('input[name="max"]');
|
||||
if (btn.dataset.scale === 'log') {
|
||||
const minInput = document.querySelector('input[name="min"]');
|
||||
const maxInput = document.querySelector('input[name="max"]');
|
||||
if (!(parseFloat(minInput.value) > 0)) minInput.value = '1';
|
||||
if (!(parseFloat(maxInput.value) > 0)) maxInput.value = '100';
|
||||
} else if (btn.dataset.scale === 'sqrt') {
|
||||
if (parseFloat(minInput.value) < 0) minInput.value = '0';
|
||||
}
|
||||
}
|
||||
doGenerate();
|
||||
|
||||
Reference in New Issue
Block a user