mirror of
https://github.com/grafana/grafana.git
synced 2026-07-30 00:08:10 -05:00
OutsideRangePlugin: Exclude leading and trailing null values when checking limits (#57335)
* OutsideRangePlugin: Exclude null limit values from calculation * refactor * Update OutsideRangePlugin.tsx Co-authored-by: Leon Sorokin <leeoniya@gmail.com> Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
This commit is contained in:
co-authored by
Leon Sorokin
parent
6f8fcae01b
commit
f161c5407a
@@ -34,11 +34,26 @@ export const OutsideRangePlugin: React.FC<ThresholdControlsPluginProps> = ({ con
|
||||
}
|
||||
|
||||
// Time values are always sorted for uPlot to work
|
||||
const first = timevalues[0];
|
||||
const last = timevalues[timevalues.length - 1];
|
||||
let i = 0,
|
||||
j = timevalues.length - 1;
|
||||
|
||||
while (i <= j && timevalues[i] == null) {
|
||||
i++;
|
||||
}
|
||||
|
||||
while (j >= 0 && timevalues[j] == null) {
|
||||
j--;
|
||||
}
|
||||
|
||||
const first = timevalues[i];
|
||||
const last = timevalues[j];
|
||||
const fromX = timeRange.min;
|
||||
const toX = timeRange.max;
|
||||
|
||||
if (first == null || last == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// (StartA <= EndB) and (EndA >= StartB)
|
||||
if (first <= toX && last >= fromX) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user