Skip to content

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

styling tooltips + clipping outside of chart values

ddux4db43376c265
diff --git a/frontend/src/lib/components/dashboard/d3-line-chart.svelte b/frontend/src/lib/components/dashboard/d3-line-chart.svelte
index 85aa8d42..1731a9c1 100644
--- a/frontend/src/lib/components/dashboard/d3-line-chart.svelte
+++ b/frontend/src/lib/components/dashboard/d3-line-chart.svelte
@@ -415,7 +415,13 @@
aria-label="Chart with drag-to-zoom"
>
{#if hasData && chartWidth > 0}
+ {@const clipId = `chart-clip-${Math.random().toString(36).slice(2, 9)}`}
<svg {width} {height}>
+ <defs>
+ <clipPath id={clipId}>
+ <rect x={0} y={0} width={chartWidth} height={chartHeight} />
+ </clipPath>
+ </defs>
<g transform="translate({padding.left}, {padding.top})">
<!-- Y axis grid lines -->
{#each yTicks() as tick}
@@ -465,34 +471,36 @@
/>
<!-- Lines for each series (with gap detection) -->
- {#each series as s}
- {#if s.data.length > 0}
- {@const segments = getLineSegments(s.data)}
- {@const isolated = getIsolatedPoints(s.data)}
-
- <!-- Draw line segments (only segments with 2+ points) -->
- {#each segments as segment}
- {#if segment.length > 1}
- <path
- d={generatePath(segment)}
- fill="none"
- stroke={s.color}
- stroke-width="1.5"
+ <g clip-path="url(#{clipId})">
+ {#each series as s}
+ {#if s.data.length > 0}
+ {@const segments = getLineSegments(s.data)}
+ {@const isolated = getIsolatedPoints(s.data)}
+
+ <!-- Draw line segments (only segments with 2+ points) -->
+ {#each segments as segment}
+ {#if segment.length > 1}
+ <path
+ d={generatePath(segment)}
+ fill="none"
+ stroke={s.color}
+ stroke-width="1.5"
+ />
+ {/if}
+ {/each}
+
+ <!-- Draw isolated points as dots -->
+ {#each isolated as point}
+ <circle
+ cx={xScale(point.timestamp)}
+ cy={yScale(point.value)}
+ r="3"
+ fill={s.color}
/>
- {/if}
- {/each}
-
- <!-- Draw isolated points as dots -->
- {#each isolated as point}
- <circle
- cx={xScale(point.timestamp)}
- cy={yScale(point.value)}
- r="3"
- fill={s.color}
- />
- {/each}
- {/if}
- {/each}
+ {/each}
+ {/if}
+ {/each}
+ </g>
</g>
</svg>
{:else}
diff --git a/frontend/src/lib/components/dashboard/d3-stacked-area-chart.svelte b/frontend/src/lib/components/dashboard/d3-stacked-area-chart.svelte
index 89e5da26..cd5e81d1 100644
--- a/frontend/src/lib/components/dashboard/d3-stacked-area-chart.svelte
+++ b/frontend/src/lib/components/dashboard/d3-stacked-area-chart.svelte
@@ -446,10 +446,10 @@
<!-- Value tooltip -->
{#if data}
<div
- class="absolute top-0 -translate-x-1/2 -translate-y-full pointer-events-none z-10"
- style="left: {clampedX}px;"
+ class="absolute -translate-x-1/2 -translate-y-full pointer-events-none z-10"
+ style="left: {clampedX}px; top: 10px;"
>
- <div class="bg-foreground text-background rounded px-2 py-1.5 text-xs font-medium whitespace-nowrap shadow-lg mb-1 flex flex-col gap-0.5">
+ <div class="bg-background text-foreground border border-border rounded px-2 py-1.5 text-xs font-medium whitespace-nowrap mb-1 flex flex-col gap-0.5">
{#each endpoints as endpoint}
{@const value = getNumericValue(data, endpoint)}
{#if value > 0}