Skip to content

The only tool you need to know what is happening and how to fix it.

shadow tooltip added

dduxc3df45642fb1
diff --git a/frontend/src/lib/components/dashboard/metric-card.svelte b/frontend/src/lib/components/dashboard/metric-card.svelte
index 5f8820ee..b483c84c 100644
--- a/frontend/src/lib/components/dashboard/metric-card.svelte
+++ b/frontend/src/lib/components/dashboard/metric-card.svelte
@@ -7,11 +7,22 @@
import { min, max } from 'd3-array';
import MetricChartOverlay from './metric-chart-overlay.svelte';
- let { metric, timeDomain = null, onRangeSelect, serverColorMap = {} } = $props<{
+ let {
+ metric,
+ timeDomain = null,
+ onRangeSelect,
+ serverColorMap = {},
+ sharedHoverTime = null,
+ isSourceChart = false,
+ onHoverTimeChange
+ } = $props<{
metric: DashboardMetric;
timeDomain?: [Date, Date] | null;
onRangeSelect?: (from: Date, to: Date) => void;
serverColorMap?: Record<string, string>;
+ sharedHoverTime?: Date | null;
+ isSourceChart?: boolean;
+ onHoverTimeChange?: (time: Date | null) => void;
}>();
// Check if we have multi-server data
@@ -312,6 +323,10 @@
{serverColorMap}
unit={metric.unit}
formatValue={(v) => metric.formatValue ? metric.formatValue(v) : formatMetricValue(v, metric.unit)}
+ chartId={metric.id}
+ {sharedHoverTime}
+ {isSourceChart}
+ {onHoverTimeChange}
>
<Chart.Container config={chartConfig()}>
{#if hasData()}
diff --git a/frontend/src/lib/components/dashboard/metric-chart-overlay.svelte b/frontend/src/lib/components/dashboard/metric-chart-overlay.svelte
index 8faf4bc6..1d6ba39d 100644
--- a/frontend/src/lib/components/dashboard/metric-chart-overlay.svelte
+++ b/frontend/src/lib/components/dashboard/metric-chart-overlay.svelte
@@ -24,7 +24,11 @@
serverColorMap = {},
unit = '',
formatValue,
- timezone
+ timezone,
+ chartId = '',
+ sharedHoverTime = null,
+ isSourceChart = false,
+ onHoverTimeChange
} = $props<{
fromTime: Date;
toTime: Date;
@@ -37,6 +41,10 @@
unit?: string;
formatValue?: (value: number) => string;
timezone?: string;
+ chartId?: string;
+ sharedHoverTime?: Date | null;
+ isSourceChart?: boolean;
+ onHoverTimeChange?: (time: Date | null) => void;
}>();
// Check if we have multi-server data
@@ -93,6 +101,17 @@
return new Date(fromTime.getTime() + timeDiff * percentage);
}
+ // Calculate X position based on time (inverse of getTimeAtPosition)
+ function getPositionAtTime(time: Date): number {
+ if (!containerRef) return chartPadding.left;
+ const chartAreaWidth = getChartAreaWidth();
+ if (chartAreaWidth <= 0) return chartPadding.left;
+ const timeDiff = toTime.getTime() - fromTime.getTime();
+ if (timeDiff <= 0) return chartPadding.left;
+ const percentage = (time.getTime() - fromTime.getTime()) / timeDiff;
+ return chartPadding.left + (percentage * chartAreaWidth);
+ }
+
// Find the value at a given time, interpolating for line sections
function getValueAtTime(time: Date): { value: number; isInterpolated: boolean } | null {
if (data.length === 0) return null;
@@ -257,6 +276,16 @@
return results;
});
+ // Shadow line: show when another chart is being hovered
+ const shouldShowShadowLine = $derived(
+ sharedHoverTime !== null && !isSourceChart && !isDragging && !isHovering
+ );
+
+ const shadowLineX = $derived(() => {
+ if (!shouldShowShadowLine || !sharedHoverTime) return 0;
+ return getPositionAtTime(sharedHoverTime);
+ });
+
// Format value for display
function formatDisplayValue(value: number): string {
if (formatValue) {
@@ -287,6 +316,8 @@
if (isDragging) {
dragEndX = mouseX;
+ } else if (isInChartArea()) {
+ onHoverTimeChange?.(getTimeAtPosition(mouseX));
}
}
@@ -300,6 +331,7 @@
if (isDragging) {
isDragging = false;
}
+ onHoverTimeChange?.(null);
}
function handleMouseDown(e: MouseEvent) {
@@ -336,6 +368,25 @@
if (!date) return '';
return formatDateTime(date, { timezone: tz, format: 'time' });
}
+
+ // Handle ESC key to cancel drag selection
+ function handleKeydown(e: KeyboardEvent) {
+ if (e.key === 'Escape' && isDragging) {
+ isDragging = false;
+ dragStartX = 0;
+ dragEndX = 0;
+ }
+ }
+
+ // Register/cleanup keyboard listener when dragging
+ $effect(() => {
+ if (isDragging) {
+ window.addEventListener('keydown', handleKeydown);
+ return () => {
+ window.removeEventListener('keydown', handleKeydown);
+ };
+ }
+ });
</script>
<div
@@ -425,4 +476,15 @@
</div>
</div>
{/if}
+
+ <!-- Shadow tooltip line: shows when another chart is being hovered -->
+ {#if shouldShowShadowLine}
+ {@const shadowX = shadowLineX()}
+ {#if shadowX >= chartPadding.left && shadowX <= getContainerWidth() - chartPadding.right}
+ <div
+ class="absolute top-0 bottom-0 w-px bg-muted-foreground/25 pointer-events-none"
+ style="left: {shadowX}px;"
+ ></div>
+ {/if}
+ {/if}
</div>
diff --git a/frontend/src/lib/components/dashboard/metrics-tab-content.svelte b/frontend/src/lib/components/dashboard/metrics-tab-content.svelte
index 72b2dd72..ec299624 100644
--- a/frontend/src/lib/components/dashboard/metrics-tab-content.svelte
+++ b/frontend/src/lib/components/dashboard/metrics-tab-content.svelte
@@ -94,6 +94,21 @@
const filteredMetrics = $derived(
metrics ? filterMetricsByServer(metrics) : []
);
+
+ // Hover state coordination for shadow tooltip lines across charts
+ let currentHoverTime = $state<Date | null>(null);
+ let currentHoverChartId = $state<string | null>(null);
+
+ function handleChartHoverChange(chartId: string, time: Date | null) {
+ if (time !== null) {
+ currentHoverTime = time;
+ currentHoverChartId = chartId;
+ } else if (currentHoverChartId === chartId) {
+ // Only clear if the chart that's leaving is the current source
+ currentHoverTime = null;
+ currentHoverChartId = null;
+ }
+ }
</script>
{#if error && !loading}
@@ -115,6 +130,9 @@
{timeDomain}
{onRangeSelect}
{serverColorMap}
+ sharedHoverTime={currentHoverTime}
+ isSourceChart={currentHoverChartId === metric.id}
+ onHoverTimeChange={(time) => handleChartHoverChange(metric.id, time)}
/>
{/each}
</div>