Skip to content

Commit 050b91d

Browse files
moar tweak!
1 parent 6f6b54e commit 050b91d

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

js/elements.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ function get_domrect(METRIC) {
3535
value = zLIE
3636
// analyse noise
3737
let oDiffs = {}, aProps = [], max = 0
38+
let isNegative = false, isPositive = false
3839
let test = oDomRect[k]['data']
3940
for (const p of Object.keys(test)) {
4041
let diff = control[p] - test[p]
42+
if (diff > 0) {isPositive = true} else {isNegative = true}
4143
if (Math.abs(diff) > max) {max = Math.abs(diff)}
4244
if (0 !== diff) {
4345
aProps.push(p)
@@ -49,14 +51,18 @@ function get_domrect(METRIC) {
4951
if (oDiffs[m].length > 1) {multiples.push(oDiffs[m].join(' + '))}
5052
}
5153
console.log(k, oDiffs, multiples, max)
52-
if (max > 0.1) {max = '> ±0.1'
54+
// sign: chamelon seems to always be -, CB seems to always be ±
55+
let sign = ''
56+
if (isNegative && isPositive) {sign = '±'} else {
57+
sign = isNegative ? '-' : '+'
58+
}
59+
if (max > 0.1) {max = '> '+ sign +'0.1'
5360
} else {
5461
// note max is always positive
5562
var z = -Math.floor(Math.log10(max) + 1) // leading zeros
56-
// chameleon varies from 6 to 9 in a few tests
57-
// cap at 5
63+
// cap at 5: chameleon varies from 6 to 9 in a few tests
5864
z = z > 5 ? 5 : z
59-
max = '< ±0.' + '0'.repeat(z-1) + '1'
65+
max = '< '+ sign +'0.' + '0'.repeat(z-1) + '1'
6066
}
6167
value = {
6268
'properties': aProps.length == 8 ? 'all' : aProps.join(', '),

0 commit comments

Comments
 (0)