The only tool you need to know what is happening and how to fix it.
Go alertingexception-trackerissue-trackinglogsmetricsmonitoringobservability-platformopen-telemetryotelsession-replaytelemetrytraces
charts major upgrade, moved to d3 fixed minor bugs issues
ddux3c43473f7ec0
diff --git a/frontend/package-lock.json b/frontend/package-lock.jsonindex dc1bed40..01867ed2 100644--- a/frontend/package-lock.json+++ b/frontend/package-lock.json@@ -39,7 +39,6 @@"eslint-config-prettier": "^10.1.8","eslint-plugin-svelte": "^3.13.1","globals": "^16.5.0",- "layerchart": "^2.0.0-next.43","prettier": "^3.7.4","prettier-plugin-svelte": "^3.4.0","prettier-plugin-tailwindcss": "^0.7.2",@@ -54,26 +53,6 @@"vite": "^7.2.6"}},- "node_modules/@dagrejs/dagre": {- "version": "1.1.8",- "resolved": "https://registry.npmjs.org/@dagrejs/dagre/-/dagre-1.1.8.tgz",- "integrity": "sha512-5SEDlndt4W/LaVzPYJW+bSmSEZc9EzTf8rJ20WCKvjS5EAZAN0b+x0Yww7VMT4R3Wootkg+X9bUfUxazYw6Blw==",- "dev": true,- "license": "MIT",- "dependencies": {- "@dagrejs/graphlib": "2.2.4"- }- },- "node_modules/@dagrejs/graphlib": {- "version": "2.2.4",- "resolved": "https://registry.npmjs.org/@dagrejs/graphlib/-/graphlib-2.2.4.tgz",- "integrity": "sha512-mepCf/e9+SKYy1d02/UkvSy6+6MoyXhVxP8lLDfA7BPE1X1d4dR0sZznmbM8/XVJ1GPM+Svnx7Xj6ZweByWUkw==",- "dev": true,- "license": "MIT",- "engines": {- "node": ">17.0.0"- }- },"node_modules/@esbuild/aix-ppc64": {"version": "0.27.2","resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.2.tgz",@@ -829,55 +808,6 @@"@jridgewell/sourcemap-codec": "^1.4.14"}},- "node_modules/@layerstack/svelte-actions": {- "version": "1.0.1-next.14",- "resolved": "https://registry.npmjs.org/@layerstack/svelte-actions/-/svelte-actions-1.0.1-next.14.tgz",- "integrity": "sha512-MPBmVaB+GfNHvBkg5nJkPG18smoXKvsvJRpsdWnrUBfca+TieZLoaEzNxDH+9LG11dIXP9gghsXt1mUqbbyAsA==",- "dev": true,- "license": "MIT",- "dependencies": {- "@floating-ui/dom": "^1.7.0",- "@layerstack/utils": "2.0.0-next.14",- "d3-scale": "^4.0.2"- }- },- "node_modules/@layerstack/svelte-state": {- "version": "0.1.0-next.19",- "resolved": "https://registry.npmjs.org/@layerstack/svelte-state/-/svelte-state-0.1.0-next.19.tgz",- "integrity": "sha512-yCYoQAIbeP8y1xmOB/r0+UundgP4JFnpNURgMki+26TotzoqrZ5oLpHvhPSVm60ks+buR3ebDBTeUFdHzxwzQQ==",- "dev": true,- "license": "MIT",- "dependencies": {- "@layerstack/utils": "2.0.0-next.14"- }- },- "node_modules/@layerstack/tailwind": {- "version": "2.0.0-next.17",- "resolved": "https://registry.npmjs.org/@layerstack/tailwind/-/tailwind-2.0.0-next.17.tgz",- "integrity": "sha512-ZSn6ouqpnzB6DKzSKLVwrUBOQsrzpDA/By2/ba9ApxgTGnaD1nyqNwrvmZ+kswdAwB4YnrGEAE4VZkKrB2+DaQ==",- "dev": true,- "license": "MIT",- "dependencies": {- "@layerstack/utils": "^2.0.0-next.14",- "clsx": "^2.1.1",- "d3-array": "^3.2.4",- "lodash-es": "^4.17.21",- "tailwind-merge": "^3.2.0"- }- },- "node_modules/@layerstack/utils": {- "version": "2.0.0-next.14",- "resolved": "https://registry.npmjs.org/@layerstack/utils/-/utils-2.0.0-next.14.tgz",- "integrity": "sha512-1I2CS0Cwgs53W35qVg1eBdYhB/CiPvL3s0XE61b8jWkTHxgjBF65yYNgXjW74kv7WI7GsJcWMNBufPd0rnu9kA==",- "dev": true,- "license": "MIT",- "dependencies": {- "d3-array": "^3.2.4",- "d3-time": "^3.1.0",- "d3-time-format": "^4.1.0",- "lodash-es": "^4.17.21"- }- },"node_modules/@lucide/svelte": {"version": "0.561.0","resolved": "https://registry.npmjs.org/@lucide/svelte/-/svelte-0.561.0.tgz",@@ -2223,16 +2153,6 @@"dev": true,"license": "MIT"},- "node_modules/commander": {- "version": "7.2.0",- "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz",- "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==",- "dev": true,- "license": "MIT",- "engines": {- "node": ">= 10"- }- },"node_modules/concat-map": {"version": "0.0.1","resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",@@ -2301,70 +2221,6 @@"node": ">=12"}},- "node_modules/d3-delaunay": {- "version": "6.0.4",- "resolved": "https://registry.npmjs.org/d3-delaunay/-/d3-delaunay-6.0.4.tgz",- "integrity": "sha512-mdjtIZ1XLAM8bm/hx3WwjfHt6Sggek7qH043O8KEjDXN40xi3vx/6pYSVTwLjEgiXQTbvaouWKynLBiUZ6SK6A==",- "dev": true,- "license": "ISC",- "dependencies": {- "delaunator": "5"- },- "engines": {- "node": ">=12"- }- },- "node_modules/d3-dispatch": {- "version": "3.0.1",- "resolved": "https://registry.npmjs.org/d3-dispatch/-/d3-dispatch-3.0.1.tgz",- "integrity": "sha512-rzUyPU/S7rwUflMyLc1ETDeBj0NRuHKKAcvukozwhshr6g6c5d8zh4c2gQjY2bZ0dXeGLWc1PF174P2tVvKhfg==",- "dev": true,- "license": "ISC",- "engines": {- "node": ">=12"- }- },- "node_modules/d3-dsv": {- "version": "3.0.1",- "resolved": "https://registry.npmjs.org/d3-dsv/-/d3-dsv-3.0.1.tgz",- "integrity": "sha512-UG6OvdI5afDIFP9w4G0mNq50dSOsXHJaRE8arAS5o9ApWnIElp8GZw1Dun8vP8OyHOZ/QJUKUJwxiiCCnUwm+Q==",- "dev": true,- "license": "ISC",- "dependencies": {- "commander": "7",- "iconv-lite": "0.6",- "rw": "1"- },- "bin": {- "csv2json": "bin/dsv2json.js",- "csv2tsv": "bin/dsv2dsv.js",- "dsv2dsv": "bin/dsv2dsv.js",- "dsv2json": "bin/dsv2json.js",- "json2csv": "bin/json2dsv.js",- "json2dsv": "bin/json2dsv.js",- "json2tsv": "bin/json2dsv.js",- "tsv2csv": "bin/dsv2dsv.js",- "tsv2json": "bin/dsv2json.js"- },- "engines": {- "node": ">=12"- }- },- "node_modules/d3-force": {- "version": "3.0.0",- "resolved": "https://registry.npmjs.org/d3-force/-/d3-force-3.0.0.tgz",- "integrity": "sha512-zxV/SsA+U4yte8051P4ECydjD/S+qeYtnaIyAs9tgHCqfguma/aAQDjo85A9Z6EKhBirHRJHXIgJUlffT4wdLg==",- "dev": true,- "license": "ISC",- "dependencies": {- "d3-dispatch": "1 - 3",- "d3-quadtree": "1 - 3",- "d3-timer": "1 - 3"- },- "engines": {- "node": ">=12"- }- },"node_modules/d3-format": {"version": "3.1.0","resolved": "https://registry.npmjs.org/d3-format/-/d3-format-3.1.0.tgz",@@ -2375,45 +2231,6 @@"node": ">=12"}},- "node_modules/d3-geo": {- "version": "3.1.1",- "resolved": "https://registry.npmjs.org/d3-geo/-/d3-geo-3.1.1.tgz",- "integrity": "sha512-637ln3gXKXOwhalDzinUgY83KzNWZRKbYubaG+fGVuc/dxO64RRljtCTnf5ecMyE1RIdtqpkVcq0IbtU2S8j2Q==",- "dev": true,- "license": "ISC",- "dependencies": {- "d3-array": "2.5.0 - 3"- },- "engines": {- "node": ">=12"- }- },- "node_modules/d3-geo-voronoi": {- "version": "2.1.0",- "resolved": "https://registry.npmjs.org/d3-geo-voronoi/-/d3-geo-voronoi-2.1.0.tgz",- "integrity": "sha512-kqE4yYuOjPbKdBXG0xztCacPwkVSK2REF1opSNrnqqtXJmNcM++UbwQ8SxvwP6IQTj9RvIjjK4qeiVsEfj0Z2Q==",- "dev": true,- "license": "ISC",- "dependencies": {- "d3-array": "3",- "d3-delaunay": "6",- "d3-geo": "3",- "d3-tricontour": "1"- },- "engines": {- "node": ">=12"- }- },- "node_modules/d3-hierarchy": {- "version": "3.1.2",- "resolved": "https://registry.npmjs.org/d3-hierarchy/-/d3-hierarchy-3.1.2.tgz",- "integrity": "sha512-FX/9frcub54beBdugHjDCdikxThEqjnR93Qt7PvQTOHxyiNCAlvMrHhclk3cD5VeAaq9fxmfRp+CnWw9rEMBuA==",- "dev": true,- "license": "ISC",- "engines": {- "node": ">=12"- }- },"node_modules/d3-interpolate": {"version": "3.0.1","resolved": "https://registry.npmjs.org/d3-interpolate/-/d3-interpolate-3.0.1.tgz",@@ -2427,13 +2244,6 @@"node": ">=12"}},- "node_modules/d3-interpolate-path": {- "version": "2.3.0",- "resolved": "https://registry.npmjs.org/d3-interpolate-path/-/d3-interpolate-path-2.3.0.tgz",- "integrity": "sha512-tZYtGXxBmbgHsIc9Wms6LS5u4w6KbP8C09a4/ZYc4KLMYYqub57rRBUgpUr2CIarIrJEpdAWWxWQvofgaMpbKQ==",- "dev": true,- "license": "BSD-3-Clause"- },"node_modules/d3-path": {"version": "3.1.0","resolved": "https://registry.npmjs.org/d3-path/-/d3-path-3.1.0.tgz",@@ -2444,71 +2254,6 @@"node": ">=12"}},- "node_modules/d3-quadtree": {- "version": "3.0.1",- "resolved": "https://registry.npmjs.org/d3-quadtree/-/d3-quadtree-3.0.1.tgz",- "integrity": "sha512-04xDrxQTDTCFwP5H6hRhsRcb9xxv2RzkcsygFzmkSIOJy3PeRJP7sNk3VRIbKXcog561P9oU0/rVH6vDROAgUw==",- "dev": true,- "license": "ISC",- "engines": {- "node": ">=12"- }- },- "node_modules/d3-random": {- "version": "3.0.1",- "resolved": "https://registry.npmjs.org/d3-random/-/d3-random-3.0.1.tgz",- "integrity": "sha512-FXMe9GfxTxqd5D6jFsQ+DJ8BJS4E/fT5mqqdjovykEB2oFbTMDVdg1MGFxfQW+FBOGoB++k8swBrgwSHT1cUXQ==",- "dev": true,- "license": "ISC",- "engines": {- "node": ">=12"- }- },- "node_modules/d3-sankey": {- "version": "0.12.3",- "resolved": "https://registry.npmjs.org/d3-sankey/-/d3-sankey-0.12.3.tgz",- "integrity": "sha512-nQhsBRmM19Ax5xEIPLMY9ZmJ/cDvd1BG3UVvt5h3WRxKg5zGRbvnteTyWAbzeSvlh3tW7ZEmq4VwR5mB3tutmQ==",- "dev": true,- "license": "BSD-3-Clause",- "dependencies": {- "d3-array": "1 - 2",- "d3-shape": "^1.2.0"- }- },- "node_modules/d3-sankey/node_modules/d3-array": {- "version": "2.12.1",- "resolved": "https://registry.npmjs.org/d3-array/-/d3-array-2.12.1.tgz",- "integrity": "sha512-B0ErZK/66mHtEsR1TkPEEkwdy+WDesimkM5gpZr5Dsg54BiTA5RXtYW5qTLIAcekaS9xfZrzBLF/OAkB3Qn1YQ==",- "dev": true,- "license": "BSD-3-Clause",- "dependencies": {- "internmap": "^1.0.0"- }- },- "node_modules/d3-sankey/node_modules/d3-path": {- "version": "1.0.9",- "resolved": "https://registry.npmjs.org/d3-path/-/d3-path-1.0.9.tgz",- "integrity": "sha512-VLaYcn81dtHVTjEHd8B+pbe9yHWpXKZUC87PzoFmsFrJqgFwDe/qxfp5MlfsfM1V5E/iVt0MmEbWQ7FVIXh/bg==",- "dev": true,- "license": "BSD-3-Clause"- },- "node_modules/d3-sankey/node_modules/d3-shape": {- "version": "1.3.7",- "resolved": "https://registry.npmjs.org/d3-shape/-/d3-shape-1.3.7.tgz",- "integrity": "sha512-EUkvKjqPFUAZyOlhY5gzCxCeI0Aep04LwIRpsZ/mLFelJiUfnK56jo5JMDSE7yyP2kLSb6LtF+S5chMk7uqPqw==",- "dev": true,- "license": "BSD-3-Clause",- "dependencies": {- "d3-path": "1"- }- },- "node_modules/d3-sankey/node_modules/internmap": {- "version": "1.0.1",- "resolved": "https://registry.npmjs.org/internmap/-/internmap-1.0.1.tgz",- "integrity": "sha512-lDB5YccMydFBtasVtxnZ3MRBHuaoE8GKsppq+EchKL2U4nK/DmEpPHNH8MZe5HkMtpSiTSOZwfN0tzYjO/lJEw==",- "dev": true,- "license": "ISC"- },"node_modules/d3-scale": {"version": "4.0.2","resolved": "https://registry.npmjs.org/d3-scale/-/d3-scale-4.0.2.tgz",@@ -2526,20 +2271,6 @@"node": ">=12"}},- "node_modules/d3-scale-chromatic": {- "version": "3.1.0",- "resolved": "https://registry.npmjs.org/d3-scale-chromatic/-/d3-scale-chromatic-3.1.0.tgz",- "integrity": "sha512-A3s5PWiZ9YCXFye1o246KoscMWqf8BsD9eRiJ3He7C9OBaxKhAd5TFCdEx/7VbKtxxTsu//1mMJFrEt572cEyQ==",- "dev": true,- "license": "ISC",- "dependencies": {- "d3-color": "1 - 3",- "d3-interpolate": "1 - 3"- },- "engines": {- "node": ">=12"- }- },"node_modules/d3-shape": {"version": "3.2.0","resolved": "https://registry.npmjs.org/d3-shape/-/d3-shape-3.2.0.tgz",@@ -2553,13 +2284,6 @@"node": ">=12"}},- "node_modules/d3-tile": {- "version": "1.0.0",- "resolved": "https://registry.npmjs.org/d3-tile/-/d3-tile-1.0.0.tgz",- "integrity": "sha512-79fnTKpPMPDS5xQ0xuS9ir0165NEwwkFpe/DSOmc2Gl9ldYzKKRDWogmTTE8wAJ8NA7PMapNfEcyKhI9Lxdu5Q==",- "dev": true,- "license": "BSD-3-Clause"- },"node_modules/d3-time": {"version": "3.1.0","resolved": "https://registry.npmjs.org/d3-time/-/d3-time-3.1.0.tgz",@@ -2586,30 +2310,6 @@"node": ">=12"}},- "node_modules/d3-timer": {- "version": "3.0.1",- "resolved": "https://registry.npmjs.org/d3-timer/-/d3-timer-3.0.1.tgz",- "integrity": "sha512-ndfJ/JxxMd3nw31uyKoY2naivF+r29V+Lc0svZxe1JvvIRmi8hUsrMvdOwgS1o6uBHmiz91geQ0ylPP0aj1VUA==",- "dev": true,- "license": "ISC",- "engines": {- "node": ">=12"- }- },- "node_modules/d3-tricontour": {- "version": "1.1.0",- "resolved": "https://registry.npmjs.org/d3-tricontour/-/d3-tricontour-1.1.0.tgz",- "integrity": "sha512-G7gHKj89n2owmkGb6WX6ixcnQ0Kf/0wpa9VIh9DGdbHu8wdrlaHU4ir3/bFNERl8N8nn4G7e7qbtBG8N9caihQ==",- "dev": true,- "license": "ISC",- "dependencies": {- "d3-delaunay": "6",- "d3-scale": "4"- },- "engines": {- "node": ">=12"- }- },"node_modules/debug": {"version": "4.4.3","resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",@@ -2645,16 +2345,6 @@"node": ">=0.10.0"}},- "node_modules/delaunator": {- "version": "5.0.1",- "resolved": "https://registry.npmjs.org/delaunator/-/delaunator-5.0.1.tgz",- "integrity": "sha512-8nvh+XBe96aCESrGOqMp/84b13H9cdKbG5P2ejQCh4d4sK9RL4371qou9drQjMhvnPmhWl5hnmqbEE0fXr9Xnw==",- "dev": true,- "license": "ISC",- "dependencies": {- "robust-predicates": "^3.0.2"- }- },"node_modules/dequal": {"version": "2.0.3","resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz",@@ -3126,19 +2816,6 @@"node": ">=12.0.0"}},- "node_modules/iconv-lite": {- "version": "0.6.3",- "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",- "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",- "dev": true,- "license": "MIT",- "dependencies": {- "safer-buffer": ">= 2.1.2 < 3.0.0"- },- "engines": {- "node": ">=0.10.0"- }- },"node_modules/ignore": {"version": "5.3.2","resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz",@@ -3303,62 +2980,6 @@"dev": true,"license": "MIT"},- "node_modules/layerchart": {- "version": "2.0.0-next.43",- "resolved": "https://registry.npmjs.org/layerchart/-/layerchart-2.0.0-next.43.tgz",- "integrity": "sha512-1Ywm38NdzHWKwgaAHq3EcqshIgsq+pylntSnVWAVazXUk/NsxPcxdpR3tMt3ySjWV0ZPBBgLs78sdVf7FTgd+g==",- "dev": true,- "license": "MIT",- "dependencies": {- "@dagrejs/dagre": "^1.1.5",- "@layerstack/svelte-actions": "1.0.1-next.14",- "@layerstack/svelte-state": "0.1.0-next.19",- "@layerstack/tailwind": "2.0.0-next.17",- "@layerstack/utils": "2.0.0-next.14",- "d3-array": "^3.2.4",- "d3-color": "^3.1.0",- "d3-delaunay": "^6.0.4",- "d3-dsv": "^3.0.1",- "d3-force": "^3.0.0",- "d3-geo": "^3.1.1",- "d3-geo-voronoi": "^2.1.0",- "d3-hierarchy": "^3.1.2",- "d3-interpolate": "^3.0.1",- "d3-interpolate-path": "^2.3.0",- "d3-path": "^3.1.0",- "d3-quadtree": "^3.0.1",- "d3-random": "^3.0.1",- "d3-sankey": "^0.12.3",- "d3-scale": "^4.0.2",- "d3-scale-chromatic": "^3.1.0",- "d3-shape": "^3.2.0",- "d3-tile": "^1.0.0",- "d3-time": "^3.1.0",- "lodash-es": "^4.17.21",- "memoize": "^10.1.0",- "runed": "^0.31.1"- },- "peerDependencies": {- "svelte": "^5.0.0"- }- },- "node_modules/layerchart/node_modules/runed": {- "version": "0.31.1",- "resolved": "https://registry.npmjs.org/runed/-/runed-0.31.1.tgz",- "integrity": "sha512-v3czcTnO+EJjiPvD4dwIqfTdHLZ8oH0zJheKqAHh9QMViY7Qb29UlAMRpX7ZtHh7AFqV60KmfxaJ9QMy+L1igQ==",- "dev": true,- "funding": [- "https://github.com/sponsors/huntabyte",- "https://github.com/sponsors/tglide"- ],- "license": "MIT",- "dependencies": {- "esm-env": "^1.0.0"- },- "peerDependencies": {- "svelte": "^5.7.0"- }- },"node_modules/levn": {"version": "0.4.1","resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz",@@ -3666,13 +3287,6 @@"url": "https://github.com/sponsors/sindresorhus"}},- "node_modules/lodash-es": {- "version": "4.17.22",- "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.22.tgz",- "integrity": "sha512-XEawp1t0gxSi9x01glktRZ5HDy0HXqrM0x5pXQM98EaI0NxO6jVM7omDOxsuEo5UIASAnm2bRp1Jt/e0a2XU8Q==",- "dev": true,- "license": "MIT"- },"node_modules/lodash.merge": {"version": "4.6.2","resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",@@ -3717,35 +3331,6 @@"@jridgewell/sourcemap-codec": "^1.5.5"}},- "node_modules/memoize": {- "version": "10.2.0",- "resolved": "https://registry.npmjs.org/memoize/-/memoize-10.2.0.tgz",- "integrity": "sha512-DeC6b7QBrZsRs3Y02A6A7lQyzFbsQbqgjI6UW0GigGWV+u1s25TycMr0XHZE4cJce7rY/vyw2ctMQqfDkIhUEA==",- "dev": true,- "license": "MIT",- "dependencies": {- "mimic-function": "^5.0.1"- },- "engines": {- "node": ">=18"- },- "funding": {- "url": "https://github.com/sindresorhus/memoize?sponsor=1"- }- },- "node_modules/mimic-function": {- "version": "5.0.1",- "resolved": "https://registry.npmjs.org/mimic-function/-/mimic-function-5.0.1.tgz",- "integrity": "sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA==",- "dev": true,- "license": "MIT",- "engines": {- "node": ">=18"- },- "funding": {- "url": "https://github.com/sponsors/sindresorhus"- }- },"node_modules/minimatch": {"version": "3.1.2","resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",@@ -4202,13 +3787,6 @@"node": ">=4"}},- "node_modules/robust-predicates": {- "version": "3.0.2",- "resolved": "https://registry.npmjs.org/robust-predicates/-/robust-predicates-3.0.2.tgz",- "integrity": "sha512-IXgzBWvWQwE6PrDI05OvmXUIruQTcoMDzRsOd5CDvHCVLcLHMTSYvOK5Cm46kWqlV3yAbuSpBZdJ5oP5OUoStg==",- "dev": true,- "license": "Unlicense"- },"node_modules/rollup": {"version": "4.54.0","resolved": "https://registry.npmjs.org/rollup/-/rollup-4.54.0.tgz",@@ -4276,13 +3854,6 @@}}},- "node_modules/rw": {- "version": "1.3.3",- "resolved": "https://registry.npmjs.org/rw/-/rw-1.3.3.tgz",- "integrity": "sha512-PdhdWy89SiZogBLaw42zdeqtRJ//zFd2PgQavcICDUgJT5oW10QCRKbJ6bg4r0/UY2M6BWd5tkxuGFRvCkgfHQ==",- "dev": true,- "license": "BSD-3-Clause"- },"node_modules/sade": {"version": "1.8.1","resolved": "https://registry.npmjs.org/sade/-/sade-1.8.1.tgz",@@ -4296,13 +3867,6 @@"node": ">=6"}},- "node_modules/safer-buffer": {- "version": "2.1.2",- "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",- "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",- "dev": true,- "license": "MIT"- },"node_modules/semver": {"version": "7.7.3","resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz",diff --git a/frontend/package.json b/frontend/package.jsonindex caab85a3..9c2acce7 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -38,7 +38,6 @@"eslint-config-prettier": "^10.1.8","eslint-plugin-svelte": "^3.13.1","globals": "^16.5.0",- "layerchart": "^2.0.0-next.43","prettier": "^3.7.4","prettier-plugin-svelte": "^3.4.0","prettier-plugin-tailwindcss": "^0.7.2",@@ -53,10 +52,10 @@"vite": "^7.2.6"},"dependencies": {+ "@sveltejs/svelte-json-tree": "^2.2.1","lucide-svelte": "^0.562.0","luxon": "^3.7.2","svelte-highlight": "^7.9.0",- "@sveltejs/svelte-json-tree": "^2.2.1","svelte-sonner": "^1.0.7"}}diff --git a/frontend/src/lib/components/dashboard/d3-line-chart.svelte b/frontend/src/lib/components/dashboard/d3-line-chart.sveltenew file mode 100644index 00000000..85aa8d42--- /dev/null+++ b/frontend/src/lib/components/dashboard/d3-line-chart.svelte@@ -0,0 +1,579 @@+<script lang="ts">+ import { scaleUtc, scaleLinear, type NumberValue } from 'd3-scale';+ import { line } from 'd3-shape';+ import { min, max } from 'd3-array';+ import { formatDateTime } from '$lib/utils/formatters';+ import { getTimezone } from '$lib/state/timezone.svelte';++ type DataPoint = {+ timestamp: Date;+ value: number;+ };++ type Series = {+ key: string;+ data: DataPoint[];+ color: string;+ };++ type ServerData = {+ serverName: string;+ trend: DataPoint[];+ };++ let {+ series = [],+ xDomain = null,+ height = 220,+ padding = { top: 10, right: 4, bottom: 20, left: 45 },+ // Overlay props+ onRangeSelect,+ data = [],+ servers = [],+ serverColorMap = {},+ unit = '',+ formatValue,+ sharedHoverTime = null,+ isSourceChart = false,+ onHoverTimeChange+ } = $props<{+ series: Series[];+ xDomain?: [Date, Date] | null;+ height?: number;+ padding?: { top: number; right: number; bottom: number; left: number };+ // Overlay props+ onRangeSelect?: (from: Date, to: Date) => void;+ data?: DataPoint[];+ servers?: ServerData[];+ serverColorMap?: Record<string, string>;+ unit?: string;+ formatValue?: (value: number) => string;+ sharedHoverTime?: Date | null;+ isSourceChart?: boolean;+ onHoverTimeChange?: (time: Date | null) => void;+ }>();++ const tz = $derived(getTimezone());++ let containerRef = $state<HTMLDivElement | null>(null);+ let width = $state(300);++ // Hover state+ let isHovering = $state(false);+ let mouseX = $state(0);++ // Drag selection state+ let isDragging = $state(false);+ let dragStartX = $state(0);+ let dragEndX = $state(0);++ // Observe container width+ $effect(() => {+ if (!containerRef) return;++ const observer = new ResizeObserver((entries) => {+ for (const entry of entries) {+ width = entry.contentRect.width;+ }+ });++ observer.observe(containerRef);+ return () => observer.disconnect();+ });++ // Chart dimensions+ const chartWidth = $derived(Math.max(0, width - padding.left - padding.right));+ const chartHeight = $derived(Math.max(0, height - padding.top - padding.bottom));++ // Calculate domains from data+ const allData = $derived(series.flatMap((s: Series) => s.data));++ const xMin = $derived(xDomain?.[0] ?? min(allData, (d: DataPoint) => d.timestamp) ?? new Date());+ const xMax = $derived(xDomain?.[1] ?? max(allData, (d: DataPoint) => d.timestamp) ?? new Date());++ const yMin = $derived(() => {+ const minVal = min(allData, (d: DataPoint) => d.value);+ return typeof minVal === 'number' ? minVal : 0;+ });++ const yMax = $derived(() => {+ const maxVal = max(allData, (d: DataPoint) => d.value);+ return typeof maxVal === 'number' ? maxVal : 0;+ });++ // Add padding to y domain+ const yPadding = $derived((yMax() - yMin()) * 0.1 || 1);+ const yDomainMin = $derived(Math.max(0, yMin() - yPadding));+ const yDomainMax = $derived(yMax() + yPadding);++ // Scales+ const xScale = $derived(+ scaleUtc()+ .domain([xMin, xMax])+ .range([0, chartWidth])+ );++ const yScale = $derived(+ scaleLinear()+ .domain([yDomainMin, yDomainMax])+ .range([chartHeight, 0])+ );++ // Generate Y axis ticks+ const yTicks = $derived(() => yScale.ticks(4));++ // Format Y axis label+ function formatYLabel(value: number): string {+ if (value >= 1000000) return (value / 1000000).toFixed(1) + 'M';+ if (value >= 1000) return (value / 1000).toFixed(1) + 'k';+ if (Number.isInteger(value)) return value.toString();+ return value.toFixed(1);+ }++ // Generate path string for a series+ function generatePath(seriesData: DataPoint[]): string {+ if (seriesData.length === 0) return '';++ const lineGen = line<DataPoint>()+ .x(d => xScale(d.timestamp))+ .y(d => yScale(d.value));++ return lineGen(seriesData) || '';+ }++ const hasData = $derived(allData.length > 0);++ // Check if we have multi-server data+ const hasMultiServerData = $derived(servers && servers.length > 1);++ // Check if mouse X is within the chart area+ function isInChartArea(): boolean {+ return mouseX >= padding.left && mouseX <= width - padding.right;+ }++ // Calculate time based on X position+ function getTimeAtPosition(x: number): Date {+ if (chartWidth <= 0) return xMin;+ const chartX = x - padding.left;+ const percentage = Math.max(0, Math.min(1, chartX / chartWidth));+ const timeDiff = xMax.getTime() - xMin.getTime();+ return new Date(xMin.getTime() + timeDiff * percentage);+ }++ // Calculate X position based on time+ function getPositionAtTime(time: Date): number {+ if (chartWidth <= 0) return padding.left;+ const timeDiff = xMax.getTime() - xMin.getTime();+ if (timeDiff <= 0) return padding.left;+ const percentage = (time.getTime() - xMin.getTime()) / timeDiff;+ return padding.left + (percentage * chartWidth);+ }++ // Calculate gap threshold from data (2x median interval)+ function getGapThreshold(pointData: DataPoint[]): number {+ if (pointData.length < 2) return 3600000;+ const intervals: number[] = [];+ for (let i = 1; i < Math.min(pointData.length, 10); i++) {+ intervals.push(pointData[i].timestamp.getTime() - pointData[i - 1].timestamp.getTime());+ }+ intervals.sort((a, b) => a - b);+ return intervals[Math.floor(intervals.length / 2)] * 2;+ }++ // Break data into line segments at gaps (for gap-aware rendering)+ function getLineSegments(pointData: DataPoint[]): DataPoint[][] {+ if (pointData.length === 0) return [];++ const threshold = getGapThreshold(pointData);+ const segments: DataPoint[][] = [];+ let currentSegment: DataPoint[] = [pointData[0]];++ for (let i = 1; i < pointData.length; i++) {+ const gap = pointData[i].timestamp.getTime() - pointData[i - 1].timestamp.getTime();+ if (gap > threshold) {+ if (currentSegment.length > 0) segments.push(currentSegment);+ currentSegment = [pointData[i]];+ } else {+ currentSegment.push(pointData[i]);+ }+ }++ if (currentSegment.length > 0) segments.push(currentSegment);+ return segments;+ }++ // Find isolated points (points with gaps on both sides)+ function getIsolatedPoints(pointData: DataPoint[]): DataPoint[] {+ if (pointData.length === 0) return [];+ if (pointData.length === 1) return pointData;++ const threshold = getGapThreshold(pointData);+ const isolated: DataPoint[] = [];++ for (let i = 0; i < pointData.length; i++) {+ const hasGapBefore = i === 0 ||+ (pointData[i].timestamp.getTime() - pointData[i - 1].timestamp.getTime() > threshold);+ const hasGapAfter = i === pointData.length - 1 ||+ (pointData[i + 1].timestamp.getTime() - pointData[i].timestamp.getTime() > threshold);++ if (hasGapBefore && hasGapAfter) {+ isolated.push(pointData[i]);+ }+ }++ return isolated;+ }++ // Find the value at a given time, interpolating for line sections+ function getValueAtTime(time: Date, pointData: DataPoint[]): { value: number; isInterpolated: boolean } | null {+ if (pointData.length === 0) return null;++ const targetMs = time.getTime();+ const threshold = getGapThreshold(pointData);++ let leftIdx = -1;+ let rightIdx = -1;++ for (let i = 0; i < pointData.length; i++) {+ const pointMs = pointData[i].timestamp.getTime();+ if (pointMs <= targetMs) leftIdx = i;+ if (pointMs >= targetMs && rightIdx === -1) rightIdx = i;+ }++ if (leftIdx >= 0 && pointData[leftIdx].timestamp.getTime() === targetMs) {+ return { value: pointData[leftIdx].value, isInterpolated: false };+ }++ if (leftIdx >= 0 && rightIdx >= 0 && leftIdx !== rightIdx) {+ const leftPoint = pointData[leftIdx];+ const rightPoint = pointData[rightIdx];+ const gap = rightPoint.timestamp.getTime() - leftPoint.timestamp.getTime();++ if (gap <= threshold) {+ const t = (targetMs - leftPoint.timestamp.getTime()) / gap;+ const interpolatedValue = leftPoint.value + t * (rightPoint.value - leftPoint.value);+ return { value: interpolatedValue, isInterpolated: true };+ }+ }++ if (leftIdx >= 0) {+ const distToLeft = targetMs - pointData[leftIdx].timestamp.getTime();+ if (distToLeft <= threshold / 2) {+ return { value: pointData[leftIdx].value, isInterpolated: false };+ }+ }++ if (rightIdx >= 0) {+ const distToRight = pointData[rightIdx].timestamp.getTime() - targetMs;+ if (distToRight <= threshold / 2) {+ return { value: pointData[rightIdx].value, isInterpolated: false };+ }+ }++ return null;+ }++ // Calculate time based on mouse X position+ const calculatedTime = $derived(() => {+ if (!isHovering) return null;+ return getTimeAtPosition(mouseX);+ });++ // Calculate the value at the current hover position+ const calculatedValue = $derived(() => {+ const time = calculatedTime();+ if (!time) return null;+ return getValueAtTime(time, data);+ });++ // Calculate values for all servers at the current hover position+ const calculatedServerValues = $derived(() => {+ const time = calculatedTime();+ if (!time || !hasMultiServerData) return [];++ const results: { serverName: string; value: number; color: string }[] = [];++ for (const server of servers) {+ const valueData = getValueAtTime(time, server.trend);+ if (valueData) {+ results.push({+ serverName: server.serverName,+ value: valueData.value,+ color: serverColorMap[server.serverName] || '#888888'+ });+ }+ }++ return results;+ });++ // Shadow line+ const shouldShowShadowLine = $derived(+ sharedHoverTime !== null && !isSourceChart && !isDragging && !isHovering+ );++ const shadowLineX = $derived(() => {+ if (!shouldShowShadowLine || !sharedHoverTime) return 0;+ return getPositionAtTime(sharedHoverTime);+ });++ // Format value for display - returns { text, includesUnit }+ function formatDisplayValue(value: number): { text: string; includesUnit: boolean } {+ if (formatValue) return { text: formatValue(value), includesUnit: true };+ if (Number.isInteger(value)) return { text: value.toString(), includesUnit: false };+ if (Math.abs(value) < 0.01) return { text: value.toFixed(4), includesUnit: false };+ if (Math.abs(value) < 1) return { text: value.toFixed(2), includesUnit: false };+ if (Math.abs(value) < 10) return { text: value.toFixed(1), includesUnit: false };+ return { text: Math.round(value).toString(), includesUnit: false };+ }++ // Selection region computed values+ const selectionLeft = $derived(Math.max(padding.left, Math.min(dragStartX, dragEndX)));+ const selectionRight = $derived(() => Math.min(width - padding.right, Math.max(dragStartX, dragEndX)));+ const selectionWidth = $derived(selectionRight() - selectionLeft);+ const selectionStartTime = $derived(() => getTimeAtPosition(selectionLeft));+ const selectionEndTime = $derived(() => getTimeAtPosition(selectionLeft + selectionWidth));++ function handleMouseMove(e: MouseEvent) {+ if (!containerRef) return;+ const rect = containerRef.getBoundingClientRect();+ mouseX = e.clientX - rect.left;++ if (isDragging) {+ dragEndX = mouseX;+ } else if (isInChartArea()) {+ onHoverTimeChange?.(getTimeAtPosition(mouseX));+ }+ }++ function handleMouseEnter() {+ isHovering = true;+ }++ function handleMouseLeave() {+ isHovering = false;+ if (isDragging) isDragging = false;+ onHoverTimeChange?.(null);+ }++ function handleMouseDown(e: MouseEvent) {+ if (!containerRef || e.button !== 0) return;+ const rect = containerRef.getBoundingClientRect();+ const x = e.clientX - rect.left;++ if (x < padding.left || x > rect.width - padding.right) return;++ isDragging = true;+ dragStartX = x;+ dragEndX = x;+ e.preventDefault();+ }++ function handleMouseUp() {+ if (!isDragging) return;++ isDragging = false;++ if (selectionWidth > 10 && onRangeSelect) {+ const startTime = getTimeAtPosition(Math.min(dragStartX, dragEndX));+ const endTime = getTimeAtPosition(Math.max(dragStartX, dragEndX));+ onRangeSelect(startTime, endTime);+ }+ }++ function formatTime(date: Date | null): string {+ if (!date) return '';+ return formatDateTime(date, { timezone: tz, format: 'time' });+ }++ function handleKeydown(e: KeyboardEvent) {+ if (e.key === 'Escape' && isDragging) {+ isDragging = false;+ dragStartX = 0;+ dragEndX = 0;+ }+ }++ $effect(() => {+ if (isDragging) {+ window.addEventListener('keydown', handleKeydown);+ return () => window.removeEventListener('keydown', handleKeydown);+ }+ });+</script>++<div+ bind:this={containerRef}+ class="relative select-none w-full"+ style="height: {height}px; cursor: {isDragging ? 'col-resize' : (isInChartArea() ? 'crosshair' : 'default')};"+ onmouseenter={handleMouseEnter}+ onmouseleave={handleMouseLeave}+ onmousemove={handleMouseMove}+ onmousedown={handleMouseDown}+ onmouseup={handleMouseUp}+ role="application"+ aria-label="Chart with drag-to-zoom"+>+ {#if hasData && chartWidth > 0}+ <svg {width} {height}>+ <g transform="translate({padding.left}, {padding.top})">+ <!-- Y axis grid lines -->+ {#each yTicks() as tick}+ <line+ x1={0}+ y1={yScale(tick)}+ x2={chartWidth}+ y2={yScale(tick)}+ stroke="#e5e7eb"+ stroke-width="1"+ stroke-dasharray="4 4"+ />+ {/each}++ <!-- Y axis labels -->+ {#each yTicks() as tick}+ <text+ x={-8}+ y={yScale(tick)}+ text-anchor="end"+ dominant-baseline="middle"+ fill="#6b7280"+ font-size="10"+ >+ {formatYLabel(tick)}+ </text>+ {/each}++ <!-- X axis line -->+ <line+ x1={0}+ y1={chartHeight}+ x2={chartWidth}+ y2={chartHeight}+ stroke="#e5e7eb"+ stroke-width="1"+ />++ <!-- Y axis line -->+ <line+ x1={0}+ y1={0}+ x2={0}+ y2={chartHeight}+ stroke="#e5e7eb"+ stroke-width="1"+ />++ <!-- 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"+ />+ {/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}+ </g>+ </svg>+ {:else}+ <div class="flex h-full items-center justify-center text-sm text-muted-foreground">+ No data in this period+ </div>+ {/if}++ <!-- Drag selection overlay -->+ {#if isDragging && selectionWidth > 0}+ <div+ class="absolute top-0 bottom-0 bg-primary/20 border-x border-primary/40 pointer-events-none"+ style="left: {selectionLeft}px; width: {selectionWidth}px;"+ >+ <div class="absolute -top-5 left-0 -translate-x-full text-[9px] font-medium text-primary whitespace-nowrap">+ {formatTime(selectionStartTime())}+ </div>+ <div class="absolute -top-5 right-0 translate-x-full text-[9px] font-medium text-primary whitespace-nowrap">+ {formatTime(selectionEndTime())}+ </div>+ </div>+ {/if}++ <!-- Hover tooltip -->+ {#if isHovering && !isDragging && isInChartArea()}+ {@const clampedX = Math.max(padding.left, Math.min(mouseX, width - padding.right))}+ {@const valueData = calculatedValue()}++ <!-- Vertical line -->+ <div+ class="absolute top-0 bottom-0 w-px bg-muted-foreground/50 pointer-events-none"+ style="left: {clampedX}px;"+ ></div>++ <!-- Value tooltip -->+ {#if hasMultiServerData && calculatedServerValues().length > 0}+ <div+ class="absolute top-0 -translate-x-1/2 -translate-y-full pointer-events-none"+ style="left: {clampedX}px;"+ >+ <div class="bg-foreground text-background rounded px-2 py-1 text-xs font-medium whitespace-nowrap shadow-lg mb-1 flex flex-col gap-0.5">+ {#each calculatedServerValues() as serverValue}+ {@const formatted = formatDisplayValue(serverValue.value)}+ <div class="flex items-center gap-1.5">+ <span class="h-2 w-2 rounded-full flex-shrink-0" style="background-color: {serverValue.color};"></span>+ <span>{formatted.text}{#if unit && !formatted.includesUnit}<span class="text-background/70 ml-0.5">{unit}</span>{/if}</span>+ </div>+ {/each}+ </div>+ </div>+ {:else if valueData}+ {@const formatted = formatDisplayValue(valueData.value)}+ <div+ class="absolute top-0 -translate-x-1/2 -translate-y-full pointer-events-none"+ style="left: {clampedX}px;"+ >+ <div class="bg-foreground text-background rounded px-2 py-1 text-xs font-medium whitespace-nowrap shadow-lg mb-1">+ {formatted.text}{#if unit && !formatted.includesUnit}<span class="text-background/70 ml-0.5">{unit}</span>{/if}+ </div>+ </div>+ {/if}++ <!-- Time label -->+ <div+ class="absolute bottom-0 -translate-x-1/2 translate-y-full pointer-events-none"+ style="left: {clampedX}px;"+ >+ <div class="bg-background border border-border rounded px-1.5 py-0.5 text-[10px] text-muted-foreground whitespace-nowrap shadow-sm mt-1">+ {formatTime(calculatedTime())}+ </div>+ </div>+ {/if}++ <!-- Shadow line from other charts -->+ {#if shouldShowShadowLine}+ {@const shadowX = shadowLineX()}+ {#if shadowX >= padding.left && shadowX <= width - padding.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/metric-card.svelte b/frontend/src/lib/components/dashboard/metric-card.svelteindex 0abd92ce..2bc7cdb4 100644--- a/frontend/src/lib/components/dashboard/metric-card.svelte+++ b/frontend/src/lib/components/dashboard/metric-card.svelte@@ -1,11 +1,8 @@<script lang="ts">import * as Card from '$lib/components/ui/card';- import * as Chart from "$lib/components/ui/chart/index.js";- import { LineChart, Points, Spline } from 'layerchart';- import { scaleUtc } from 'd3-scale';import type { DashboardMetric, MetricTrendPoint, ServerMetricTrend } from '$lib/types/dashboard';import { min, max } from 'd3-array';- import MetricChartOverlay from './metric-chart-overlay.svelte';+ import D3LineChart from './d3-line-chart.svelte';let {metric,@@ -30,10 +27,8 @@metric.servers && metric.servers.length > 1);-// Smart number formatting based on unit typefunction formatMetricValue(value: number, unit: string): string {- // Percentagesif (unit === '%') {if (value === 0) return '0';if (Math.abs(value) < 0.1) return value.toFixed(2);@@ -41,7 +36,6 @@return Math.round(value).toString();}- // Durations (ms)if (unit === 'ms') {if (value < 1) return (value * 1000).toFixed(0);if (value < 10) return value.toFixed(1);@@ -49,68 +43,26 @@return (value / 1000).toFixed(1);}- // Countsif (unit === 'count' || unit === '') {if (value >= 1_000_000) return (value / 1_000_000).toFixed(1) + 'M';if (value >= 1_000) return (value / 1_000).toFixed(1) + 'K';return Math.round(value).toString();}- // Memory (MB) - convert to GB for large valuesif (unit === 'MB') {if (value >= 1024) return (value / 1024).toFixed(1) + ' GB';return Math.round(value).toString() + ' MB';}- // Default: round to 1 decimalif (Number.isInteger(value)) return value.toString();return value.toFixed(1);}- // Generate chart config based on servers or single value- const chartConfig = $derived(() => {- if (hasMultiServerData && metric.servers) {- const config: Chart.ChartConfig = {};- for (const server of metric.servers) {- config[server.serverName] = {- label: server.serverName,- color: serverColorMap[server.serverName] || 'var(--chart-1)'- };- }- return config;- }- return {- value: { label: "Value", color: "var(--chart-1)" }- } satisfies Chart.ChartConfig;- });-- // Calculate yMin/yMax considering multi-server data- const yMin = $derived((): number => {- if (hasMultiServerData && metric.servers) {- const allValues = metric.servers.flatMap((s: ServerMetricTrend) => s.trend.map((t: MetricTrendPoint) => t.value));- const minVal = min(allValues);- return typeof minVal === 'number' ? minVal : 0;- }- const minVal = min(metric.trend, (d: MetricTrendPoint) => d.value);- return typeof minVal === 'number' ? minVal : 0;- });- const yMax = $derived((): number => {- if (hasMultiServerData && metric.servers) {- const allValues = metric.servers.flatMap((s: ServerMetricTrend) => s.trend.map((t: MetricTrendPoint) => t.value));- const maxVal = max(allValues);- return typeof maxVal === 'number' ? maxVal : 0;- }- const maxVal = max(metric.trend, (d: MetricTrendPoint) => d.value);- return typeof maxVal === 'number' ? maxVal : 0;- });- const padding = $derived((yMax() - yMin()) * 0.1 || 1);-// Calculate X domain from timeDomain or dataconst xDomainValue = $derived(() => {if (timeDomain) {return timeDomain;}- // Fallback to data rangeif (metric.trend.length > 0) {const minTime = min(metric.trend, (d: MetricTrendPoint) => d.timestamp);const maxTime = max(metric.trend, (d: MetricTrendPoint) => d.timestamp);@@ -121,330 +73,57 @@return undefined;});- // Calculate expected interval from actual data and use 2x as gap threshold- const gapThresholdMs = $derived(() => {- if (metric.trend.length < 2) return 3600000; // 1 hour default- const intervals: number[] = [];- for (let i = 1; i < Math.min(metric.trend.length, 10); i++) {- intervals.push(metric.trend[i].timestamp.getTime() - metric.trend[i - 1].timestamp.getTime());- }- intervals.sort((a, b) => a - b);- const median = intervals[Math.floor(intervals.length / 2)];- return median * 2; // Gap threshold = 2x median interval- });-- // Create lookup set for gap points - marks points that have a gap before them- const gapPoints = $derived(() => {- const gaps = new Set<number>();- const threshold = gapThresholdMs();- for (let i = 1; i < metric.trend.length; i++) {- const gap = metric.trend[i].timestamp.getTime() - metric.trend[i - 1].timestamp.getTime();- if (gap > threshold) {- // Mark the point AFTER the gap as "undefined" to break the line- gaps.add(metric.trend[i].timestamp.getTime());- }- }- return gaps;- });-- // Function to determine if a point should be connected to the previous point- // A point is "defined" (line should be drawn TO it) if there's no gap before it- function isDefined(d: MetricTrendPoint): boolean {- return !gapPoints().has(d.timestamp.getTime());- }-- // Calculate isolated points - points that have gaps BOTH before AND after them- // These are the only points that should show dots- const isolatedPoints = $derived(() => {- if (metric.trend.length === 0) return [];- if (metric.trend.length === 1) return metric.trend; // Single point is always isolated-- const threshold = gapThresholdMs();- const isolated: MetricTrendPoint[] = [];-- for (let i = 0; i < metric.trend.length; i++) {- const hasGapBefore = i === 0 ||- (metric.trend[i].timestamp.getTime() - metric.trend[i - 1].timestamp.getTime() > threshold);- const hasGapAfter = i === metric.trend.length - 1 ||- (metric.trend[i + 1].timestamp.getTime() - metric.trend[i].timestamp.getTime() > threshold);-- if (hasGapBefore && hasGapAfter) {- isolated.push(metric.trend[i]);- }+ // Build series array for the chart+ const chartSeries = $derived(() => {+ if (hasMultiServerData && metric.servers) {+ return metric.servers.map((server: ServerMetricTrend) => ({+ key: server.serverName,+ data: server.trend,+ color: serverColorMap[server.serverName] || '#3b82f6'+ }));}-- return isolated;+ return [{+ key: 'value',+ data: metric.trend,+ color: '#3b82f6'+ }];});const hasData = $derived(() => {if (hasMultiServerData && metric.servers) {- return metric.servers.some((s: ServerMetricTrend) => s.trend.length > 0 && s.trend.some((t: MetricTrendPoint) => t.value !== 0));+ return metric.servers.some((s: ServerMetricTrend) => s.trend.length > 0);}- return metric.trend.length > 0 && metric.trend.some((d: MetricTrendPoint) => d.value !== 0);+ return metric.trend.length > 0;});-- // Build merged data and series for multi-server charts- const multiServerChartData = $derived(() => {- if (!hasMultiServerData || !metric.servers) return [];-- // Merge all server data by timestamp- const timeMap = new Map<number, Record<string, number>>();-- for (const server of metric.servers) {- for (const point of server.trend) {- const timestamp = point.timestamp.getTime();- if (!timeMap.has(timestamp)) {- timeMap.set(timestamp, { timestamp } as any);- }- timeMap.get(timestamp)![server.serverName] = point.value;- }- }-- // Convert to sorted array- return Array.from(timeMap.values())- .map(entry => ({- ...entry,- timestamp: new Date(entry.timestamp as unknown as number)- }))- .sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime());- });-- const multiServerSeries = $derived(() => {- if (!hasMultiServerData || !metric.servers) return [];- return metric.servers.map((server: ServerMetricTrend) => ({- key: server.serverName,- label: server.serverName,- color: serverColorMap[server.serverName] || 'var(--chart-1)'- }));- });-- // Per-server gap detection for multi-server charts- const perServerGapData = $derived(() => {- if (!hasMultiServerData || !metric.servers) return new Map<string, {- gapPoints: Set<number>;- isolatedPoints: { timestamp: Date; value: number }[];- }>();-- const result = new Map<string, {- gapPoints: Set<number>;- isolatedPoints: { timestamp: Date; value: number }[];- }>();-- for (const server of metric.servers) {- const trend = server.trend;- if (trend.length < 2) {- result.set(server.serverName, {- gapPoints: new Set(),- isolatedPoints: trend.map((t: MetricTrendPoint) => ({ timestamp: t.timestamp, value: t.value }))- });- continue;- }-- // Calculate threshold for this server (2x median interval)- const intervals: number[] = [];- for (let i = 1; i < Math.min(trend.length, 10); i++) {- intervals.push(trend[i].timestamp.getTime() - trend[i - 1].timestamp.getTime());- }- intervals.sort((a, b) => a - b);- const threshold = intervals[Math.floor(intervals.length / 2)] * 2;-- // Calculate gap points (timestamps where line should break)- const serverGapPoints = new Set<number>();- for (let i = 1; i < trend.length; i++) {- const gap = trend[i].timestamp.getTime() - trend[i - 1].timestamp.getTime();- if (gap > threshold) {- serverGapPoints.add(trend[i].timestamp.getTime());- }- }-- // Calculate isolated points (gaps both before AND after)- const isolated: { timestamp: Date; value: number }[] = [];- for (let i = 0; i < trend.length; i++) {- const hasGapBefore = i === 0 ||- (trend[i].timestamp.getTime() - trend[i - 1].timestamp.getTime() > threshold);- const hasGapAfter = i === trend.length - 1 ||- (trend[i + 1].timestamp.getTime() - trend[i].timestamp.getTime() > threshold);- if (hasGapBefore && hasGapAfter) {- isolated.push({ timestamp: trend[i].timestamp, value: trend[i].value });- }- }-- result.set(server.serverName, { gapPoints: serverGapPoints, isolatedPoints: isolated });- }-- return result;- });-- // Helper to get defined function for a specific server- function getServerDefined(serverName: string) {- return (d: any) => {- // Check if value exists for this server at this point- const value = d[serverName];- if (value === undefined || value === null || Number.isNaN(value)) {- return false;- }- // Also check gap points- const gapData = perServerGapData().get(serverName);- if (!gapData) return true;- const timestamp = d.timestamp instanceof Date ? d.timestamp.getTime() : d.timestamp;- return !gapData.gapPoints.has(timestamp);- };- }</script>-<Card.Root class="gap-3 pb-0">- <Card.Header class="pb-2">+<Card.Root class="gap-0 pb-0">+ <Card.Header class="pb-0"><Card.Title class="text-sm font-medium">{metric.name}</Card.Title></Card.Header>- <Card.Content class="p-1 pt-0 pl-3">-- <!-- Large Value Display -->-- <!-- Sparkline Chart -->-- <!-- <Chart- data={metric.trend}- x={(d: MetricTrendPoint) => d.timestamp}- xScale={scaleUtc()}- y={(d: MetricTrendPoint) => d.value}- yScale={scaleLinear()}- padding={{ top: 4, bottom: 4, left: 0, right: 0 }}- >- <Svg>- <Area- line={{ stroke: 'hsl(var(--chart-1))', 'stroke-width': 2 }}- area={{ fill: 'none' }}- />- </Svg>- </Chart> -->-- <MetricChartOverlay- fromTime={xDomainValue()?.[0] ?? new Date()}- toTime={xDomainValue()?.[1] ?? new Date()}+ <Card.Content class="p-1 pt-0">+ {#if hasData()}+ <D3LineChart+ series={chartSeries()}+ xDomain={xDomainValue()}+ height={220}+ padding={{ top: 10, right: 4, bottom: 20, left: 45 }}{onRangeSelect}data={metric.trend}servers={metric.servers}{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()}- {#if hasMultiServerData}- <!-- Multi-server chart with per-server gap handling -->- <LineChart- data={multiServerChartData()}- x="timestamp"- xScale={scaleUtc()}- xDomain={xDomainValue()}- series={multiServerSeries()}- yDomain={[Math.max(0, yMin() - padding), yMax() + padding]}- seriesLayout="overlap"- axis={true}- rule={true}- grid={{ x: false, y: { style: '--stroke-color: hsl(var(--border));' } }}- props={{- xAxis: {- format: () => "",- rule: true- },- yAxis: {- format: (a: number) => {- if (a >= 1000000) return (a / 1000000).toFixed(1) + "M";- if (a >= 1000) return (a / 1000).toFixed(1) + "k";- return Number.isInteger(a) ? a.toString() : a.toFixed(1);- },- rule: true- }- }}- tooltip={false}- >- {#snippet spline({ props, seriesIndex })}- {@const serverName = multiServerSeries()[seriesIndex]?.key}- <Spline {...props} defined={getServerDefined(serverName)} />- {/snippet}-- {#snippet aboveMarks()}- <!-- Per-server isolated points -->- {#each metric.servers ?? [] as server}- {@const gapData = perServerGapData().get(server.serverName)}- {@const color = serverColorMap[server.serverName] || 'var(--chart-1)'}- {#if gapData && gapData.isolatedPoints.length > 0}- <Points- data={gapData.isolatedPoints}- x="timestamp"- y="value"- r={2}- fill={color}- />- {/if}- {/each}- {/snippet}- </LineChart>- {:else}- <!-- Single series chart (original behavior) -->- <LineChart- data={metric.trend}- x="timestamp"- xScale={scaleUtc()}- xDomain={xDomainValue()}- series={[- {- key: "value",- label: "Value",- color: "var(--chart-1)",- },- ]}- yDomain={[Math.max(0, yMin() - padding), yMax() + padding]}- seriesLayout="stack"- axis={true}- rule={true}- grid={{ x: false, y: { style: '--stroke-color: hsl(var(--border));' } }}- props={{- xAxis: {- format: () => "",- rule: true- },- yAxis: {- format: (a: number) => {- if (a >= 1000000) return (a / 1000000).toFixed(1) + "M";- if (a >= 1000) return (a / 1000).toFixed(1) + "k";- return Number.isInteger(a) ? a.toString() : a.toFixed(1);- },- rule: true- },- spline: {- defined: isDefined- }- }}- tooltip={false}- >- {#snippet aboveMarks()}- <!-- Isolated points (dots only where no line) -->- {#if isolatedPoints().length > 0}- <Points- data={isolatedPoints()}- x="timestamp"- y="value"- r={2}- fill="var(--chart-1)"- />- {/if}- {/snippet}- </LineChart>- {/if}- {:else}- <div class="flex h-[100px] items-center justify-center text-sm text-muted-foreground">- No data in this period- </div>- {/if}- </Chart.Container>- </MetricChartOverlay>+ />+ {:else}+ <div class="flex h-[220px] items-center justify-center text-sm text-muted-foreground">+ No data in this period+ </div>+ {/if}</Card.Content></Card.Root>diff --git a/frontend/src/lib/components/dashboard/metric-chart-overlay.svelte b/frontend/src/lib/components/dashboard/metric-chart-overlay.sveltedeleted file mode 100644index 1d6ba39d..00000000--- a/frontend/src/lib/components/dashboard/metric-chart-overlay.svelte+++ /dev/null@@ -1,490 +0,0 @@-<script lang="ts">- import type { Snippet } from 'svelte';- import { formatDateTime } from '$lib/utils/formatters';- import { getTimezone } from '$lib/state/timezone.svelte';-- type DataPoint = {- timestamp: Date;- value: number;- };-- type ServerData = {- serverName: string;- trend: DataPoint[];- };-- let {- fromTime,- toTime,- children,- onRangeSelect,- chartPadding = { left: 20, right: 4 },- data = [],- servers = [],- serverColorMap = {},- unit = '',- formatValue,- timezone,- chartId = '',- sharedHoverTime = null,- isSourceChart = false,- onHoverTimeChange- } = $props<{- fromTime: Date;- toTime: Date;- children: Snippet;- onRangeSelect?: (from: Date, to: Date) => void;- chartPadding?: { left: number; right: number };- data?: DataPoint[];- servers?: ServerData[];- serverColorMap?: Record<string, string>;- 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- const hasMultiServerData = $derived(servers && servers.length > 1);-- const tz = $derived(timezone ?? getTimezone());-- let containerRef = $state<HTMLDivElement | null>(null);- let isHovering = $state(false);- let mouseX = $state(0);- let mouseY = $state(0);-- // Drag selection state- let isDragging = $state(false);- let dragStartX = $state(0);- let dragEndX = $state(0);-- // Calculate gap threshold from data (2x median interval)- const gapThresholdMs = $derived(() => {- if (data.length < 2) return 3600000; // 1 hour default- const intervals: number[] = [];- for (let i = 1; i < Math.min(data.length, 10); i++) {- intervals.push(data[i].timestamp.getTime() - data[i - 1].timestamp.getTime());- }- intervals.sort((a, b) => a - b);- const median = intervals[Math.floor(intervals.length / 2)];- return median * 2;- });-- // Get container width- function getContainerWidth(): number {- return containerRef?.getBoundingClientRect().width ?? 0;- }-- // Get the actual chart plotting area width (container minus padding on both sides)- function getChartAreaWidth(): number {- return getContainerWidth() - chartPadding.left - chartPadding.right;- }-- // Check if mouse X is within the chart area- function isInChartArea(): boolean {- return mouseX >= chartPadding.left && mouseX <= getContainerWidth() - chartPadding.right;- }-- // Calculate time based on X position (relative to chart area, not container)- function getTimeAtPosition(x: number): Date {- if (!containerRef) return fromTime;- const chartAreaWidth = getChartAreaWidth();- if (chartAreaWidth <= 0) return fromTime;- // Adjust x to be relative to chart area start- const chartX = x - chartPadding.left;- const percentage = Math.max(0, Math.min(1, chartX / chartAreaWidth));- const timeDiff = toTime.getTime() - fromTime.getTime();- 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;-- const targetMs = time.getTime();- const threshold = gapThresholdMs();-- // Find the bracketing points- let leftIdx = -1;- let rightIdx = -1;-- for (let i = 0; i < data.length; i++) {- const pointMs = data[i].timestamp.getTime();- if (pointMs <= targetMs) {- leftIdx = i;- }- if (pointMs >= targetMs && rightIdx === -1) {- rightIdx = i;- }- }-- // If exact match- if (leftIdx >= 0 && data[leftIdx].timestamp.getTime() === targetMs) {- return { value: data[leftIdx].value, isInterpolated: false };- }-- // If we have both bracketing points- if (leftIdx >= 0 && rightIdx >= 0 && leftIdx !== rightIdx) {- const leftPoint = data[leftIdx];- const rightPoint = data[rightIdx];- const gap = rightPoint.timestamp.getTime() - leftPoint.timestamp.getTime();-- // Check if this is a continuous line section (no gap)- if (gap <= threshold) {- // Interpolate linearly- const t = (targetMs - leftPoint.timestamp.getTime()) / gap;- const interpolatedValue = leftPoint.value + t * (rightPoint.value - leftPoint.value);- return { value: interpolatedValue, isInterpolated: true };- }- }-- // Check if we're close to a single point (for isolated points or edges)- if (leftIdx >= 0) {- const leftPoint = data[leftIdx];- const distToLeft = targetMs - leftPoint.timestamp.getTime();- if (distToLeft <= threshold / 2) {- return { value: leftPoint.value, isInterpolated: false };- }- }-- if (rightIdx >= 0) {- const rightPoint = data[rightIdx];- const distToRight = rightPoint.timestamp.getTime() - targetMs;- if (distToRight <= threshold / 2) {- return { value: rightPoint.value, isInterpolated: false };- }- }-- return null; // In a gap, no value to show- }-- // Calculate time based on mouse X position (for hover display)- const calculatedTime = $derived(() => {- if (!containerRef || !isHovering) return null;- return getTimeAtPosition(mouseX);- });-- // Calculate the value at the current hover position (for single-server)- const calculatedValue = $derived(() => {- const time = calculatedTime();- if (!time) return null;- return getValueAtTime(time);- });-- // Get value at time for a specific server's data- function getServerValueAtTime(serverData: DataPoint[], time: Date): { value: number; isInterpolated: boolean } | null {- if (serverData.length === 0) return null;-- const targetMs = time.getTime();-- // Calculate threshold for this server- let threshold = 3600000;- if (serverData.length >= 2) {- const intervals: number[] = [];- for (let i = 1; i < Math.min(serverData.length, 10); i++) {- intervals.push(serverData[i].timestamp.getTime() - serverData[i - 1].timestamp.getTime());- }- intervals.sort((a, b) => a - b);- threshold = intervals[Math.floor(intervals.length / 2)] * 2;- }-- // Find the bracketing points- let leftIdx = -1;- let rightIdx = -1;-- for (let i = 0; i < serverData.length; i++) {- const pointMs = serverData[i].timestamp.getTime();- if (pointMs <= targetMs) {- leftIdx = i;- }- if (pointMs >= targetMs && rightIdx === -1) {- rightIdx = i;- }- }-- // If exact match- if (leftIdx >= 0 && serverData[leftIdx].timestamp.getTime() === targetMs) {- return { value: serverData[leftIdx].value, isInterpolated: false };- }-- // If we have both bracketing points- if (leftIdx >= 0 && rightIdx >= 0 && leftIdx !== rightIdx) {- const leftPoint = serverData[leftIdx];- const rightPoint = serverData[rightIdx];- const gap = rightPoint.timestamp.getTime() - leftPoint.timestamp.getTime();-- if (gap <= threshold) {- const t = (targetMs - leftPoint.timestamp.getTime()) / gap;- const interpolatedValue = leftPoint.value + t * (rightPoint.value - leftPoint.value);- return { value: interpolatedValue, isInterpolated: true };- }- }-- // Check if we're close to a single point- if (leftIdx >= 0) {- const leftPoint = serverData[leftIdx];- const distToLeft = targetMs - leftPoint.timestamp.getTime();- if (distToLeft <= threshold / 2) {- return { value: leftPoint.value, isInterpolated: false };- }- }-- if (rightIdx >= 0) {- const rightPoint = serverData[rightIdx];- const distToRight = rightPoint.timestamp.getTime() - targetMs;- if (distToRight <= threshold / 2) {- return { value: rightPoint.value, isInterpolated: false };- }- }-- return null;- }-- // Calculate values for all servers at the current hover position- const calculatedServerValues = $derived(() => {- const time = calculatedTime();- if (!time || !hasMultiServerData) return [];-- const results: { serverName: string; value: number; color: string }[] = [];-- for (const server of servers) {- const valueData = getServerValueAtTime(server.trend, time);- if (valueData) {- results.push({- serverName: server.serverName,- value: valueData.value,- color: serverColorMap[server.serverName] || '#888888'- });- }- }-- 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) {- return formatValue(value);- }- // Default formatting based on value magnitude- if (Number.isInteger(value)) return value.toString();- if (Math.abs(value) < 0.01) return value.toFixed(4);- if (Math.abs(value) < 1) return value.toFixed(2);- if (Math.abs(value) < 10) return value.toFixed(1);- return Math.round(value).toString();- }-- // Selection region computed values (clamped to chart area)- const selectionLeft = $derived(Math.max(chartPadding.left, Math.min(dragStartX, dragEndX)));- const selectionRight = $derived(() => {- return Math.min(getContainerWidth() - chartPadding.right, Math.max(dragStartX, dragEndX));- });- const selectionWidth = $derived(selectionRight() - selectionLeft);- const selectionStartTime = $derived(() => getTimeAtPosition(selectionLeft));- const selectionEndTime = $derived(() => getTimeAtPosition(selectionLeft + selectionWidth));-- function handleMouseMove(e: MouseEvent) {- if (!containerRef) return;- const rect = containerRef.getBoundingClientRect();- mouseX = e.clientX - rect.left;- mouseY = e.clientY - rect.top;-- if (isDragging) {- dragEndX = mouseX;- } else if (isInChartArea()) {- onHoverTimeChange?.(getTimeAtPosition(mouseX));- }- }-- function handleMouseEnter() {- isHovering = true;- }-- function handleMouseLeave() {- isHovering = false;- // Cancel drag if mouse leaves- if (isDragging) {- isDragging = false;- }- onHoverTimeChange?.(null);- }-- function handleMouseDown(e: MouseEvent) {- if (!containerRef || e.button !== 0) return; // Only left click- const rect = containerRef.getBoundingClientRect();- const x = e.clientX - rect.left;-- // Only start drag if within chart area- if (x < chartPadding.left || x > rect.width - chartPadding.right) return;-- isDragging = true;- dragStartX = x;- dragEndX = x;-- // Prevent text selection during drag- e.preventDefault();- }-- function handleMouseUp(e: MouseEvent) {- if (!isDragging || !containerRef) return;-- isDragging = false;-- // Only trigger if selection is meaningful (at least 10px)- if (selectionWidth > 10 && onRangeSelect) {- const startTime = getTimeAtPosition(Math.min(dragStartX, dragEndX));- const endTime = getTimeAtPosition(Math.max(dragStartX, dragEndX));- onRangeSelect(startTime, endTime);- }- }-- // Format time for display- function formatTime(date: Date | null): string {- 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- bind:this={containerRef}- class="relative select-none"- onmouseenter={handleMouseEnter}- onmouseleave={handleMouseLeave}- onmousemove={handleMouseMove}- onmousedown={handleMouseDown}- onmouseup={handleMouseUp}- role="application"- aria-label="Chart with drag-to-zoom"- style="cursor: {isDragging ? 'col-resize' : (isInChartArea() ? 'crosshair' : 'default')};"->- {@render children()}-- {#if isDragging && selectionWidth > 0}- <!-- Selection region overlay -->- <div- class="absolute top-0 bottom-0 bg-primary/20 border-x border-primary/40 pointer-events-none"- style="left: {selectionLeft}px; width: {selectionWidth}px;"- >- <!-- Selection time labels -->- <div class="absolute -top-5 left-0 -translate-x-full text-[9px] font-medium text-primary whitespace-nowrap">- {formatTime(selectionStartTime())}- </div>- <div class="absolute -top-5 right-0 translate-x-full text-[9px] font-medium text-primary whitespace-nowrap">- {formatTime(selectionEndTime())}- </div>- </div>- {/if}-- {#if isHovering && !isDragging && isInChartArea()}- {@const clampedX = Math.max(chartPadding.left, Math.min(mouseX, getContainerWidth() - chartPadding.right))}- {@const valueData = calculatedValue()}-- <!-- Vertical line at mouse X position (clamped to chart area) -->- <div- class="absolute top-0 bottom-0 w-px bg-muted-foreground/50 pointer-events-none"- style="left: {clampedX}px;"- ></div>-- <!-- Value tooltip at top -->- {#if hasMultiServerData && calculatedServerValues().length > 0}- <!-- Multi-server tooltip -->- <div- class="absolute top-0 -translate-x-1/2 -translate-y-full pointer-events-none"- style="left: {clampedX}px;"- >- <div- class="bg-foreground text-background rounded px-2 py-1 text-xs font-medium whitespace-nowrap shadow-lg mb-1 flex flex-col gap-0.5"- >- {#each calculatedServerValues() as serverValue}- <div class="flex items-center gap-1.5">- <span- class="h-2 w-2 rounded-full flex-shrink-0"- style="background-color: {serverValue.color};"- ></span>- <span>{formatDisplayValue(serverValue.value)}{#if unit}<span class="text-background/70 ml-0.5">{unit}</span>{/if}</span>- </div>- {/each}- </div>- </div>- {:else if valueData}- <!-- Single-server tooltip -->- <div- class="absolute top-0 -translate-x-1/2 -translate-y-full pointer-events-none"- style="left: {clampedX}px;"- >- <div- class="bg-foreground text-background rounded px-2 py-1 text-xs font-medium whitespace-nowrap shadow-lg mb-1"- >- {formatDisplayValue(valueData.value)}{#if unit}<span class="text-background/70 ml-0.5">{unit}</span>{/if}- </div>- </div>- {/if}-- <!-- Time label at bottom, positioned at mouse X -->- <div- class="absolute bottom-0 -translate-x-1/2 translate-y-full pointer-events-none"- style="left: {clampedX}px;"- >- <div- class="bg-background border border-border rounded px-1.5 py-0.5 text-[10px] text-muted-foreground whitespace-nowrap shadow-sm mt-1"- >- {formatTime(calculatedTime())}- </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/ui/chart/chart-container.svelte b/frontend/src/lib/components/ui/chart/chart-container.sveltedeleted file mode 100644index d4599597..00000000--- a/frontend/src/lib/components/ui/chart/chart-container.svelte+++ /dev/null@@ -1,78 +0,0 @@-<script lang="ts">- import { cn, type WithElementRef } from "$lib/utils.js";- import type { HTMLAttributes } from "svelte/elements";- import ChartStyle from "./chart-style.svelte";- import { setChartContext, type ChartConfig } from "./chart-utils.js";-- const uid = $props.id();-- let {- ref = $bindable(null),- id = uid,- class: className,- children,- config,- ...restProps- }: WithElementRef<HTMLAttributes<HTMLElement>> & {- config: ChartConfig;- } = $props();-- const chartId = `chart-${id || uid.replace(/:/g, "")}`;-- setChartContext({- get config() {- return config;- },- });-</script>--<div- bind:this={ref}- data-chart={chartId}- data-slot="chart"- class={cn(- "flex aspect-video justify-center overflow-visible text-xs",- // Overrides- //- // Stroke around dots/marks when hovering- "[&_.lc-highlight-point]:stroke-transparent",- // override the default stroke color of lines- "[&_.lc-line]:stroke-border/50",-- // by default, layerchart shows a line intersecting the point when hovering, this hides that- "[&_.lc-highlight-line]:stroke-0",-- // by default, when you hover a point on a stacked series chart, it will drop the opacity- // of the other series, this overrides that- "[&_.lc-area-path]:opacity-100 [&_.lc-highlight-line]:opacity-100 [&_.lc-highlight-point]:opacity-100 [&_.lc-spline-path]:opacity-100 [&_.lc-text]:text-xs [&_.lc-text-svg]:overflow-visible",-- // We don't want the little tick lines between the axis labels and the chart, so we remove- // the stroke. The alternative is to manually disable `tickMarks` on the x/y axis of every- // chart.- "[&_.lc-axis-tick]:stroke-0",-- // Show axis lines (X on bottom, Y on left)- "[&_.lc-rule-x-line:not(.lc-grid-x-rule)]:stroke-[#c8cdd4] [&_.lc-rule-y-line:not(.lc-grid-y-rule)]:stroke-[#c8cdd4]",- "[&_.lc-grid-x-radial-line]:stroke-border [&_.lc-grid-x-radial-circle]:stroke-border",- "[&_.lc-grid-y-radial-line]:stroke-border [&_.lc-grid-y-radial-circle]:stroke-border",-- // Legend adjustments- "[&_.lc-legend-swatch-button]:items-center [&_.lc-legend-swatch-button]:gap-1.5",- "[&_.lc-legend-swatch-group]:items-center [&_.lc-legend-swatch-group]:gap-4",- "[&_.lc-legend-swatch]:size-2.5 [&_.lc-legend-swatch]:rounded-[2px]",-- // Labels- "[&_.lc-labels-text:not([fill])]:fill-foreground [&_text]:stroke-transparent",-- // Tick labels on th x/y axes- "[&_.lc-axis-tick-label]:fill-muted-foreground [&_.lc-axis-tick-label]:font-normal",- "[&_.lc-tooltip-rects-g]:fill-transparent",- "[&_.lc-layout-svg-g]:fill-transparent",- "[&_.lc-root-container]:w-full",- className- )}- {...restProps}->- <ChartStyle id={chartId} {config} />- {@render children?.()}-</div>diff --git a/frontend/src/lib/components/ui/chart/chart-style.svelte b/frontend/src/lib/components/ui/chart/chart-style.sveltedeleted file mode 100644index 864ecc31..00000000--- a/frontend/src/lib/components/ui/chart/chart-style.svelte+++ /dev/null@@ -1,37 +0,0 @@-<script lang="ts">- import { THEMES, type ChartConfig } from "./chart-utils.js";-- let { id, config }: { id: string; config: ChartConfig } = $props();-- const colorConfig = $derived(- config ? Object.entries(config).filter(([, config]) => config.theme || config.color) : null- );-- const themeContents = $derived.by(() => {- if (!colorConfig || !colorConfig.length) return;-- const themeContents = [];- for (let [_theme, prefix] of Object.entries(THEMES)) {- let content = `${prefix} [data-chart=${id}] {\n`;- const color = colorConfig.map(([key, itemConfig]) => {- const theme = _theme as keyof typeof itemConfig.theme;- const color = itemConfig.theme?.[theme] || itemConfig.color;- return color ? `\t--color-${key}: ${color};` : null;- });-- content += color.join("\n") + "\n}";-- themeContents.push(content);- }-- return themeContents.join("\n");- });-</script>--{#if themeContents}- {#key id}- <svelte:element this={"style"}>- {themeContents}- </svelte:element>- {/key}-{/if}diff --git a/frontend/src/lib/components/ui/chart/chart-tooltip.svelte b/frontend/src/lib/components/ui/chart/chart-tooltip.sveltedeleted file mode 100644index 6eb66ff1..00000000--- a/frontend/src/lib/components/ui/chart/chart-tooltip.svelte+++ /dev/null@@ -1,159 +0,0 @@-<script lang="ts">- import { cn, type WithElementRef, type WithoutChildren } from "$lib/utils.js";- import type { HTMLAttributes } from "svelte/elements";- import { getPayloadConfigFromPayload, useChart, type TooltipPayload } from "./chart-utils.js";- import { getTooltipContext, Tooltip as TooltipPrimitive } from "layerchart";- import type { Snippet } from "svelte";-- // eslint-disable-next-line @typescript-eslint/no-explicit-any- function defaultFormatter(value: any, _payload: TooltipPayload[]) {- return `${value}`;- }-- let {- ref = $bindable(null),- class: className,- hideLabel = false,- indicator = "dot",- hideIndicator = false,- labelKey,- label,- labelFormatter = defaultFormatter,- labelClassName,- formatter,- nameKey,- color,- ...restProps- }: WithoutChildren<WithElementRef<HTMLAttributes<HTMLDivElement>>> & {- hideLabel?: boolean;- label?: string;- indicator?: "line" | "dot" | "dashed";- nameKey?: string;- labelKey?: string;- hideIndicator?: boolean;- labelClassName?: string;- labelFormatter?: // eslint-disable-next-line @typescript-eslint/no-explicit-any- ((value: any, payload: TooltipPayload[]) => string | number | Snippet) | null;- formatter?: Snippet<- [- {- value: unknown;- name: string;- item: TooltipPayload;- index: number;- payload: TooltipPayload[];- },- ]- >;- } = $props();-- const chart = useChart();- const tooltipCtx = getTooltipContext();-- const formattedLabel = $derived.by(() => {- if (hideLabel || !tooltipCtx.payload?.length) return null;-- const [item] = tooltipCtx.payload;- const key = labelKey ?? item?.label ?? item?.name ?? "value";-- const itemConfig = getPayloadConfigFromPayload(chart.config, item, key);-- const value =- !labelKey && typeof label === "string"- ? (chart.config[label as keyof typeof chart.config]?.label ?? label)- : (itemConfig?.label ?? item.label);-- if (value === undefined) return null;- if (!labelFormatter) return value;- return labelFormatter(value, tooltipCtx.payload);- });-- const nestLabel = $derived(tooltipCtx.payload.length === 1 && indicator !== "dot");-</script>--{#snippet TooltipLabel()}- {#if formattedLabel}- <div class={cn("font-medium", labelClassName)}>- {#if typeof formattedLabel === "function"}- {@render formattedLabel()}- {:else}- {formattedLabel}- {/if}- </div>- {/if}-{/snippet}--<TooltipPrimitive.Root variant="none">- <div- class={cn(- "border-border/50 bg-background grid min-w-[9rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl",- className- )}- {...restProps}- >- {#if !nestLabel}- {@render TooltipLabel()}- {/if}- <div class="grid gap-1.5">- {#each tooltipCtx.payload as item, i (item.key + i)}- {@const key = `${nameKey || item.key || item.name || "value"}`}- {@const itemConfig = getPayloadConfigFromPayload(chart.config, item, key)}- {@const indicatorColor = color || item.payload?.color || item.color}- <div- class={cn(- "[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:size-2.5",- indicator === "dot" && "items-center"- )}- >- {#if formatter && item.value !== undefined && item.name}- {@render formatter({- value: item.value,- name: item.name,- item,- index: i,- payload: tooltipCtx.payload,- })}- {:else}- {#if itemConfig?.icon}- <itemConfig.icon />- {:else if !hideIndicator}- <div- style="--color-bg: {indicatorColor}; --color-border: {indicatorColor};"- class={cn(- "shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",- {- "size-2.5": indicator === "dot",- "h-full w-1": indicator === "line",- "w-0 border-[1.5px] border-dashed bg-transparent":- indicator === "dashed",- "my-0.5": nestLabel && indicator === "dashed",- }- )}- ></div>- {/if}- <div- class={cn(- "flex flex-1 shrink-0 justify-between leading-none",- nestLabel ? "items-end" : "items-center"- )}- >- <div class="grid gap-1.5">- {#if nestLabel}- {@render TooltipLabel()}- {/if}- <span class="text-muted-foreground">- {itemConfig?.label || item.name}- </span>- </div>- {#if item.value !== undefined}- <span class="text-foreground font-mono font-medium tabular-nums">- {item.value.toLocaleString()}- </span>- {/if}- </div>- {/if}- </div>- {/each}- </div>- </div>-</TooltipPrimitive.Root>diff --git a/frontend/src/lib/components/ui/chart/chart-utils.ts b/frontend/src/lib/components/ui/chart/chart-utils.tsdeleted file mode 100644index 2decbbf7..00000000--- a/frontend/src/lib/components/ui/chart/chart-utils.ts+++ /dev/null@@ -1,66 +0,0 @@-import type { Tooltip } from "layerchart";-import { getContext, setContext, type Component, type ComponentProps, type Snippet } from "svelte";--export const THEMES = { light: "", dark: ".dark" } as const;--export type ChartConfig = {- [k in string]: {- label?: string;- icon?: Component;- } & (- | { color?: string; theme?: never }- | { color?: never; theme: Record<keyof typeof THEMES, string> }- );-};--export type ExtractSnippetParams<T> = T extends Snippet<[infer P]> ? P : never;--export type TooltipPayload = ExtractSnippetParams<- ComponentProps<typeof Tooltip.Root>["children"]->["payload"][number];--// Helper to extract item config from a payload.-export function getPayloadConfigFromPayload(- config: ChartConfig,- payload: TooltipPayload,- key: string-) {- if (typeof payload !== "object" || payload === null) return undefined;-- const payloadPayload =- "payload" in payload && typeof payload.payload === "object" && payload.payload !== null- ? payload.payload- : undefined;-- let configLabelKey: string = key;-- if (payload.key === key) {- configLabelKey = payload.key;- } else if (payload.name === key) {- configLabelKey = payload.name;- } else if (key in payload && typeof payload[key as keyof typeof payload] === "string") {- configLabelKey = payload[key as keyof typeof payload] as string;- } else if (- payloadPayload !== undefined &&- key in payloadPayload &&- typeof payloadPayload[key as keyof typeof payloadPayload] === "string"- ) {- configLabelKey = payloadPayload[key as keyof typeof payloadPayload] as string;- }-- return configLabelKey in config ? config[configLabelKey] : config[key as keyof typeof config];-}--type ChartContextValue = {- config: ChartConfig;-};--const chartContextKey = Symbol("chart-context");--export function setChartContext(value: ChartContextValue) {- return setContext(chartContextKey, value);-}--export function useChart() {- return getContext<ChartContextValue>(chartContextKey);-}diff --git a/frontend/src/lib/components/ui/chart/index.ts b/frontend/src/lib/components/ui/chart/index.tsdeleted file mode 100644index f22375e0..00000000--- a/frontend/src/lib/components/ui/chart/index.ts+++ /dev/null@@ -1,6 +0,0 @@-import ChartContainer from "./chart-container.svelte";-import ChartTooltip from "./chart-tooltip.svelte";--export { getPayloadConfigFromPayload, type ChartConfig } from "./chart-utils.js";--export { ChartContainer, ChartTooltip, ChartContainer as Container, ChartTooltip as Tooltip };