Fix: Tooltip

This commit is contained in:
Luc Mcgrady 2025-07-13 16:36:11 +01:00
parent 84b2b2bd96
commit b6f551210d
No known key found for this signature in database
GPG key ID: 4F3D7A0B17CC3D9C

View file

@ -73,6 +73,10 @@ export function renderWorkloadChart(
tr.statisticsMemorized({ memorized: Math.round(value).toFixed(0) }), tr.statisticsMemorized({ memorized: Math.round(value).toFixed(0) }),
})[subgraph]; })[subgraph];
function formatX(dr: number) {
return `Desired Retention: ${dr}%<br>`;
}
return _renderSimulationChart( return _renderSimulationChart(
svgElem, svgElem,
bounds, bounds,
@ -80,6 +84,7 @@ export function renderWorkloadChart(
x, x,
yTickFormat, yTickFormat,
formatY, formatY,
formatX,
(_e: MouseEvent, _d: number) => undefined, (_e: MouseEvent, _d: number) => undefined,
); );
} }
@ -143,6 +148,11 @@ export function renderSimulationChart(
); );
} }
function formatX(date: Date) {
const days = +((date.getTime() - Date.now()) / (60 * 60 * 24 * 1000)).toFixed();
return `Date: ${localizedDate(date)}<br>In ${days} Days<br>`;
}
return _renderSimulationChart( return _renderSimulationChart(
svgElem, svgElem,
bounds, bounds,
@ -150,6 +160,7 @@ export function renderSimulationChart(
x, x,
yTickFormat, yTickFormat,
formatY, formatY,
formatX,
legendMouseMove, legendMouseMove,
); );
} }
@ -160,7 +171,8 @@ function _renderSimulationChart<T extends { x: any; y: any; label: number }>(
subgraph_data: T[], subgraph_data: T[],
x: any, x: any,
yTickFormat: (n: number) => string, yTickFormat: (n: number) => string,
formatY: (n: number) => string, formatY: (n: T["y"]) => string,
formatX: (n: T["x"]) => string,
legendMouseMove: (e: MouseEvent, d: number) => void, legendMouseMove: (e: MouseEvent, d: number) => void,
): TableDatum[] { ): TableDatum[] {
const svg = select(svgElem); const svg = select(svgElem);
@ -272,8 +284,7 @@ function _renderSimulationChart<T extends { x: any; y: any; label: number }>(
focusLine.attr("x1", d[0]).attr("x2", d[0]).style("opacity", 1); focusLine.attr("x1", d[0]).attr("x2", d[0]).style("opacity", 1);
const days = +((date.getTime() - Date.now()) / (60 * 60 * 24 * 1000)).toFixed(); let tooltipContent = formatX(date);
let tooltipContent = `Date: ${localizedDate(date)}<br>In ${days} Days<br>`;
for (const [key, value] of Object.entries(groupData)) { for (const [key, value] of Object.entries(groupData)) {
const path = svg.select(`path[data-group="${key}"]`); const path = svg.select(`path[data-group="${key}"]`);
const hidden = path.classed("hidden"); const hidden = path.classed("hidden");