From 84e23a5d08cdd9ec51b2dcf7aed3eb6ec8c3d685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 15 Jul 2008 15:55:28 +0000 Subject: [PATCH] * DataHistory::ValueAt() now interpolates between two values in case the time doesn't match exactly one data item (before, it would have returned the value of the closest but earlier value). * This almost removes the effect that the older values seem to change with every refresh (because the time did not always match exactly)). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26429 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/activitymonitor/ActivityView.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/apps/activitymonitor/ActivityView.cpp b/src/apps/activitymonitor/ActivityView.cpp index 080bd39294..0b12cf27fc 100644 --- a/src/apps/activitymonitor/ActivityView.cpp +++ b/src/apps/activitymonitor/ActivityView.cpp @@ -172,9 +172,14 @@ DataHistory::ValueAt(bigtime_t time) // search in left part right = index - 1; } else { - if (index + 1 >= fBuffer.CountItems() - || fBuffer.ItemAt(index + 1)->time > time) { + data_item* nextItem = fBuffer.ItemAt(index + 1); + if (nextItem == NULL) + return item->value; + if (nextItem->time > time) { // found item + int64 value = item->value; + value += int64(double(nextItem->value - value) + / (nextItem->time - item->time) * (time - item->time)); return item->value; }