Skip to content

Commit

Permalink
fix: more intuitive min_bound_range behavior (#1136)
Browse files Browse the repository at this point in the history
Now if one bound is defined but a soft bound, and there is no other bound defined, it treats it as a bound.

If both are soft bounds then it doesn't care.

And if the other bound is a hard bound, the soft one is breached.
  • Loading branch information
FAB1150 authored Jan 2, 2025
1 parent 25e6aea commit 54d9875
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -830,10 +830,22 @@ class MiniGraphCard extends LitElement {

// Doesn't matter if minBoundRange is NaN because this will be false if so
if (diff > 0) {
boundary = [
boundary[0] - diff / 2,
boundary[1] + diff / 2,
const weights = [
min !== undefined && min[0] !== '~' || max === undefined ? 0 : 1,
max !== undefined && max[0] !== '~' || min === undefined ? 0 : 1,
];
const sum = weights[0] + weights[1];
if (sum > 0) {
boundary = [
boundary[0] - diff * weights[0] / sum,
boundary[1] + diff * weights[1] / sum,
];
} else {
boundary = [
boundary[0] - diff / 2,
boundary[1] + diff / 2,
];
}
}
}

Expand Down

0 comments on commit 54d9875

Please sign in to comment.