[release-11.6.4] StateTimeline: Add endTime to tooltip (#107605)

StateTimeline: Add endTime to tooltip (#106582)

Co-authored-by: Adela Almasan <88068998+adela-almasan@users.noreply.github.com>
This commit is contained in:
Leon Sorokin
2025-07-08 01:38:29 +01:00
committed by GitHub
co-authored by Adela Almasan
parent 3b95e22331
commit 5854ed6114
2 changed files with 6 additions and 2 deletions
@@ -52,8 +52,9 @@ export const VizTooltipRow = ({
overflowY: 'auto',
}
: {
whiteSpace: 'wrap',
whiteSpace: 'pre-line',
wordBreak: 'break-word',
lineHeight: 1.2,
};
const [showLabelTooltip, setShowLabelTooltip] = useState(false);
@@ -43,6 +43,7 @@ export const StateTimelineTooltip2 = ({
mode = isPinned ? TooltipDisplayMode.Single : mode;
const contentItems = getContentItems(series.fields, xField, dataIdxs, seriesIdx, mode, sortOrder);
let endTime = null;
// append duration in single mode
if (withDuration && mode === TooltipDisplayMode.Single) {
@@ -58,9 +59,11 @@ export const StateTimelineTooltip2 = ({
if (nextStateTs) {
duration = nextStateTs && fmtDuration(nextStateTs - stateTs);
endTime = nextStateTs;
} else {
const to = timeRange.to.valueOf();
duration = fmtDuration(to - stateTs);
endTime = to;
}
contentItems.push({ label: 'Duration', value: duration });
@@ -82,7 +85,7 @@ export const StateTimelineTooltip2 = ({
const headerItem: VizTooltipItem = {
label: xField.type === FieldType.time ? '' : (xField.state?.displayName ?? xField.name),
value: xVal,
value: endTime ? xVal + ' - \n' + xField.display!(endTime).text : xVal,
};
return (