gth - 1];
            lastDataTimestamp = new Date(lastDataPoint.timestamp);
            // Only update lastUpdated from data if this wasn't triggered by manual refresh
            if (!isRefreshing) {
              lastUpdated = lastDataTimestamp;
            }
          }

          const values = data.map((d) => d.value);
          const stats = {
            current: values[values.length - 1] || 0,
            average: values.reduce((a, b) => a + b, 0) / values.length,
            min: Math.min(...value