We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e138fa0 commit 2917d2bCopy full SHA for 2917d2b
src/filters/filters.ts
@@ -167,9 +167,10 @@ const filters = {
167
if ((i >= window_size && i < ys.length) || extended) {
168
if (centered) xs2.push(new Date(acc.x / acc.ys.length));
169
else xs2.push(xs[i]);
170
- const mid1 = Math.floor(acc.ys.length / 2);
171
- const mid2 = Math.ceil(acc.ys.length / 2);
172
- ys2.push((acc.ys[mid1] + acc.ys[mid2]) / 2);
+ const sorted = acc.ys.slice().sort();
+ const mid1 = Math.floor(sorted.length / 2);
+ const mid2 = Math.ceil(sorted.length / 2);
173
+ ys2.push((sorted[mid1] + sorted[mid2]) / 2);
174
}
175
176
return { ys: ys2, xs: xs2, ...rest };
0 commit comments