Skip to content
Snippets Groups Projects
Commit 1c529206 authored by Antoine Lambert's avatar Antoine Lambert
Browse files

history-counters: Ensure last counter value can be displayed in tooltip

Previously, it was hard to display the most recent counter value in
histogram tooltip. This is no longer the case with this change.
parent 9db4e436
No related branches found
No related tags found
No related merge requests found
Pipeline #10413 passed
/**
* Copyright (C) 2019 The Software Heritage developers
* Copyright (C) 2019-2024 The Software Heritage developers
* See the AUTHORS file at the top-level directory of this distribution
* License: GNU Affero General Public License version 3, or any later version
* See top-level LICENSE file for more information
......@@ -136,8 +136,10 @@ export async function drawHistoryCounterGraph(container, historyData) {
function updateTooltip(event) {
const x0 = xScale.invert(d3.pointer(event)[0]);
const i = bisectDate(historyData, x0, 1);
if (i >= historyData.length) return;
let i = bisectDate(historyData, x0, 1);
if (i >= historyData.length) {
i = historyData.length - 1;
}
const d0 = historyData[i - 1];
const d1 = historyData[i];
const d = x0 - d0[0] > d1[0] - x0 ? d1 : d0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment