StateTimeline: fix duration in tooltip (#45955) (#45987)

- Fixes duration in StateTimeline appearing incorrectly when "merge consecutive values" is enabled.

(cherry picked from commit 5aab0063c7)

Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2022-02-28 16:55:54 -06:00
committed by GitHub
co-authored by Leon Sorokin
parent 700fd45f54
commit 865723d56e
@@ -553,16 +553,18 @@ export function findNextStateIndex(field: Field, datapointIdx: number) {
return null;
}
const startValue = field.values.get(datapointIdx);
while (end === undefined) {
if (rightPointer >= field.values.length) {
return null;
}
const rightValue = field.values.get(rightPointer);
if (rightValue !== undefined) {
end = rightPointer;
} else {
if (rightValue === undefined || rightValue === startValue) {
rightPointer++;
} else {
end = rightPointer;
}
}