Closed hz2018tv closed 10 months ago
looks like sth in scaling
maybe :shrug:. i'll need runnable code to tell you what's going on.
you can try running different commits in between to see which commit changed this. you can use git bisect
to help you quickly find when this happened: https://stackoverflow.com/questions/4713088/how-to-use-git-bisect
interesting, 230705 does not have this problem
maybe this? https://github.com/leeoniya/uPlot/commit/c057b8e4d0b24f19bae8d023f2eb9440fa55cc89
what is your data like?
yes, I replaced the getMinMax with old code in iife.js, it seems back :D
can you paste your data arrays here?
here you go 230623,1,2 230626,-1,-1 230627,1,1 230628,-1,-1 230629,-1,-2 230630,-1,-3 230703,-1,-4 230705,-1,-5 230706,1,1 230707,-1,-1 230710,-1,-2 230711,-1,-3 230712,-1,-4 230713,-1,-5 230714,1,1 230717,1,2 230718,-1,-1 230719,-1,-2 230720,-1,-3
okay. it's because your data arrays are probably parsed as strings instead of numbers. uPlot does not support string values in the data, so you need to fix this on your end.
https://jsfiddle.net/93crox0d/2/
const inf = Infinity;
const min = Math.min;
const max = Math.max;
function getMinMaxNew(data, _i0, _i1, sorted) {
let _min = inf;
let _max = -inf;
if (sorted == 1) {
_min = data[_i0];
_max = data[_i1];
}
else if (sorted == -1) {
_min = data[_i1];
_max = data[_i0];
}
else {
for (let i = _i0; i <= _i1; i++) {
let v = data[i];
if (v != null) {
if (v < _min)
_min = v;
if (v > _max)
_max = v;
}
}
}
return [_min, _max];
}
function getMinMaxOld(data, _i0, _i1, sorted) {
let _min = inf;
let _max = -inf;
if (sorted == 1) {
_min = data[_i0];
_max = data[_i1];
}
else if (sorted == -1) {
_min = data[_i1];
_max = data[_i0];
}
else {
for (let i = _i0; i <= _i1; i++) {
if (data[i] != null) {
_min = min(_min, data[i]);
_max = max(_max, data[i]);
}
}
}
return [_min, _max];
}
let x = [];
let y1 = [];
let y2 = [];
const data = `
230623,1,2
230626,-1,-1
230627,1,1
230628,-1,-1
230629,-1,-2
230630,-1,-3
230703,-1,-4
230705,-1,-5
230706,1,1
230707,-1,-1
230710,-1,-2
230711,-1,-3
230712,-1,-4
230713,-1,-5
230714,1,1
230717,1,2
230718,-1,-1
230719,-1,-2
230720,-1,-3
`.trim().split("\n").forEach(r => {
let vals = r.split(',');
x.push(+vals[0]);
y1.push(+vals[1]);
y2.push(+vals[2]);
});
let idx0 = 0;
let idx1 = x.length - 1;
console.log(x, y1, y2);
console.log(getMinMaxOld(x, idx0, idx1), getMinMaxNew(x, idx0, idx1));
console.log(getMinMaxOld(y1, idx0, idx1), getMinMaxNew(y1, idx0, idx1));
console.log(getMinMaxOld(y2, idx0, idx1), getMinMaxNew(y2, idx0, idx1));
// maybe strings?
let _x = [];
let _y1 = [];
let _y2 = [];
const data2 = `
230623,1,2
230626,-1,-1
230627,1,1
230628,-1,-1
230629,-1,-2
230630,-1,-3
230703,-1,-4
230705,-1,-5
230706,1,1
230707,-1,-1
230710,-1,-2
230711,-1,-3
230712,-1,-4
230713,-1,-5
230714,1,1
230717,1,2
230718,-1,-1
230719,-1,-2
230720,-1,-3
`.trim().split("\n").forEach(r => {
let vals = r.split(',');
_x.push(vals[0]);
_y1.push(vals[1]);
_y2.push(vals[2]);
});
console.log(_x, _y1, _y2);
console.log(getMinMaxOld(_x, idx0, idx1), getMinMaxNew(_x, idx0, idx1));
console.log(getMinMaxOld(_y1, idx0, idx1), getMinMaxNew(_y1, idx0, idx1));
console.log(getMinMaxOld(_y2, idx0, idx1), getMinMaxNew(_y2, idx0, idx1));
cool. I forced a number() on the data, with your new getMinMax(), seems ok. thanks!
same everything, only replaced the uPlot from 230430 to 230721, got the bottom of the bar cut-off. what could it be? looks like sth in scaling