diff --git a/.devcontainer/README.md b/.devcontainer/README.md new file mode 100644 index 0000000..05ee5ff --- /dev/null +++ b/.devcontainer/README.md @@ -0,0 +1,207 @@ +# DevContainer Setup für Thats-Me + +## Was ist ein DevContainer? + +Ein DevContainer ist eine vollständige Entwicklungsumgebung in Docker. Cursor/VSCode läuft direkt im Container und Sie entwickeln mit allen Tools, die bereits vorinstalliert sind. + +## Voraussetzungen + +1. **Docker Desktop** muss laufen +2. **Traefik Proxy** als externes Netzwerk: + ```bash + docker network create proxy + ``` + +## DevContainer starten + +1. **In Cursor/VSCode:** + + - Drücken Sie `Cmd+Shift+P` (macOS) oder `Ctrl+Shift+P` (Windows/Linux) + - Wählen Sie: **"Dev Containers: Reopen in Container"** + - Warten Sie, bis alle Container gebaut und gestartet sind + +2. **Beim ersten Start:** + - Der Laravel Container wird gebaut (kann einige Minuten dauern) + - Alle Services werden gestartet (MySQL, Redis, Mailpit, Quasar) + - Sie werden automatisch im Laravel Container eingeloggt + +## Was passiert beim Start? + +Der DevContainer startet folgende Services: + +- **laravel.test** - Laravel Backend (Sie arbeiten in diesem Container) +- **mysql** - Datenbank +- **redis** - Cache/Queue +- **mailpit** - E-Mail Testing +- **quasar.app** - Frontend App (läuft automatisch) + +## Arbeiten im Container + +### Terminal + +Das Terminal in Cursor/VSCode ist bereits im Container. Sie können direkt arbeiten: + +```bash +# Sie sind im /var/www/html Verzeichnis (= ./backend vom Host) +php artisan migrate +php artisan serve +composer install +npm install +npm run dev +``` + +### Verfügbare Services + +Im DevContainer können Sie direkt auf die anderen Services zugreifen: + +```bash +# MySQL Verbindung +mysql -h mysql -u sail -p +# Passwort: password + +# Redis +redis-cli -h redis + +# Composer +composer install +composer update + +# Artisan +php artisan migrate +php artisan tinker +``` + +## Zugriff von außerhalb + +### Von Ihrem Browser (Host) + +Die Ports werden automatisch weitergeleitet: + +- **Laravel App:** http://localhost (Port 80) +- **Vite Dev Server:** http://localhost:5173 +- **Mailpit Dashboard:** http://localhost:8025 +- **Quasar App:** http://localhost:9000 + +### Mit Traefik + +Wenn Traefik läuft, können Sie auch die Domains verwenden: + +- https://thats-me.test +- https://portal.thats-me.test +- https://api.thats-me.test +- https://app.thats-me.test +- https://assets.thats-me.test + +## Backend .env Konfiguration + +Stellen Sie sicher, dass `backend/.env` folgende Werte hat: + +```env +DB_CONNECTION=mysql +DB_HOST=mysql +DB_PORT=3306 +DB_DATABASE=thats-me +DB_USERNAME=sail +DB_PASSWORD=password + +MAIL_MAILER=smtp +MAIL_HOST=mailpit +MAIL_PORT=1025 + +REDIS_HOST=redis +REDIS_PORT=6379 +``` + +## Vite Dev Server starten + +```bash +# Im DevContainer Terminal +npm install +npm run dev +``` + +Vite läuft dann auf Port 5173 und ist verfügbar unter: + +- http://localhost:5173 (vom Host) +- https://assets.thats-me.test (mit Traefik) + +## Quasar App + +Die Quasar App läuft automatisch in einem separaten Container und ist verfügbar unter: + +- http://localhost:9000 (vom Host) +- https://app.thats-me.test (mit Traefik) + +## Troubleshooting + +### Container startet nicht + +```bash +# Schließen Sie den DevContainer +# Öffnen Sie ein normales Terminal auf dem Host +docker-compose down -v +docker-compose build --no-cache +# Dann neu starten: "Dev Containers: Reopen in Container" +``` + +### "Dockerfile not found" Fehler + +Stellen Sie sicher, dass Laravel Sail installiert ist: + +```bash +cd backend +composer require laravel/sail --dev +``` + +### Permission-Probleme + +Die User-IDs in `devcontainer.json` anpassen: + +```json +"containerEnv": { + "WWWUSER": "1000", // Ihre User-ID + "WWWGROUP": "1000" // Ihre Group-ID +} +``` + +Finden Sie Ihre IDs mit: + +```bash +id -u # User ID +id -g # Group ID +``` + +### Logs ansehen + +```bash +# Im DevContainer Terminal +docker-compose logs -f + +# Nur MySQL +docker-compose logs -f mysql + +# Nur Quasar +docker-compose logs -f quasar.app +``` + +## DevContainer verlassen + +1. Drücken Sie `Cmd+Shift+P` / `Ctrl+Shift+P` +2. Wählen Sie: **"Dev Containers: Reopen Folder Locally"** + +## Container stoppen + +Nach dem Verlassen des DevContainers: + +```bash +docker-compose down +``` + +## Vorteile des DevContainers + +✅ Alle arbeiten mit der gleichen Umgebung +✅ Keine lokale PHP/MySQL Installation nötig +✅ Automatische Service-Verwaltung +✅ Isolierte Entwicklungsumgebung +✅ Einfaches Onboarding für neue Entwickler + diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..840f882 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,94 @@ +{ + "name": "Thats-Me (Dev Container)", + // 1. DIES IST DER WICHTIGSTE TEIL: + // Wir verwenden Docker Compose für alle Services + "dockerComposeFile": [ + "../docker-compose.yml" + ], + "service": "laravel.test", + // 3. WIR DEFINIEREN DEN ARBEITSBEREICH: + // Wir mounten das gesamte Projekt, damit Sie Backend UND Frontend sehen + "workspaceFolder": "/workspace", + // 4. WIR LEGEN DEN BENUTZER FEST: + // Laravel Sail führt Befehle standardmäßig als 'sail'-Benutzer aus, um Berechtigungsprobleme zu vermeiden. + "remoteUser": "sail", + // 5. ZUSÄTZLICHE ENTWICKLER-TOOLS (FEATURES): + // Features werden über postCreateCommand installiert um Kompatibilitätsprobleme zu vermeiden + "features": {}, + // 6. BEFEHLE NACH DEM ERSTELLEN: + // Installiert nur die Tools die ohne Root-Rechte funktionieren + //"postCreateCommand": "composer install --no-interaction --prefer-dist --optimize-autoloader", + // 7. EDITOR-ANPASSUNGEN (Optional, aber sehr empfohlen): + "customizations": { + "vscode": { + "extensions": [ + "bmewburn.vscode-intelephense-client", + "onecentlin.laravel-blade", + "shufo.vscode-blade-formatter", + "bradlc.vscode-tailwindcss" + ] + } + }, + // 8. ZU STARTENDE DIENSTE: + // Legt fest, welche Dienste aus der docker-compose.yml gestartet werden sollen. + "runServices": [ + "laravel.test", + "quasar.app", + "mysql", + "redis", + "mailpit" + ], + // 9. ZUSÄTZLICHE KONFIGURATION: + // Umgebungsvariablen für den DevContainer + "containerEnv": { + "WWWUSER": "501", + "WWWGROUP": "20", + "LARAVEL_SAIL": "1" + }, + // 9b. MOUNTS: + // Mountet das gesamte Projekt (Root) nach /workspace, damit Sie Backend UND Frontend sehen + "mounts": [ + "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached" + ], + // 10. FORWARD PORTS: + // Ports die automatisch weitergeleitet werden sollen (Container-Ports) + "forwardPorts": [ + 80, + 5173, + 3306, + 6379, + 1025, + 8025, + 9000 + ], + "portsAttributes": { + "80": { + "label": "Laravel App (HTTP)", + "onAutoForward": "notify" + }, + "5173": { + "label": "Vite Dev Server", + "onAutoForward": "notify" + }, + "3306": { + "label": "MySQL", + "onAutoForward": "silent" + }, + "6379": { + "label": "Redis", + "onAutoForward": "silent" + }, + "8025": { + "label": "Mailpit Dashboard", + "onAutoForward": "notify" + }, + "1025": { + "label": "Mailpit SMTP", + "onAutoForward": "silent" + }, + "9000": { + "label": "Quasar App", + "onAutoForward": "notify" + } + } +} diff --git a/.gitignore b/.gitignore index df866ed..ce8cafa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,25 +1,58 @@ +# Laravel +/.phpunit.cache +/node_modules +/public/build +/public/hot +/public/storage +/public/vendor +/storage/*.key +/storage/app +/storage/framework +/storage/language +/storage/logs +/storage/pail +/vendor +.env +.env.backup +.env.production +.phpactor.json +.phpunit.result.cache +Homestead.json +Homestead.yaml +auth.json +npm-debug.log +yarn-error.log + +# IDEs & Editors +/.fleet +/.idea +/.nova +/.vscode +/.zed +.claude/ +.cursor/ + +# macOS .DS_Store -node_modules -/dist +.AppleDouble +.LSOverride +._* +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk +Icon -# local env files -.env.local -.env.*.local - -# Log files -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* - -# Editor directories and files -.idea -.vscode -*.suo -*.ntvs* -*.njsproj -*.sln -*.sw? -/.history -/deployment +# Project specific +_static/ +_work/ +_storage/ diff --git a/DOCKER-SETUP.md b/DOCKER-SETUP.md new file mode 100644 index 0000000..2a853c9 --- /dev/null +++ b/DOCKER-SETUP.md @@ -0,0 +1,296 @@ +# Docker Setup für Thats-Me Projekt + +## Übersicht + +Dieses Projekt verwendet Docker mit Laravel Sail für das Backend und einen Node-Container für die Quasar Frontend App. + +### Services + +- **laravel.test** - Laravel Backend (PHP 8.4) +- **quasar.app** - Quasar Frontend App (Node 20) +- **mysql** - MySQL 8.0 Database +- **mailpit** - E-Mail Testing Tool +- **redis** - Cache & Queue Service + +### Domains + +Das Setup konfiguriert 4 Domains über Traefik: + +1. **thats-me.test** - Laravel Webseite/Landingpage +2. **portal.thats-me.test** - Laravel Admin Panel +3. **api.thats-me.test** - Laravel API für Quasar App +4. **app.thats-me.test** - Quasar Frontend App + +Zusätzlich: + +- **assets.thats-me.test** - Vite Dev Server für Laravel Assets + +## Voraussetzungen + +1. **Docker Desktop** installiert +2. **Traefik Proxy** muss als externes Netzwerk verfügbar sein: + ```bash + docker network create proxy + ``` +3. **Laravel Sail** muss im Backend installiert sein: + ```bash + cd backend + composer require laravel/sail --dev + ``` + +## Installation + +### 1. Environment Dateien einrichten + +**Root .env Datei:** + +```bash +cp .env.docker .env +``` + +**Backend .env Datei:** + +```bash +cd backend +cp .env.example .env +php artisan key:generate +``` + +Bearbeite `backend/.env` und stelle sicher, dass diese Einstellungen gesetzt sind: + +```env +DB_CONNECTION=mysql +DB_HOST=mysql +DB_PORT=3306 +DB_DATABASE=thats-me +DB_USERNAME=sail +DB_PASSWORD=password + +MAIL_MAILER=smtp +MAIL_HOST=mailpit +MAIL_PORT=1025 + +REDIS_HOST=redis +REDIS_PORT=6379 +``` + +### 2. Hosts-Datei konfigurieren + +Füge folgende Einträge zu deiner `/etc/hosts` Datei hinzu: + +``` +127.0.0.1 thats-me.test +127.0.0.1 portal.thats-me.test +127.0.0.1 api.thats-me.test +127.0.0.1 app.thats-me.test +127.0.0.1 assets.thats-me.test +``` + +### 3. Docker Container starten + +```bash +docker-compose up -d +``` + +### 4. Laravel Installation abschließen + +Beim ersten Start: + +```bash +# In den Laravel Container einsteigen +docker-compose exec laravel.test bash + +# Composer Dependencies installieren +composer install + +# Datenbank migrieren +php artisan migrate + +# Optional: Seeder ausführen +php artisan db:seed +``` + +### 5. Frontend Dependencies installieren + +Der Quasar Container installiert automatisch die Dependencies beim Start. +Falls manuell nötig: + +```bash +docker-compose exec quasar.app npm install +``` + +## Verwendung + +### Container starten + +```bash +docker-compose up -d +``` + +### Container stoppen + +```bash +docker-compose down +``` + +### Logs ansehen + +```bash +# Alle Services +docker-compose logs -f + +# Nur Laravel +docker-compose logs -f laravel.test + +# Nur Quasar +docker-compose logs -f quasar.app +``` + +### In Container einsteigen + +**Laravel:** + +```bash +docker-compose exec laravel.test bash +``` + +**Quasar:** + +```bash +docker-compose exec quasar.app sh +``` + +**MySQL:** + +```bash +docker-compose exec mysql mysql -u sail -p +# Passwort: password +``` + +### Artisan Commands + +```bash +docker-compose exec laravel.test php artisan migrate +docker-compose exec laravel.test php artisan cache:clear +docker-compose exec laravel.test php artisan queue:work +``` + +### NPM Commands (Frontend) + +```bash +docker-compose exec quasar.app npm run dev +docker-compose exec quasar.app npm run build +``` + +## Zugriff auf die Anwendung + +### Mit Traefik (empfohlen) + +- **Hauptwebseite:** https://thats-me.test +- **Admin Portal:** https://portal.thats-me.test +- **API:** https://api.thats-me.test +- **Frontend App:** https://app.thats-me.test +- **Vite Assets:** https://assets.thats-me.test + +### Direkt über Ports + +- **Laravel App:** http://localhost (Port 80 über Traefik) +- **Vite Dev Server:** http://localhost:5179 (Host) → 5173 (Container) +- **Quasar App:** http://localhost:9000 +- **Mailpit Dashboard:** http://localhost:8028 +- **MySQL:** localhost:33070 +- **Redis:** localhost:6383 + +## Vite Development Server + +Um den Vite Dev Server für Laravel zu starten: + +```bash +docker-compose exec laravel.test npm install +docker-compose exec laravel.test npm run dev +``` + +Dann ist HMR (Hot Module Replacement) unter https://assets.thats-me.test verfügbar. + +## Troubleshooting + +### Proxy-Netzwerk existiert nicht + +```bash +docker network create proxy +``` + +### Port-Konflikte + +Ändere die Ports in der `.env` Datei: + +```env +FORWARD_DB_PORT=33071 +FORWARD_MAILPIT_DASHBOARD_PORT=8029 +QUASAR_PORT=9001 +VITE_PORT=5180 +``` + +### Permission-Probleme + +```bash +# User/Group IDs in .env anpassen +WWWUSER=1000 +WWWGROUP=1000 +``` + +### Container neu bauen + +```bash +docker-compose down -v +docker-compose build --no-cache +docker-compose up -d +``` + +### Quasar startet nicht + +```bash +# Manuell im Container starten +docker-compose exec quasar.app sh +cd /app +npm install +npm run dev +``` + +## Entwicklung ohne Traefik + +Falls Sie kein Traefik haben, können Sie die Container auch direkt über Ports erreichen: + +1. Entfernen Sie die `labels` Sektion aus `docker-compose.yml` +2. Aktivieren Sie den Port-Mapping für Laravel: + ```yaml + ports: + - "${APP_PORT:-80}:80" + - "${VITE_PORT:-5173}:5173" + ``` +3. Zugriff dann über: + - Laravel: http://localhost + - Vite: http://localhost:5173 + - Quasar: http://localhost:9000 + +## Nützliche Befehle + +```bash +# Container Status +docker-compose ps + +# Container neu starten +docker-compose restart + +# Bestimmten Service neu starten +docker-compose restart laravel.test + +# Container und Volumes löschen +docker-compose down -v + +# Logs von heute +docker-compose logs --since 24h + +# Ressourcen-Nutzung +docker stats +``` diff --git a/README.md b/README.md index 159c8b4..ad4cd7b 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,13 @@ Eine kurze Beschreibung, was dieses Projekt macht (ein oder zwei Sätze). +## Domains auf dem Testserver + +app.thats-me.test = frontend Quasar APP +portal.thats-me.test = backend Laravel Admin Panel mit Tailwind CSS + FluxUI +thats-me.test = backend Laravel Webseite / Landinpage mit Tailwind CSS + FluxUI +api.thats-me.test = backend Laravel API für Quasar APP + ## Inhaltsverzeichnis - [Start des Projekts](#start) @@ -93,4 +100,4 @@ Erkläre, wie andere zum Projekt beitragen können. Gibt es Richtlinien für Pul Gib an, unter welcher Lizenz das Projekt veröffentlicht wird. Zum Beispiel: -Dieses Projekt ist unter der MIT-Lizenz lizenziert - siehe die [LICENSE.md](LICENSE.md)-Datei für Details (falls vorhanden). \ No newline at end of file +Dieses Projekt ist unter der MIT-Lizenz lizenziert - siehe die [LICENSE.md](LICENSE.md)-Datei für Details (falls vorhanden). diff --git a/backend/composer.json b/backend/composer.json index e0a0e24..8915653 100644 --- a/backend/composer.json +++ b/backend/composer.json @@ -19,7 +19,7 @@ "fakerphp/faker": "^1.23", "laravel/pail": "^1.2.2", "laravel/pint": "^1.18", - "laravel/sail": "^1.41", + "laravel/sail": "^1.46", "mockery/mockery": "^1.6", "nunomaduro/collision": "^8.6", "pestphp/pest": "^3.7", @@ -74,4 +74,4 @@ }, "minimum-stability": "stable", "prefer-stable": true -} \ No newline at end of file +} diff --git a/backend/composer.lock b/backend/composer.lock index 1554f64..70d226f 100644 --- a/backend/composer.lock +++ b/backend/composer.lock @@ -4,29 +4,29 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b17142323a68267a6e0b99a3d80c5654", + "content-hash": "9ec434279d6b443c6a5865f46b13b717", "packages": [ { "name": "brick/math", - "version": "0.12.3", + "version": "0.14.0", "source": { "type": "git", "url": "https://github.com/brick/math.git", - "reference": "866551da34e9a618e64a819ee1e01c20d8a588ba" + "reference": "113a8ee2656b882d4c3164fa31aa6e12cbb7aaa2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/brick/math/zipball/866551da34e9a618e64a819ee1e01c20d8a588ba", - "reference": "866551da34e9a618e64a819ee1e01c20d8a588ba", + "url": "https://api.github.com/repos/brick/math/zipball/113a8ee2656b882d4c3164fa31aa6e12cbb7aaa2", + "reference": "113a8ee2656b882d4c3164fa31aa6e12cbb7aaa2", "shasum": "" }, "require": { - "php": "^8.1" + "php": "^8.2" }, "require-dev": { "php-coveralls/php-coveralls": "^2.2", - "phpunit/phpunit": "^10.1", - "vimeo/psalm": "6.8.8" + "phpstan/phpstan": "2.1.22", + "phpunit/phpunit": "^11.5" }, "type": "library", "autoload": { @@ -56,7 +56,7 @@ ], "support": { "issues": "https://github.com/brick/math/issues", - "source": "https://github.com/brick/math/tree/0.12.3" + "source": "https://github.com/brick/math/tree/0.14.0" }, "funding": [ { @@ -64,7 +64,7 @@ "type": "github" } ], - "time": "2025-02-28T13:11:00+00:00" + "time": "2025-08-29T12:40:03+00:00" }, { "name": "carbonphp/carbon-doctrine-types", @@ -212,33 +212,32 @@ }, { "name": "doctrine/inflector", - "version": "2.0.10", + "version": "2.1.0", "source": { "type": "git", "url": "https://github.com/doctrine/inflector.git", - "reference": "5817d0659c5b50c9b950feb9af7b9668e2c436bc" + "reference": "6d6c96277ea252fc1304627204c3d5e6e15faa3b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/inflector/zipball/5817d0659c5b50c9b950feb9af7b9668e2c436bc", - "reference": "5817d0659c5b50c9b950feb9af7b9668e2c436bc", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/6d6c96277ea252fc1304627204c3d5e6e15faa3b", + "reference": "6d6c96277ea252fc1304627204c3d5e6e15faa3b", "shasum": "" }, "require": { "php": "^7.2 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^11.0", - "phpstan/phpstan": "^1.8", - "phpstan/phpstan-phpunit": "^1.1", - "phpstan/phpstan-strict-rules": "^1.3", - "phpunit/phpunit": "^8.5 || ^9.5", - "vimeo/psalm": "^4.25 || ^5.4" + "doctrine/coding-standard": "^12.0 || ^13.0", + "phpstan/phpstan": "^1.12 || ^2.0", + "phpstan/phpstan-phpunit": "^1.4 || ^2.0", + "phpstan/phpstan-strict-rules": "^1.6 || ^2.0", + "phpunit/phpunit": "^8.5 || ^12.2" }, "type": "library", "autoload": { "psr-4": { - "Doctrine\\Inflector\\": "lib/Doctrine/Inflector" + "Doctrine\\Inflector\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -283,7 +282,7 @@ ], "support": { "issues": "https://github.com/doctrine/inflector/issues", - "source": "https://github.com/doctrine/inflector/tree/2.0.10" + "source": "https://github.com/doctrine/inflector/tree/2.1.0" }, "funding": [ { @@ -299,7 +298,7 @@ "type": "tidelift" } ], - "time": "2024-02-18T20:23:39+00:00" + "time": "2025-08-10T19:31:58+00:00" }, { "name": "doctrine/lexer", @@ -645,22 +644,22 @@ }, { "name": "guzzlehttp/guzzle", - "version": "7.9.3", + "version": "7.10.0", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "7b2f29fe81dc4da0ca0ea7d42107a0845946ea77" + "reference": "b51ac707cfa420b7bfd4e4d5e510ba8008e822b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/7b2f29fe81dc4da0ca0ea7d42107a0845946ea77", - "reference": "7b2f29fe81dc4da0ca0ea7d42107a0845946ea77", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/b51ac707cfa420b7bfd4e4d5e510ba8008e822b4", + "reference": "b51ac707cfa420b7bfd4e4d5e510ba8008e822b4", "shasum": "" }, "require": { "ext-json": "*", - "guzzlehttp/promises": "^1.5.3 || ^2.0.3", - "guzzlehttp/psr7": "^2.7.0", + "guzzlehttp/promises": "^2.3", + "guzzlehttp/psr7": "^2.8", "php": "^7.2.5 || ^8.0", "psr/http-client": "^1.0", "symfony/deprecation-contracts": "^2.2 || ^3.0" @@ -751,7 +750,7 @@ ], "support": { "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/7.9.3" + "source": "https://github.com/guzzle/guzzle/tree/7.10.0" }, "funding": [ { @@ -767,20 +766,20 @@ "type": "tidelift" } ], - "time": "2025-03-27T13:37:11+00:00" + "time": "2025-08-23T22:36:01+00:00" }, { "name": "guzzlehttp/promises", - "version": "2.2.0", + "version": "2.3.0", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "7c69f28996b0a6920945dd20b3857e499d9ca96c" + "reference": "481557b130ef3790cf82b713667b43030dc9c957" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/7c69f28996b0a6920945dd20b3857e499d9ca96c", - "reference": "7c69f28996b0a6920945dd20b3857e499d9ca96c", + "url": "https://api.github.com/repos/guzzle/promises/zipball/481557b130ef3790cf82b713667b43030dc9c957", + "reference": "481557b130ef3790cf82b713667b43030dc9c957", "shasum": "" }, "require": { @@ -788,7 +787,7 @@ }, "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", - "phpunit/phpunit": "^8.5.39 || ^9.6.20" + "phpunit/phpunit": "^8.5.44 || ^9.6.25" }, "type": "library", "extra": { @@ -834,7 +833,7 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/2.2.0" + "source": "https://github.com/guzzle/promises/tree/2.3.0" }, "funding": [ { @@ -850,20 +849,20 @@ "type": "tidelift" } ], - "time": "2025-03-27T13:27:01+00:00" + "time": "2025-08-22T14:34:08+00:00" }, { "name": "guzzlehttp/psr7", - "version": "2.7.1", + "version": "2.8.0", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "c2270caaabe631b3b44c85f99e5a04bbb8060d16" + "reference": "21dc724a0583619cd1652f673303492272778051" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/c2270caaabe631b3b44c85f99e5a04bbb8060d16", - "reference": "c2270caaabe631b3b44c85f99e5a04bbb8060d16", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/21dc724a0583619cd1652f673303492272778051", + "reference": "21dc724a0583619cd1652f673303492272778051", "shasum": "" }, "require": { @@ -879,7 +878,7 @@ "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", "http-interop/http-factory-tests": "0.9.0", - "phpunit/phpunit": "^8.5.39 || ^9.6.20" + "phpunit/phpunit": "^8.5.44 || ^9.6.25" }, "suggest": { "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" @@ -950,7 +949,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.7.1" + "source": "https://github.com/guzzle/psr7/tree/2.8.0" }, "funding": [ { @@ -966,20 +965,20 @@ "type": "tidelift" } ], - "time": "2025-03-27T12:30:47+00:00" + "time": "2025-08-23T21:21:41+00:00" }, { "name": "guzzlehttp/uri-template", - "version": "v1.0.4", + "version": "v1.0.5", "source": { "type": "git", "url": "https://github.com/guzzle/uri-template.git", - "reference": "30e286560c137526eccd4ce21b2de477ab0676d2" + "reference": "4f4bbd4e7172148801e76e3decc1e559bdee34e1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/uri-template/zipball/30e286560c137526eccd4ce21b2de477ab0676d2", - "reference": "30e286560c137526eccd4ce21b2de477ab0676d2", + "url": "https://api.github.com/repos/guzzle/uri-template/zipball/4f4bbd4e7172148801e76e3decc1e559bdee34e1", + "reference": "4f4bbd4e7172148801e76e3decc1e559bdee34e1", "shasum": "" }, "require": { @@ -988,7 +987,7 @@ }, "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", - "phpunit/phpunit": "^8.5.36 || ^9.6.15", + "phpunit/phpunit": "^8.5.44 || ^9.6.25", "uri-template/tests": "1.0.0" }, "type": "library", @@ -1036,7 +1035,7 @@ ], "support": { "issues": "https://github.com/guzzle/uri-template/issues", - "source": "https://github.com/guzzle/uri-template/tree/v1.0.4" + "source": "https://github.com/guzzle/uri-template/tree/v1.0.5" }, "funding": [ { @@ -1052,24 +1051,24 @@ "type": "tidelift" } ], - "time": "2025-02-03T10:55:03+00:00" + "time": "2025-08-22T14:27:06+00:00" }, { "name": "laravel/framework", - "version": "v12.4.1", + "version": "v12.34.0", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "cdefd852ecb459a65392cd6ccb578c92a15b8e2b" + "reference": "f9ec5a5d88bc8c468f17b59f88e05c8ac3c8d687" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/cdefd852ecb459a65392cd6ccb578c92a15b8e2b", - "reference": "cdefd852ecb459a65392cd6ccb578c92a15b8e2b", + "url": "https://api.github.com/repos/laravel/framework/zipball/f9ec5a5d88bc8c468f17b59f88e05c8ac3c8d687", + "reference": "f9ec5a5d88bc8c468f17b59f88e05c8ac3c8d687", "shasum": "" }, "require": { - "brick/math": "^0.11|^0.12", + "brick/math": "^0.11|^0.12|^0.13|^0.14", "composer-runtime-api": "^2.2", "doctrine/inflector": "^2.0.5", "dragonmantank/cron-expression": "^3.4", @@ -1086,7 +1085,7 @@ "guzzlehttp/uri-template": "^1.0", "laravel/prompts": "^0.3.0", "laravel/serializable-closure": "^1.3|^2.0", - "league/commonmark": "^2.6", + "league/commonmark": "^2.7", "league/flysystem": "^3.25.1", "league/flysystem-local": "^3.25.1", "league/uri": "^7.5.1", @@ -1105,7 +1104,9 @@ "symfony/http-kernel": "^7.2.0", "symfony/mailer": "^7.2.0", "symfony/mime": "^7.2.0", - "symfony/polyfill-php83": "^1.31", + "symfony/polyfill-php83": "^1.33", + "symfony/polyfill-php84": "^1.33", + "symfony/polyfill-php85": "^1.33", "symfony/process": "^7.2.0", "symfony/routing": "^7.2.0", "symfony/uid": "^7.2.0", @@ -1141,6 +1142,7 @@ "illuminate/filesystem": "self.version", "illuminate/hashing": "self.version", "illuminate/http": "self.version", + "illuminate/json-schema": "self.version", "illuminate/log": "self.version", "illuminate/macroable": "self.version", "illuminate/mail": "self.version", @@ -1173,12 +1175,13 @@ "league/flysystem-read-only": "^3.25.1", "league/flysystem-sftp-v3": "^3.25.1", "mockery/mockery": "^1.6.10", - "orchestra/testbench-core": "^10.0.0", - "pda/pheanstalk": "^5.0.6", + "opis/json-schema": "^2.4.1", + "orchestra/testbench-core": "^10.7.0", + "pda/pheanstalk": "^5.0.6|^7.0.0", "php-http/discovery": "^1.15", "phpstan/phpstan": "^2.0", "phpunit/phpunit": "^10.5.35|^11.5.3|^12.0.1", - "predis/predis": "^2.3", + "predis/predis": "^2.3|^3.0", "resend/resend-php": "^0.10.0", "symfony/cache": "^7.2.0", "symfony/http-client": "^7.2.0", @@ -1198,7 +1201,7 @@ "ext-pdo": "Required to use all database features.", "ext-posix": "Required to use all features of the queue worker.", "ext-redis": "Required to use the Redis cache and queue drivers (^4.0|^5.0|^6.0).", - "fakerphp/faker": "Required to use the eloquent factory builder (^1.9.1).", + "fakerphp/faker": "Required to generate fake data using the fake() helper (^1.23).", "filp/whoops": "Required for friendly error pages in development (^2.14.3).", "laravel/tinker": "Required to use the tinker console command (^2.0).", "league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (^3.25.1).", @@ -1210,7 +1213,7 @@ "pda/pheanstalk": "Required to use the beanstalk queue driver (^5.0).", "php-http/discovery": "Required to use PSR-7 bridging features (^1.15).", "phpunit/phpunit": "Required to use assertions and run tests (^10.5.35|^11.5.3|^12.0.1).", - "predis/predis": "Required to use the predis connector (^2.3).", + "predis/predis": "Required to use the predis connector (^2.3|^3.0).", "psr/http-message": "Required to allow Storage::put to accept a StreamInterface (^1.0).", "pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^6.0|^7.0).", "resend/resend-php": "Required to enable support for the Resend mail transport (^0.10.0).", @@ -1267,20 +1270,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2025-03-30T16:27:26+00:00" + "time": "2025-10-14T13:58:31+00:00" }, { "name": "laravel/prompts", - "version": "v0.3.5", + "version": "v0.3.7", "source": { "type": "git", "url": "https://github.com/laravel/prompts.git", - "reference": "57b8f7efe40333cdb925700891c7d7465325d3b1" + "reference": "a1891d362714bc40c8d23b0b1d7090f022ea27cc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/prompts/zipball/57b8f7efe40333cdb925700891c7d7465325d3b1", - "reference": "57b8f7efe40333cdb925700891c7d7465325d3b1", + "url": "https://api.github.com/repos/laravel/prompts/zipball/a1891d362714bc40c8d23b0b1d7090f022ea27cc", + "reference": "a1891d362714bc40c8d23b0b1d7090f022ea27cc", "shasum": "" }, "require": { @@ -1297,8 +1300,8 @@ "illuminate/collections": "^10.0|^11.0|^12.0", "mockery/mockery": "^1.5", "pestphp/pest": "^2.3|^3.4", - "phpstan/phpstan": "^1.11", - "phpstan/phpstan-mockery": "^1.1" + "phpstan/phpstan": "^1.12.28", + "phpstan/phpstan-mockery": "^1.1.3" }, "suggest": { "ext-pcntl": "Required for the spinner to be animated." @@ -1324,22 +1327,22 @@ "description": "Add beautiful and user-friendly forms to your command-line applications.", "support": { "issues": "https://github.com/laravel/prompts/issues", - "source": "https://github.com/laravel/prompts/tree/v0.3.5" + "source": "https://github.com/laravel/prompts/tree/v0.3.7" }, - "time": "2025-02-11T13:34:40+00:00" + "time": "2025-09-19T13:47:56+00:00" }, { "name": "laravel/serializable-closure", - "version": "v2.0.4", + "version": "v2.0.6", "source": { "type": "git", "url": "https://github.com/laravel/serializable-closure.git", - "reference": "b352cf0534aa1ae6b4d825d1e762e35d43f8a841" + "reference": "038ce42edee619599a1debb7e81d7b3759492819" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/b352cf0534aa1ae6b4d825d1e762e35d43f8a841", - "reference": "b352cf0534aa1ae6b4d825d1e762e35d43f8a841", + "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/038ce42edee619599a1debb7e81d7b3759492819", + "reference": "038ce42edee619599a1debb7e81d7b3759492819", "shasum": "" }, "require": { @@ -1387,7 +1390,7 @@ "issues": "https://github.com/laravel/serializable-closure/issues", "source": "https://github.com/laravel/serializable-closure" }, - "time": "2025-03-19T13:51:03+00:00" + "time": "2025-10-09T13:42:30+00:00" }, { "name": "laravel/tinker", @@ -1457,16 +1460,16 @@ }, { "name": "league/commonmark", - "version": "2.6.1", + "version": "2.7.1", "source": { "type": "git", "url": "https://github.com/thephpleague/commonmark.git", - "reference": "d990688c91cedfb69753ffc2512727ec646df2ad" + "reference": "10732241927d3971d28e7ea7b5712721fa2296ca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/d990688c91cedfb69753ffc2512727ec646df2ad", - "reference": "d990688c91cedfb69753ffc2512727ec646df2ad", + "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/10732241927d3971d28e7ea7b5712721fa2296ca", + "reference": "10732241927d3971d28e7ea7b5712721fa2296ca", "shasum": "" }, "require": { @@ -1495,7 +1498,7 @@ "symfony/process": "^5.4 | ^6.0 | ^7.0", "symfony/yaml": "^2.3 | ^3.0 | ^4.0 | ^5.0 | ^6.0 | ^7.0", "unleashedtech/php-coding-standard": "^3.1.1", - "vimeo/psalm": "^4.24.0 || ^5.0.0" + "vimeo/psalm": "^4.24.0 || ^5.0.0 || ^6.0.0" }, "suggest": { "symfony/yaml": "v2.3+ required if using the Front Matter extension" @@ -1503,7 +1506,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "2.7-dev" + "dev-main": "2.8-dev" } }, "autoload": { @@ -1560,7 +1563,7 @@ "type": "tidelift" } ], - "time": "2024-12-29T14:10:59+00:00" + "time": "2025-07-20T12:47:49+00:00" }, { "name": "league/config", @@ -1646,16 +1649,16 @@ }, { "name": "league/flysystem", - "version": "3.29.1", + "version": "3.30.0", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "edc1bb7c86fab0776c3287dbd19b5fa278347319" + "reference": "2203e3151755d874bb2943649dae1eb8533ac93e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/edc1bb7c86fab0776c3287dbd19b5fa278347319", - "reference": "edc1bb7c86fab0776c3287dbd19b5fa278347319", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/2203e3151755d874bb2943649dae1eb8533ac93e", + "reference": "2203e3151755d874bb2943649dae1eb8533ac93e", "shasum": "" }, "require": { @@ -1679,13 +1682,13 @@ "composer/semver": "^3.0", "ext-fileinfo": "*", "ext-ftp": "*", - "ext-mongodb": "^1.3", + "ext-mongodb": "^1.3|^2", "ext-zip": "*", "friendsofphp/php-cs-fixer": "^3.5", "google/cloud-storage": "^1.23", "guzzlehttp/psr7": "^2.6", "microsoft/azure-storage-blob": "^1.1", - "mongodb/mongodb": "^1.2", + "mongodb/mongodb": "^1.2|^2", "phpseclib/phpseclib": "^3.0.36", "phpstan/phpstan": "^1.10", "phpunit/phpunit": "^9.5.11|^10.0", @@ -1723,22 +1726,22 @@ ], "support": { "issues": "https://github.com/thephpleague/flysystem/issues", - "source": "https://github.com/thephpleague/flysystem/tree/3.29.1" + "source": "https://github.com/thephpleague/flysystem/tree/3.30.0" }, - "time": "2024-10-08T08:58:34+00:00" + "time": "2025-06-25T13:29:59+00:00" }, { "name": "league/flysystem-local", - "version": "3.29.0", + "version": "3.30.0", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem-local.git", - "reference": "e0e8d52ce4b2ed154148453d321e97c8e931bd27" + "reference": "6691915f77c7fb69adfb87dcd550052dc184ee10" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem-local/zipball/e0e8d52ce4b2ed154148453d321e97c8e931bd27", - "reference": "e0e8d52ce4b2ed154148453d321e97c8e931bd27", + "url": "https://api.github.com/repos/thephpleague/flysystem-local/zipball/6691915f77c7fb69adfb87dcd550052dc184ee10", + "reference": "6691915f77c7fb69adfb87dcd550052dc184ee10", "shasum": "" }, "require": { @@ -1772,9 +1775,9 @@ "local" ], "support": { - "source": "https://github.com/thephpleague/flysystem-local/tree/3.29.0" + "source": "https://github.com/thephpleague/flysystem-local/tree/3.30.0" }, - "time": "2024-08-09T21:24:39+00:00" + "time": "2025-05-21T10:34:19+00:00" }, { "name": "league/mime-type-detection", @@ -2008,16 +2011,16 @@ }, { "name": "livewire/flux", - "version": "v2.1.1", + "version": "v2.6.0", "source": { "type": "git", "url": "https://github.com/livewire/flux.git", - "reference": "f5b7169e4538039d59a750cdcc64494e2fc0729c" + "reference": "3cb2ea40978449da74b3814eeef75f0388124224" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/livewire/flux/zipball/f5b7169e4538039d59a750cdcc64494e2fc0729c", - "reference": "f5b7169e4538039d59a750cdcc64494e2fc0729c", + "url": "https://api.github.com/repos/livewire/flux/zipball/3cb2ea40978449da74b3814eeef75f0388124224", + "reference": "3cb2ea40978449da74b3814eeef75f0388124224", "shasum": "" }, "require": { @@ -2029,6 +2032,9 @@ "php": "^8.1", "symfony/console": "^6.0|^7.0" }, + "conflict": { + "livewire/blaze": "<0.1.0" + }, "type": "library", "extra": { "laravel": { @@ -2065,22 +2071,22 @@ ], "support": { "issues": "https://github.com/livewire/flux/issues", - "source": "https://github.com/livewire/flux/tree/v2.1.1" + "source": "https://github.com/livewire/flux/tree/v2.6.0" }, - "time": "2025-03-20T21:34:31+00:00" + "time": "2025-10-13T23:17:18+00:00" }, { "name": "livewire/livewire", - "version": "v3.6.2", + "version": "v3.6.4", "source": { "type": "git", "url": "https://github.com/livewire/livewire.git", - "reference": "8f8914731f5eb43b6bb145d87c8d5a9edfc89313" + "reference": "ef04be759da41b14d2d129e670533180a44987dc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/livewire/livewire/zipball/8f8914731f5eb43b6bb145d87c8d5a9edfc89313", - "reference": "8f8914731f5eb43b6bb145d87c8d5a9edfc89313", + "url": "https://api.github.com/repos/livewire/livewire/zipball/ef04be759da41b14d2d129e670533180a44987dc", + "reference": "ef04be759da41b14d2d129e670533180a44987dc", "shasum": "" }, "require": { @@ -2135,7 +2141,7 @@ "description": "A front-end framework for Laravel.", "support": { "issues": "https://github.com/livewire/livewire/issues", - "source": "https://github.com/livewire/livewire/tree/v3.6.2" + "source": "https://github.com/livewire/livewire/tree/v3.6.4" }, "funding": [ { @@ -2143,20 +2149,20 @@ "type": "github" } ], - "time": "2025-03-12T20:24:15+00:00" + "time": "2025-07-17T05:12:15+00:00" }, { "name": "livewire/volt", - "version": "v1.7.0", + "version": "v1.7.2", "source": { "type": "git", "url": "https://github.com/livewire/volt.git", - "reference": "94091094aa745c8636f9c7bed1e2da2d2a3f32b3" + "reference": "91ba934e72bbd162442840862959ade24dbe728a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/livewire/volt/zipball/94091094aa745c8636f9c7bed1e2da2d2a3f32b3", - "reference": "94091094aa745c8636f9c7bed1e2da2d2a3f32b3", + "url": "https://api.github.com/repos/livewire/volt/zipball/91ba934e72bbd162442840862959ade24dbe728a", + "reference": "91ba934e72bbd162442840862959ade24dbe728a", "shasum": "" }, "require": { @@ -2215,7 +2221,7 @@ "issues": "https://github.com/livewire/volt/issues", "source": "https://github.com/livewire/volt" }, - "time": "2025-03-05T15:20:55+00:00" + "time": "2025-08-06T15:40:50+00:00" }, { "name": "monolog/monolog", @@ -2322,16 +2328,16 @@ }, { "name": "nesbot/carbon", - "version": "3.8.6", + "version": "3.10.3", "source": { "type": "git", "url": "https://github.com/CarbonPHP/carbon.git", - "reference": "ff2f20cf83bd4d503720632ce8a426dc747bf7fd" + "reference": "8e3643dcd149ae0fe1d2ff4f2c8e4bbfad7c165f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/CarbonPHP/carbon/zipball/ff2f20cf83bd4d503720632ce8a426dc747bf7fd", - "reference": "ff2f20cf83bd4d503720632ce8a426dc747bf7fd", + "url": "https://api.github.com/repos/CarbonPHP/carbon/zipball/8e3643dcd149ae0fe1d2ff4f2c8e4bbfad7c165f", + "reference": "8e3643dcd149ae0fe1d2ff4f2c8e4bbfad7c165f", "shasum": "" }, "require": { @@ -2339,9 +2345,9 @@ "ext-json": "*", "php": "^8.1", "psr/clock": "^1.0", - "symfony/clock": "^6.3 || ^7.0", + "symfony/clock": "^6.3.12 || ^7.0", "symfony/polyfill-mbstring": "^1.0", - "symfony/translation": "^4.4.18 || ^5.2.1|| ^6.0 || ^7.0" + "symfony/translation": "^4.4.18 || ^5.2.1 || ^6.0 || ^7.0" }, "provide": { "psr/clock-implementation": "1.0" @@ -2349,14 +2355,13 @@ "require-dev": { "doctrine/dbal": "^3.6.3 || ^4.0", "doctrine/orm": "^2.15.2 || ^3.0", - "friendsofphp/php-cs-fixer": "^3.57.2", + "friendsofphp/php-cs-fixer": "^v3.87.1", "kylekatarnls/multi-tester": "^2.5.3", - "ondrejmirtes/better-reflection": "^6.25.0.4", "phpmd/phpmd": "^2.15.0", - "phpstan/extension-installer": "^1.3.1", - "phpstan/phpstan": "^1.11.2", - "phpunit/phpunit": "^10.5.20", - "squizlabs/php_codesniffer": "^3.9.0" + "phpstan/extension-installer": "^1.4.3", + "phpstan/phpstan": "^2.1.22", + "phpunit/phpunit": "^10.5.53", + "squizlabs/php_codesniffer": "^3.13.4" }, "bin": [ "bin/carbon" @@ -2424,7 +2429,7 @@ "type": "tidelift" } ], - "time": "2025-02-20T17:33:38+00:00" + "time": "2025-09-06T13:39:36+00:00" }, { "name": "nette/schema", @@ -2490,29 +2495,29 @@ }, { "name": "nette/utils", - "version": "v4.0.6", + "version": "v4.0.8", "source": { "type": "git", "url": "https://github.com/nette/utils.git", - "reference": "ce708655043c7050eb050df361c5e313cf708309" + "reference": "c930ca4e3cf4f17dcfb03037703679d2396d2ede" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/utils/zipball/ce708655043c7050eb050df361c5e313cf708309", - "reference": "ce708655043c7050eb050df361c5e313cf708309", + "url": "https://api.github.com/repos/nette/utils/zipball/c930ca4e3cf4f17dcfb03037703679d2396d2ede", + "reference": "c930ca4e3cf4f17dcfb03037703679d2396d2ede", "shasum": "" }, "require": { - "php": "8.0 - 8.4" + "php": "8.0 - 8.5" }, "conflict": { "nette/finder": "<3", "nette/schema": "<1.2.2" }, "require-dev": { - "jetbrains/phpstorm-attributes": "dev-master", + "jetbrains/phpstorm-attributes": "^1.2", "nette/tester": "^2.5", - "phpstan/phpstan": "^1.0", + "phpstan/phpstan-nette": "^2.0@stable", "tracy/tracy": "^2.9" }, "suggest": { @@ -2530,6 +2535,9 @@ } }, "autoload": { + "psr-4": { + "Nette\\": "src" + }, "classmap": [ "src/" ] @@ -2570,22 +2578,22 @@ ], "support": { "issues": "https://github.com/nette/utils/issues", - "source": "https://github.com/nette/utils/tree/v4.0.6" + "source": "https://github.com/nette/utils/tree/v4.0.8" }, - "time": "2025-03-30T21:06:30+00:00" + "time": "2025-08-06T21:43:34+00:00" }, { "name": "nikic/php-parser", - "version": "v5.4.0", + "version": "v5.6.1", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "447a020a1f875a434d62f2a401f53b82a396e494" + "reference": "f103601b29efebd7ff4a1ca7b3eeea9e3336a2a2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/447a020a1f875a434d62f2a401f53b82a396e494", - "reference": "447a020a1f875a434d62f2a401f53b82a396e494", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/f103601b29efebd7ff4a1ca7b3eeea9e3336a2a2", + "reference": "f103601b29efebd7ff4a1ca7b3eeea9e3336a2a2", "shasum": "" }, "require": { @@ -2604,7 +2612,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "5.0-dev" + "dev-master": "5.x-dev" } }, "autoload": { @@ -2628,37 +2636,37 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v5.4.0" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.6.1" }, - "time": "2024-12-30T11:07:19+00:00" + "time": "2025-08-13T20:13:15+00:00" }, { "name": "nunomaduro/termwind", - "version": "v2.3.0", + "version": "v2.3.1", "source": { "type": "git", "url": "https://github.com/nunomaduro/termwind.git", - "reference": "52915afe6a1044e8b9cee1bcff836fb63acf9cda" + "reference": "dfa08f390e509967a15c22493dc0bac5733d9123" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/termwind/zipball/52915afe6a1044e8b9cee1bcff836fb63acf9cda", - "reference": "52915afe6a1044e8b9cee1bcff836fb63acf9cda", + "url": "https://api.github.com/repos/nunomaduro/termwind/zipball/dfa08f390e509967a15c22493dc0bac5733d9123", + "reference": "dfa08f390e509967a15c22493dc0bac5733d9123", "shasum": "" }, "require": { "ext-mbstring": "*", "php": "^8.2", - "symfony/console": "^7.1.8" + "symfony/console": "^7.2.6" }, "require-dev": { - "illuminate/console": "^11.33.2", - "laravel/pint": "^1.18.2", + "illuminate/console": "^11.44.7", + "laravel/pint": "^1.22.0", "mockery/mockery": "^1.6.12", - "pestphp/pest": "^2.36.0", - "phpstan/phpstan": "^1.12.11", - "phpstan/phpstan-strict-rules": "^1.6.1", - "symfony/var-dumper": "^7.1.8", + "pestphp/pest": "^2.36.0 || ^3.8.2", + "phpstan/phpstan": "^1.12.25", + "phpstan/phpstan-strict-rules": "^1.6.2", + "symfony/var-dumper": "^7.2.6", "thecodingmachine/phpstan-strict-rules": "^1.0.0" }, "type": "library", @@ -2701,7 +2709,7 @@ ], "support": { "issues": "https://github.com/nunomaduro/termwind/issues", - "source": "https://github.com/nunomaduro/termwind/tree/v2.3.0" + "source": "https://github.com/nunomaduro/termwind/tree/v2.3.1" }, "funding": [ { @@ -2717,20 +2725,20 @@ "type": "github" } ], - "time": "2024-11-21T10:39:51+00:00" + "time": "2025-05-08T08:14:37+00:00" }, { "name": "phpoption/phpoption", - "version": "1.9.3", + "version": "1.9.4", "source": { "type": "git", "url": "https://github.com/schmittjoh/php-option.git", - "reference": "e3fac8b24f56113f7cb96af14958c0dd16330f54" + "reference": "638a154f8d4ee6a5cfa96d6a34dfbe0cffa9566d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/e3fac8b24f56113f7cb96af14958c0dd16330f54", - "reference": "e3fac8b24f56113f7cb96af14958c0dd16330f54", + "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/638a154f8d4ee6a5cfa96d6a34dfbe0cffa9566d", + "reference": "638a154f8d4ee6a5cfa96d6a34dfbe0cffa9566d", "shasum": "" }, "require": { @@ -2738,7 +2746,7 @@ }, "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", - "phpunit/phpunit": "^8.5.39 || ^9.6.20 || ^10.5.28" + "phpunit/phpunit": "^8.5.44 || ^9.6.25 || ^10.5.53 || ^11.5.34" }, "type": "library", "extra": { @@ -2780,7 +2788,7 @@ ], "support": { "issues": "https://github.com/schmittjoh/php-option/issues", - "source": "https://github.com/schmittjoh/php-option/tree/1.9.3" + "source": "https://github.com/schmittjoh/php-option/tree/1.9.4" }, "funding": [ { @@ -2792,7 +2800,7 @@ "type": "tidelift" } ], - "time": "2024-07-20T21:41:07+00:00" + "time": "2025-08-21T11:53:16+00:00" }, { "name": "psr/clock", @@ -3208,16 +3216,16 @@ }, { "name": "psy/psysh", - "version": "v0.12.8", + "version": "v0.12.12", "source": { "type": "git", "url": "https://github.com/bobthecow/psysh.git", - "reference": "85057ceedee50c49d4f6ecaff73ee96adb3b3625" + "reference": "cd23863404a40ccfaf733e3af4db2b459837f7e7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bobthecow/psysh/zipball/85057ceedee50c49d4f6ecaff73ee96adb3b3625", - "reference": "85057ceedee50c49d4f6ecaff73ee96adb3b3625", + "url": "https://api.github.com/repos/bobthecow/psysh/zipball/cd23863404a40ccfaf733e3af4db2b459837f7e7", + "reference": "cd23863404a40ccfaf733e3af4db2b459837f7e7", "shasum": "" }, "require": { @@ -3267,12 +3275,11 @@ "authors": [ { "name": "Justin Hileman", - "email": "justin@justinhileman.info", - "homepage": "http://justinhileman.com" + "email": "justin@justinhileman.info" } ], "description": "An interactive shell for modern PHP.", - "homepage": "http://psysh.org", + "homepage": "https://psysh.org", "keywords": [ "REPL", "console", @@ -3281,9 +3288,9 @@ ], "support": { "issues": "https://github.com/bobthecow/psysh/issues", - "source": "https://github.com/bobthecow/psysh/tree/v0.12.8" + "source": "https://github.com/bobthecow/psysh/tree/v0.12.12" }, - "time": "2025-03-16T03:05:19+00:00" + "time": "2025-09-20T13:46:31+00:00" }, { "name": "ralouphie/getallheaders", @@ -3407,21 +3414,20 @@ }, { "name": "ramsey/uuid", - "version": "4.7.6", + "version": "4.9.1", "source": { "type": "git", "url": "https://github.com/ramsey/uuid.git", - "reference": "91039bc1faa45ba123c4328958e620d382ec7088" + "reference": "81f941f6f729b1e3ceea61d9d014f8b6c6800440" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/uuid/zipball/91039bc1faa45ba123c4328958e620d382ec7088", - "reference": "91039bc1faa45ba123c4328958e620d382ec7088", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/81f941f6f729b1e3ceea61d9d014f8b6c6800440", + "reference": "81f941f6f729b1e3ceea61d9d014f8b6c6800440", "shasum": "" }, "require": { - "brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11 || ^0.12", - "ext-json": "*", + "brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11 || ^0.12 || ^0.13 || ^0.14", "php": "^8.0", "ramsey/collection": "^1.2 || ^2.0" }, @@ -3429,26 +3435,23 @@ "rhumsaa/uuid": "self.version" }, "require-dev": { - "captainhook/captainhook": "^5.10", + "captainhook/captainhook": "^5.25", "captainhook/plugin-composer": "^5.3", - "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", - "doctrine/annotations": "^1.8", - "ergebnis/composer-normalize": "^2.15", - "mockery/mockery": "^1.3", + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "ergebnis/composer-normalize": "^2.47", + "mockery/mockery": "^1.6", "paragonie/random-lib": "^2", - "php-mock/php-mock": "^2.2", - "php-mock/php-mock-mockery": "^1.3", - "php-parallel-lint/php-parallel-lint": "^1.1", - "phpbench/phpbench": "^1.0", - "phpstan/extension-installer": "^1.1", - "phpstan/phpstan": "^1.8", - "phpstan/phpstan-mockery": "^1.1", - "phpstan/phpstan-phpunit": "^1.1", - "phpunit/phpunit": "^8.5 || ^9", - "ramsey/composer-repl": "^1.4", - "slevomat/coding-standard": "^8.4", - "squizlabs/php_codesniffer": "^3.5", - "vimeo/psalm": "^4.9" + "php-mock/php-mock": "^2.6", + "php-mock/php-mock-mockery": "^1.5", + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpbench/phpbench": "^1.2.14", + "phpstan/extension-installer": "^1.4", + "phpstan/phpstan": "^2.1", + "phpstan/phpstan-mockery": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpunit/phpunit": "^9.6", + "slevomat/coding-standard": "^8.18", + "squizlabs/php_codesniffer": "^3.13" }, "suggest": { "ext-bcmath": "Enables faster math with arbitrary-precision integers using BCMath.", @@ -3483,23 +3486,13 @@ ], "support": { "issues": "https://github.com/ramsey/uuid/issues", - "source": "https://github.com/ramsey/uuid/tree/4.7.6" + "source": "https://github.com/ramsey/uuid/tree/4.9.1" }, - "funding": [ - { - "url": "https://github.com/ramsey", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/ramsey/uuid", - "type": "tidelift" - } - ], - "time": "2024-04-27T21:32:50+00:00" + "time": "2025-09-04T20:59:21+00:00" }, { "name": "symfony/clock", - "version": "v7.2.0", + "version": "v7.3.0", "source": { "type": "git", "url": "https://github.com/symfony/clock.git", @@ -3553,7 +3546,7 @@ "time" ], "support": { - "source": "https://github.com/symfony/clock/tree/v7.2.0" + "source": "https://github.com/symfony/clock/tree/v7.3.0" }, "funding": [ { @@ -3573,23 +3566,24 @@ }, { "name": "symfony/console", - "version": "v7.2.5", + "version": "v7.3.4", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "e51498ea18570c062e7df29d05a7003585b19b88" + "reference": "2b9c5fafbac0399a20a2e82429e2bd735dcfb7db" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/e51498ea18570c062e7df29d05a7003585b19b88", - "reference": "e51498ea18570c062e7df29d05a7003585b19b88", + "url": "https://api.github.com/repos/symfony/console/zipball/2b9c5fafbac0399a20a2e82429e2bd735dcfb7db", + "reference": "2b9c5fafbac0399a20a2e82429e2bd735dcfb7db", "shasum": "" }, "require": { "php": ">=8.2", + "symfony/deprecation-contracts": "^2.5|^3", "symfony/polyfill-mbstring": "~1.0", "symfony/service-contracts": "^2.5|^3", - "symfony/string": "^6.4|^7.0" + "symfony/string": "^7.2" }, "conflict": { "symfony/dependency-injection": "<6.4", @@ -3646,7 +3640,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v7.2.5" + "source": "https://github.com/symfony/console/tree/v7.3.4" }, "funding": [ { @@ -3657,16 +3651,20 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2025-03-12T08:11:12+00:00" + "time": "2025-09-22T15:31:00+00:00" }, { "name": "symfony/css-selector", - "version": "v7.2.0", + "version": "v7.3.0", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", @@ -3711,7 +3709,7 @@ "description": "Converts CSS selectors to XPath expressions", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/css-selector/tree/v7.2.0" + "source": "https://github.com/symfony/css-selector/tree/v7.3.0" }, "funding": [ { @@ -3731,16 +3729,16 @@ }, { "name": "symfony/deprecation-contracts", - "version": "v3.5.1", + "version": "v3.6.0", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6" + "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6", - "reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62", + "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62", "shasum": "" }, "require": { @@ -3753,7 +3751,7 @@ "name": "symfony/contracts" }, "branch-alias": { - "dev-main": "3.5-dev" + "dev-main": "3.6-dev" } }, "autoload": { @@ -3778,7 +3776,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.1" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.6.0" }, "funding": [ { @@ -3794,20 +3792,20 @@ "type": "tidelift" } ], - "time": "2024-09-25T14:20:29+00:00" + "time": "2024-09-25T14:21:43+00:00" }, { "name": "symfony/error-handler", - "version": "v7.2.5", + "version": "v7.3.4", "source": { "type": "git", "url": "https://github.com/symfony/error-handler.git", - "reference": "102be5e6a8e4f4f3eb3149bcbfa33a80d1ee374b" + "reference": "99f81bc944ab8e5dae4f21b4ca9972698bbad0e4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/error-handler/zipball/102be5e6a8e4f4f3eb3149bcbfa33a80d1ee374b", - "reference": "102be5e6a8e4f4f3eb3149bcbfa33a80d1ee374b", + "url": "https://api.github.com/repos/symfony/error-handler/zipball/99f81bc944ab8e5dae4f21b4ca9972698bbad0e4", + "reference": "99f81bc944ab8e5dae4f21b4ca9972698bbad0e4", "shasum": "" }, "require": { @@ -3820,9 +3818,11 @@ "symfony/http-kernel": "<6.4" }, "require-dev": { + "symfony/console": "^6.4|^7.0", "symfony/deprecation-contracts": "^2.5|^3", "symfony/http-kernel": "^6.4|^7.0", - "symfony/serializer": "^6.4|^7.0" + "symfony/serializer": "^6.4|^7.0", + "symfony/webpack-encore-bundle": "^1.0|^2.0" }, "bin": [ "Resources/bin/patch-type-declarations" @@ -3853,7 +3853,7 @@ "description": "Provides tools to manage errors and ease debugging PHP code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/error-handler/tree/v7.2.5" + "source": "https://github.com/symfony/error-handler/tree/v7.3.4" }, "funding": [ { @@ -3864,25 +3864,29 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2025-03-03T07:12:39+00:00" + "time": "2025-09-11T10:12:26+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v7.2.0", + "version": "v7.3.3", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "910c5db85a5356d0fea57680defec4e99eb9c8c1" + "reference": "b7dc69e71de420ac04bc9ab830cf3ffebba48191" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/910c5db85a5356d0fea57680defec4e99eb9c8c1", - "reference": "910c5db85a5356d0fea57680defec4e99eb9c8c1", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/b7dc69e71de420ac04bc9ab830cf3ffebba48191", + "reference": "b7dc69e71de420ac04bc9ab830cf3ffebba48191", "shasum": "" }, "require": { @@ -3933,7 +3937,7 @@ "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v7.2.0" + "source": "https://github.com/symfony/event-dispatcher/tree/v7.3.3" }, "funding": [ { @@ -3944,25 +3948,29 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2024-09-25T14:21:43+00:00" + "time": "2025-08-13T11:49:31+00:00" }, { "name": "symfony/event-dispatcher-contracts", - "version": "v3.5.1", + "version": "v3.6.0", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher-contracts.git", - "reference": "7642f5e970b672283b7823222ae8ef8bbc160b9f" + "reference": "59eb412e93815df44f05f342958efa9f46b1e586" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/7642f5e970b672283b7823222ae8ef8bbc160b9f", - "reference": "7642f5e970b672283b7823222ae8ef8bbc160b9f", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/59eb412e93815df44f05f342958efa9f46b1e586", + "reference": "59eb412e93815df44f05f342958efa9f46b1e586", "shasum": "" }, "require": { @@ -3976,7 +3984,7 @@ "name": "symfony/contracts" }, "branch-alias": { - "dev-main": "3.5-dev" + "dev-main": "3.6-dev" } }, "autoload": { @@ -4009,7 +4017,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.5.1" + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.6.0" }, "funding": [ { @@ -4025,20 +4033,20 @@ "type": "tidelift" } ], - "time": "2024-09-25T14:20:29+00:00" + "time": "2024-09-25T14:21:43+00:00" }, { "name": "symfony/finder", - "version": "v7.2.2", + "version": "v7.3.2", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "87a71856f2f56e4100373e92529eed3171695cfb" + "reference": "2a6614966ba1074fa93dae0bc804227422df4dfe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/87a71856f2f56e4100373e92529eed3171695cfb", - "reference": "87a71856f2f56e4100373e92529eed3171695cfb", + "url": "https://api.github.com/repos/symfony/finder/zipball/2a6614966ba1074fa93dae0bc804227422df4dfe", + "reference": "2a6614966ba1074fa93dae0bc804227422df4dfe", "shasum": "" }, "require": { @@ -4073,7 +4081,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v7.2.2" + "source": "https://github.com/symfony/finder/tree/v7.3.2" }, "funding": [ { @@ -4084,25 +4092,29 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2024-12-30T19:00:17+00:00" + "time": "2025-07-15T13:41:35+00:00" }, { "name": "symfony/http-foundation", - "version": "v7.2.5", + "version": "v7.3.4", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "371272aeb6286f8135e028ca535f8e4d6f114126" + "reference": "c061c7c18918b1b64268771aad04b40be41dd2e6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/371272aeb6286f8135e028ca535f8e4d6f114126", - "reference": "371272aeb6286f8135e028ca535f8e4d6f114126", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/c061c7c18918b1b64268771aad04b40be41dd2e6", + "reference": "c061c7c18918b1b64268771aad04b40be41dd2e6", "shasum": "" }, "require": { @@ -4119,6 +4131,7 @@ "doctrine/dbal": "^3.6|^4", "predis/predis": "^1.1|^2.0", "symfony/cache": "^6.4.12|^7.1.5", + "symfony/clock": "^6.4|^7.0", "symfony/dependency-injection": "^6.4|^7.0", "symfony/expression-language": "^6.4|^7.0", "symfony/http-kernel": "^6.4|^7.0", @@ -4151,7 +4164,7 @@ "description": "Defines an object-oriented layer for the HTTP specification", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-foundation/tree/v7.2.5" + "source": "https://github.com/symfony/http-foundation/tree/v7.3.4" }, "funding": [ { @@ -4162,25 +4175,29 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2025-03-25T15:54:33+00:00" + "time": "2025-09-16T08:38:17+00:00" }, { "name": "symfony/http-kernel", - "version": "v7.2.5", + "version": "v7.3.4", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "b1fe91bc1fa454a806d3f98db4ba826eb9941a54" + "reference": "b796dffea7821f035047235e076b60ca2446e3cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/b1fe91bc1fa454a806d3f98db4ba826eb9941a54", - "reference": "b1fe91bc1fa454a806d3f98db4ba826eb9941a54", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/b796dffea7821f035047235e076b60ca2446e3cf", + "reference": "b796dffea7821f035047235e076b60ca2446e3cf", "shasum": "" }, "require": { @@ -4188,8 +4205,8 @@ "psr/log": "^1|^2|^3", "symfony/deprecation-contracts": "^2.5|^3", "symfony/error-handler": "^6.4|^7.0", - "symfony/event-dispatcher": "^6.4|^7.0", - "symfony/http-foundation": "^6.4|^7.0", + "symfony/event-dispatcher": "^7.3", + "symfony/http-foundation": "^7.3", "symfony/polyfill-ctype": "^1.8" }, "conflict": { @@ -4265,7 +4282,7 @@ "description": "Provides a structured process for converting a Request into a Response", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-kernel/tree/v7.2.5" + "source": "https://github.com/symfony/http-kernel/tree/v7.3.4" }, "funding": [ { @@ -4276,25 +4293,29 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2025-03-28T13:32:50+00:00" + "time": "2025-09-27T12:32:17+00:00" }, { "name": "symfony/mailer", - "version": "v7.2.3", + "version": "v7.3.4", "source": { "type": "git", "url": "https://github.com/symfony/mailer.git", - "reference": "f3871b182c44997cf039f3b462af4a48fb85f9d3" + "reference": "ab97ef2f7acf0216955f5845484235113047a31d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mailer/zipball/f3871b182c44997cf039f3b462af4a48fb85f9d3", - "reference": "f3871b182c44997cf039f3b462af4a48fb85f9d3", + "url": "https://api.github.com/repos/symfony/mailer/zipball/ab97ef2f7acf0216955f5845484235113047a31d", + "reference": "ab97ef2f7acf0216955f5845484235113047a31d", "shasum": "" }, "require": { @@ -4345,7 +4366,7 @@ "description": "Helps sending emails", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/mailer/tree/v7.2.3" + "source": "https://github.com/symfony/mailer/tree/v7.3.4" }, "funding": [ { @@ -4356,25 +4377,29 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2025-01-27T11:08:17+00:00" + "time": "2025-09-17T05:51:54+00:00" }, { "name": "symfony/mime", - "version": "v7.2.4", + "version": "v7.3.4", "source": { "type": "git", "url": "https://github.com/symfony/mime.git", - "reference": "87ca22046b78c3feaff04b337f33b38510fd686b" + "reference": "b1b828f69cbaf887fa835a091869e55df91d0e35" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mime/zipball/87ca22046b78c3feaff04b337f33b38510fd686b", - "reference": "87ca22046b78c3feaff04b337f33b38510fd686b", + "url": "https://api.github.com/repos/symfony/mime/zipball/b1b828f69cbaf887fa835a091869e55df91d0e35", + "reference": "b1b828f69cbaf887fa835a091869e55df91d0e35", "shasum": "" }, "require": { @@ -4429,7 +4454,7 @@ "mime-type" ], "support": { - "source": "https://github.com/symfony/mime/tree/v7.2.4" + "source": "https://github.com/symfony/mime/tree/v7.3.4" }, "funding": [ { @@ -4440,16 +4465,20 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2025-02-19T08:51:20+00:00" + "time": "2025-09-16T08:38:17+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.31.0", + "version": "v1.33.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", @@ -4508,7 +4537,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.31.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.33.0" }, "funding": [ { @@ -4519,6 +4548,10 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" @@ -4528,16 +4561,16 @@ }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.31.0", + "version": "v1.33.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe" + "reference": "380872130d3a5dd3ace2f4010d95125fde5d5c70" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe", - "reference": "b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/380872130d3a5dd3ace2f4010d95125fde5d5c70", + "reference": "380872130d3a5dd3ace2f4010d95125fde5d5c70", "shasum": "" }, "require": { @@ -4586,7 +4619,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.31.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.33.0" }, "funding": [ { @@ -4597,25 +4630,29 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2024-09-09T11:45:10+00:00" + "time": "2025-06-27T09:58:17+00:00" }, { "name": "symfony/polyfill-intl-idn", - "version": "v1.31.0", + "version": "v1.33.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-idn.git", - "reference": "c36586dcf89a12315939e00ec9b4474adcb1d773" + "reference": "9614ac4d8061dc257ecc64cba1b140873dce8ad3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/c36586dcf89a12315939e00ec9b4474adcb1d773", - "reference": "c36586dcf89a12315939e00ec9b4474adcb1d773", + "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/9614ac4d8061dc257ecc64cba1b140873dce8ad3", + "reference": "9614ac4d8061dc257ecc64cba1b140873dce8ad3", "shasum": "" }, "require": { @@ -4669,7 +4706,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.31.0" + "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.33.0" }, "funding": [ { @@ -4680,16 +4717,20 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2024-09-09T11:45:10+00:00" + "time": "2024-09-10T14:38:51+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.31.0", + "version": "v1.33.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", @@ -4750,7 +4791,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.31.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.33.0" }, "funding": [ { @@ -4761,6 +4802,10 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" @@ -4770,19 +4815,20 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.31.0", + "version": "v1.33.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341" + "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341", - "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493", + "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493", "shasum": "" }, "require": { + "ext-iconv": "*", "php": ">=7.2" }, "provide": { @@ -4830,7 +4876,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.33.0" }, "funding": [ { @@ -4841,25 +4887,29 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2024-09-09T11:45:10+00:00" + "time": "2024-12-23T08:48:59+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.31.0", + "version": "v1.33.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8" + "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", - "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/0cc9dd0f17f61d8131e7df6b84bd344899fe2608", + "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608", "shasum": "" }, "require": { @@ -4910,7 +4960,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.33.0" }, "funding": [ { @@ -4921,25 +4971,29 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2024-09-09T11:45:10+00:00" + "time": "2025-01-02T08:10:11+00:00" }, { "name": "symfony/polyfill-php83", - "version": "v1.31.0", + "version": "v1.33.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php83.git", - "reference": "2fb86d65e2d424369ad2905e83b236a8805ba491" + "reference": "17f6f9a6b1735c0f163024d959f700cfbc5155e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php83/zipball/2fb86d65e2d424369ad2905e83b236a8805ba491", - "reference": "2fb86d65e2d424369ad2905e83b236a8805ba491", + "url": "https://api.github.com/repos/symfony/polyfill-php83/zipball/17f6f9a6b1735c0f163024d959f700cfbc5155e5", + "reference": "17f6f9a6b1735c0f163024d959f700cfbc5155e5", "shasum": "" }, "require": { @@ -4986,7 +5040,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php83/tree/v1.31.0" + "source": "https://github.com/symfony/polyfill-php83/tree/v1.33.0" }, "funding": [ { @@ -4997,16 +5051,180 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2024-09-09T11:45:10+00:00" + "time": "2025-07-08T02:45:35+00:00" + }, + { + "name": "symfony/polyfill-php84", + "version": "v1.33.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php84.git", + "reference": "d8ced4d875142b6a7426000426b8abc631d6b191" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php84/zipball/d8ced4d875142b6a7426000426b8abc631d6b191", + "reference": "d8ced4d875142b6a7426000426b8abc631d6b191", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php84\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.4+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php84/tree/v1.33.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-06-24T13:30:11+00:00" + }, + { + "name": "symfony/polyfill-php85", + "version": "v1.33.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php85.git", + "reference": "d4e5fcd4ab3d998ab16c0db48e6cbb9a01993f91" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php85/zipball/d4e5fcd4ab3d998ab16c0db48e6cbb9a01993f91", + "reference": "d4e5fcd4ab3d998ab16c0db48e6cbb9a01993f91", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php85\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.5+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php85/tree/v1.33.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-06-23T16:12:55+00:00" }, { "name": "symfony/polyfill-uuid", - "version": "v1.31.0", + "version": "v1.33.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-uuid.git", @@ -5065,7 +5283,7 @@ "uuid" ], "support": { - "source": "https://github.com/symfony/polyfill-uuid/tree/v1.31.0" + "source": "https://github.com/symfony/polyfill-uuid/tree/v1.33.0" }, "funding": [ { @@ -5076,6 +5294,10 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" @@ -5085,16 +5307,16 @@ }, { "name": "symfony/process", - "version": "v7.2.5", + "version": "v7.3.4", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "87b7c93e57df9d8e39a093d32587702380ff045d" + "reference": "f24f8f316367b30810810d4eb30c543d7003ff3b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/87b7c93e57df9d8e39a093d32587702380ff045d", - "reference": "87b7c93e57df9d8e39a093d32587702380ff045d", + "url": "https://api.github.com/repos/symfony/process/zipball/f24f8f316367b30810810d4eb30c543d7003ff3b", + "reference": "f24f8f316367b30810810d4eb30c543d7003ff3b", "shasum": "" }, "require": { @@ -5126,7 +5348,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v7.2.5" + "source": "https://github.com/symfony/process/tree/v7.3.4" }, "funding": [ { @@ -5137,25 +5359,29 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2025-03-13T12:21:46+00:00" + "time": "2025-09-11T10:12:26+00:00" }, { "name": "symfony/routing", - "version": "v7.2.3", + "version": "v7.3.4", "source": { "type": "git", "url": "https://github.com/symfony/routing.git", - "reference": "ee9a67edc6baa33e5fae662f94f91fd262930996" + "reference": "8dc648e159e9bac02b703b9fbd937f19ba13d07c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/ee9a67edc6baa33e5fae662f94f91fd262930996", - "reference": "ee9a67edc6baa33e5fae662f94f91fd262930996", + "url": "https://api.github.com/repos/symfony/routing/zipball/8dc648e159e9bac02b703b9fbd937f19ba13d07c", + "reference": "8dc648e159e9bac02b703b9fbd937f19ba13d07c", "shasum": "" }, "require": { @@ -5207,7 +5433,7 @@ "url" ], "support": { - "source": "https://github.com/symfony/routing/tree/v7.2.3" + "source": "https://github.com/symfony/routing/tree/v7.3.4" }, "funding": [ { @@ -5218,25 +5444,29 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2025-01-17T10:56:55+00:00" + "time": "2025-09-11T10:12:26+00:00" }, { "name": "symfony/service-contracts", - "version": "v3.5.1", + "version": "v3.6.0", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "e53260aabf78fb3d63f8d79d69ece59f80d5eda0" + "reference": "f021b05a130d35510bd6b25fe9053c2a8a15d5d4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/e53260aabf78fb3d63f8d79d69ece59f80d5eda0", - "reference": "e53260aabf78fb3d63f8d79d69ece59f80d5eda0", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/f021b05a130d35510bd6b25fe9053c2a8a15d5d4", + "reference": "f021b05a130d35510bd6b25fe9053c2a8a15d5d4", "shasum": "" }, "require": { @@ -5254,7 +5484,7 @@ "name": "symfony/contracts" }, "branch-alias": { - "dev-main": "3.5-dev" + "dev-main": "3.6-dev" } }, "autoload": { @@ -5290,7 +5520,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.5.1" + "source": "https://github.com/symfony/service-contracts/tree/v3.6.0" }, "funding": [ { @@ -5306,20 +5536,20 @@ "type": "tidelift" } ], - "time": "2024-09-25T14:20:29+00:00" + "time": "2025-04-25T09:37:31+00:00" }, { "name": "symfony/string", - "version": "v7.2.0", + "version": "v7.3.4", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "446e0d146f991dde3e73f45f2c97a9faad773c82" + "reference": "f96476035142921000338bad71e5247fbc138872" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/446e0d146f991dde3e73f45f2c97a9faad773c82", - "reference": "446e0d146f991dde3e73f45f2c97a9faad773c82", + "url": "https://api.github.com/repos/symfony/string/zipball/f96476035142921000338bad71e5247fbc138872", + "reference": "f96476035142921000338bad71e5247fbc138872", "shasum": "" }, "require": { @@ -5334,7 +5564,6 @@ }, "require-dev": { "symfony/emoji": "^7.1", - "symfony/error-handler": "^6.4|^7.0", "symfony/http-client": "^6.4|^7.0", "symfony/intl": "^6.4|^7.0", "symfony/translation-contracts": "^2.5|^3.0", @@ -5377,7 +5606,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v7.2.0" + "source": "https://github.com/symfony/string/tree/v7.3.4" }, "funding": [ { @@ -5388,25 +5617,29 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2024-11-13T13:31:26+00:00" + "time": "2025-09-11T14:36:48+00:00" }, { "name": "symfony/translation", - "version": "v7.2.4", + "version": "v7.3.4", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "283856e6981286cc0d800b53bd5703e8e363f05a" + "reference": "ec25870502d0c7072d086e8ffba1420c85965174" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/283856e6981286cc0d800b53bd5703e8e363f05a", - "reference": "283856e6981286cc0d800b53bd5703e8e363f05a", + "url": "https://api.github.com/repos/symfony/translation/zipball/ec25870502d0c7072d086e8ffba1420c85965174", + "reference": "ec25870502d0c7072d086e8ffba1420c85965174", "shasum": "" }, "require": { @@ -5416,6 +5649,7 @@ "symfony/translation-contracts": "^2.5|^3.0" }, "conflict": { + "nikic/php-parser": "<5.0", "symfony/config": "<6.4", "symfony/console": "<6.4", "symfony/dependency-injection": "<6.4", @@ -5429,7 +5663,7 @@ "symfony/translation-implementation": "2.3|3.0" }, "require-dev": { - "nikic/php-parser": "^4.18|^5.0", + "nikic/php-parser": "^5.0", "psr/log": "^1|^2|^3", "symfony/config": "^6.4|^7.0", "symfony/console": "^6.4|^7.0", @@ -5472,7 +5706,7 @@ "description": "Provides tools to internationalize your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/translation/tree/v7.2.4" + "source": "https://github.com/symfony/translation/tree/v7.3.4" }, "funding": [ { @@ -5483,25 +5717,29 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2025-02-13T10:27:23+00:00" + "time": "2025-09-07T11:39:36+00:00" }, { "name": "symfony/translation-contracts", - "version": "v3.5.1", + "version": "v3.6.0", "source": { "type": "git", "url": "https://github.com/symfony/translation-contracts.git", - "reference": "4667ff3bd513750603a09c8dedbea942487fb07c" + "reference": "df210c7a2573f1913b2d17cc95f90f53a73d8f7d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/4667ff3bd513750603a09c8dedbea942487fb07c", - "reference": "4667ff3bd513750603a09c8dedbea942487fb07c", + "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/df210c7a2573f1913b2d17cc95f90f53a73d8f7d", + "reference": "df210c7a2573f1913b2d17cc95f90f53a73d8f7d", "shasum": "" }, "require": { @@ -5514,7 +5752,7 @@ "name": "symfony/contracts" }, "branch-alias": { - "dev-main": "3.5-dev" + "dev-main": "3.6-dev" } }, "autoload": { @@ -5550,7 +5788,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/translation-contracts/tree/v3.5.1" + "source": "https://github.com/symfony/translation-contracts/tree/v3.6.0" }, "funding": [ { @@ -5566,20 +5804,20 @@ "type": "tidelift" } ], - "time": "2024-09-25T14:20:29+00:00" + "time": "2024-09-27T08:32:26+00:00" }, { "name": "symfony/uid", - "version": "v7.2.0", + "version": "v7.3.1", "source": { "type": "git", "url": "https://github.com/symfony/uid.git", - "reference": "2d294d0c48df244c71c105a169d0190bfb080426" + "reference": "a69f69f3159b852651a6bf45a9fdd149520525bb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/uid/zipball/2d294d0c48df244c71c105a169d0190bfb080426", - "reference": "2d294d0c48df244c71c105a169d0190bfb080426", + "url": "https://api.github.com/repos/symfony/uid/zipball/a69f69f3159b852651a6bf45a9fdd149520525bb", + "reference": "a69f69f3159b852651a6bf45a9fdd149520525bb", "shasum": "" }, "require": { @@ -5624,7 +5862,7 @@ "uuid" ], "support": { - "source": "https://github.com/symfony/uid/tree/v7.2.0" + "source": "https://github.com/symfony/uid/tree/v7.3.1" }, "funding": [ { @@ -5640,31 +5878,31 @@ "type": "tidelift" } ], - "time": "2024-09-25T14:21:43+00:00" + "time": "2025-06-27T19:55:54+00:00" }, { "name": "symfony/var-dumper", - "version": "v7.2.3", + "version": "v7.3.4", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "82b478c69745d8878eb60f9a049a4d584996f73a" + "reference": "b8abe7daf2730d07dfd4b2ee1cecbf0dd2fbdabb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/82b478c69745d8878eb60f9a049a4d584996f73a", - "reference": "82b478c69745d8878eb60f9a049a4d584996f73a", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/b8abe7daf2730d07dfd4b2ee1cecbf0dd2fbdabb", + "reference": "b8abe7daf2730d07dfd4b2ee1cecbf0dd2fbdabb", "shasum": "" }, "require": { "php": ">=8.2", + "symfony/deprecation-contracts": "^2.5|^3", "symfony/polyfill-mbstring": "~1.0" }, "conflict": { "symfony/console": "<6.4" }, "require-dev": { - "ext-iconv": "*", "symfony/console": "^6.4|^7.0", "symfony/http-kernel": "^6.4|^7.0", "symfony/process": "^6.4|^7.0", @@ -5707,7 +5945,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v7.2.3" + "source": "https://github.com/symfony/var-dumper/tree/v7.3.4" }, "funding": [ { @@ -5718,12 +5956,16 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2025-01-17T11:39:41+00:00" + "time": "2025-09-11T10:12:26+00:00" }, { "name": "tijsverkoyen/css-to-inline-styles", @@ -5782,16 +6024,16 @@ }, { "name": "vlucas/phpdotenv", - "version": "v5.6.1", + "version": "v5.6.2", "source": { "type": "git", "url": "https://github.com/vlucas/phpdotenv.git", - "reference": "a59a13791077fe3d44f90e7133eb68e7d22eaff2" + "reference": "24ac4c74f91ee2c193fa1aaa5c249cb0822809af" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/a59a13791077fe3d44f90e7133eb68e7d22eaff2", - "reference": "a59a13791077fe3d44f90e7133eb68e7d22eaff2", + "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/24ac4c74f91ee2c193fa1aaa5c249cb0822809af", + "reference": "24ac4c74f91ee2c193fa1aaa5c249cb0822809af", "shasum": "" }, "require": { @@ -5850,7 +6092,7 @@ ], "support": { "issues": "https://github.com/vlucas/phpdotenv/issues", - "source": "https://github.com/vlucas/phpdotenv/tree/v5.6.1" + "source": "https://github.com/vlucas/phpdotenv/tree/v5.6.2" }, "funding": [ { @@ -5862,7 +6104,7 @@ "type": "tidelift" } ], - "time": "2024-07-20T21:52:34+00:00" + "time": "2025-04-30T23:37:27+00:00" }, { "name": "voku/portable-ascii", @@ -6000,16 +6242,16 @@ "packages-dev": [ { "name": "brianium/paratest", - "version": "v7.8.3", + "version": "v7.8.4", "source": { "type": "git", "url": "https://github.com/paratestphp/paratest.git", - "reference": "a585c346ddf1bec22e51e20b5387607905604a71" + "reference": "130a9bf0e269ee5f5b320108f794ad03e275cad4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/paratestphp/paratest/zipball/a585c346ddf1bec22e51e20b5387607905604a71", - "reference": "a585c346ddf1bec22e51e20b5387607905604a71", + "url": "https://api.github.com/repos/paratestphp/paratest/zipball/130a9bf0e269ee5f5b320108f794ad03e275cad4", + "reference": "130a9bf0e269ee5f5b320108f794ad03e275cad4", "shasum": "" }, "require": { @@ -6018,26 +6260,26 @@ "ext-reflection": "*", "ext-simplexml": "*", "fidry/cpu-core-counter": "^1.2.0", - "jean85/pretty-package-versions": "^2.1.0", + "jean85/pretty-package-versions": "^2.1.1", "php": "~8.2.0 || ~8.3.0 || ~8.4.0", - "phpunit/php-code-coverage": "^11.0.9 || ^12.0.4", - "phpunit/php-file-iterator": "^5.1.0 || ^6", - "phpunit/php-timer": "^7.0.1 || ^8", - "phpunit/phpunit": "^11.5.11 || ^12.0.6", - "sebastian/environment": "^7.2.0 || ^8", - "symfony/console": "^6.4.17 || ^7.2.1", - "symfony/process": "^6.4.19 || ^7.2.4" + "phpunit/php-code-coverage": "^11.0.10", + "phpunit/php-file-iterator": "^5.1.0", + "phpunit/php-timer": "^7.0.1", + "phpunit/phpunit": "^11.5.24", + "sebastian/environment": "^7.2.1", + "symfony/console": "^6.4.22 || ^7.3.0", + "symfony/process": "^6.4.20 || ^7.3.0" }, "require-dev": { "doctrine/coding-standard": "^12.0.0", "ext-pcov": "*", "ext-posix": "*", - "phpstan/phpstan": "^2.1.6", - "phpstan/phpstan-deprecation-rules": "^2.0.1", - "phpstan/phpstan-phpunit": "^2.0.4", - "phpstan/phpstan-strict-rules": "^2.0.3", - "squizlabs/php_codesniffer": "^3.11.3", - "symfony/filesystem": "^6.4.13 || ^7.2.0" + "phpstan/phpstan": "^2.1.17", + "phpstan/phpstan-deprecation-rules": "^2.0.3", + "phpstan/phpstan-phpunit": "^2.0.6", + "phpstan/phpstan-strict-rules": "^2.0.4", + "squizlabs/php_codesniffer": "^3.13.2", + "symfony/filesystem": "^6.4.13 || ^7.3.0" }, "bin": [ "bin/paratest", @@ -6077,7 +6319,7 @@ ], "support": { "issues": "https://github.com/paratestphp/paratest/issues", - "source": "https://github.com/paratestphp/paratest/tree/v7.8.3" + "source": "https://github.com/paratestphp/paratest/tree/v7.8.4" }, "funding": [ { @@ -6089,30 +6331,33 @@ "type": "paypal" } ], - "time": "2025-03-05T08:29:11+00:00" + "time": "2025-06-23T06:07:21+00:00" }, { "name": "doctrine/deprecations", - "version": "1.1.4", + "version": "1.1.5", "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "31610dbb31faa98e6b5447b62340826f54fbc4e9" + "reference": "459c2f5dd3d6a4633d3b5f46ee2b1c40f57d3f38" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/31610dbb31faa98e6b5447b62340826f54fbc4e9", - "reference": "31610dbb31faa98e6b5447b62340826f54fbc4e9", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/459c2f5dd3d6a4633d3b5f46ee2b1c40f57d3f38", + "reference": "459c2f5dd3d6a4633d3b5f46ee2b1c40f57d3f38", "shasum": "" }, "require": { "php": "^7.1 || ^8.0" }, + "conflict": { + "phpunit/phpunit": "<=7.5 || >=13" + }, "require-dev": { - "doctrine/coding-standard": "^9 || ^12", - "phpstan/phpstan": "1.4.10 || 2.0.3", + "doctrine/coding-standard": "^9 || ^12 || ^13", + "phpstan/phpstan": "1.4.10 || 2.1.11", "phpstan/phpstan-phpunit": "^1.0 || ^2", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.6 || ^10.5 || ^11.5 || ^12", "psr/log": "^1 || ^2 || ^3" }, "suggest": { @@ -6132,9 +6377,9 @@ "homepage": "https://www.doctrine-project.org/", "support": { "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/1.1.4" + "source": "https://github.com/doctrine/deprecations/tree/1.1.5" }, - "time": "2024-12-07T21:18:45+00:00" + "time": "2025-04-07T20:06:18+00:00" }, { "name": "fakerphp/faker", @@ -6201,16 +6446,16 @@ }, { "name": "fidry/cpu-core-counter", - "version": "1.2.0", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/theofidry/cpu-core-counter.git", - "reference": "8520451a140d3f46ac33042715115e290cf5785f" + "reference": "db9508f7b1474469d9d3c53b86f817e344732678" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theofidry/cpu-core-counter/zipball/8520451a140d3f46ac33042715115e290cf5785f", - "reference": "8520451a140d3f46ac33042715115e290cf5785f", + "url": "https://api.github.com/repos/theofidry/cpu-core-counter/zipball/db9508f7b1474469d9d3c53b86f817e344732678", + "reference": "db9508f7b1474469d9d3c53b86f817e344732678", "shasum": "" }, "require": { @@ -6220,10 +6465,10 @@ "fidry/makefile": "^0.2.0", "fidry/php-cs-fixer-config": "^1.1.2", "phpstan/extension-installer": "^1.2.0", - "phpstan/phpstan": "^1.9.2", - "phpstan/phpstan-deprecation-rules": "^1.0.0", - "phpstan/phpstan-phpunit": "^1.2.2", - "phpstan/phpstan-strict-rules": "^1.4.4", + "phpstan/phpstan": "^2.0", + "phpstan/phpstan-deprecation-rules": "^2.0.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", "phpunit/phpunit": "^8.5.31 || ^9.5.26", "webmozarts/strict-phpunit": "^7.5" }, @@ -6250,7 +6495,7 @@ ], "support": { "issues": "https://github.com/theofidry/cpu-core-counter/issues", - "source": "https://github.com/theofidry/cpu-core-counter/tree/1.2.0" + "source": "https://github.com/theofidry/cpu-core-counter/tree/1.3.0" }, "funding": [ { @@ -6258,20 +6503,20 @@ "type": "github" } ], - "time": "2024-08-06T10:04:20+00:00" + "time": "2025-08-14T07:29:31+00:00" }, { "name": "filp/whoops", - "version": "2.18.0", + "version": "2.18.4", "source": { "type": "git", "url": "https://github.com/filp/whoops.git", - "reference": "a7de6c3c6c3c022f5cfc337f8ede6a14460cf77e" + "reference": "d2102955e48b9fd9ab24280a7ad12ed552752c4d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filp/whoops/zipball/a7de6c3c6c3c022f5cfc337f8ede6a14460cf77e", - "reference": "a7de6c3c6c3c022f5cfc337f8ede6a14460cf77e", + "url": "https://api.github.com/repos/filp/whoops/zipball/d2102955e48b9fd9ab24280a7ad12ed552752c4d", + "reference": "d2102955e48b9fd9ab24280a7ad12ed552752c4d", "shasum": "" }, "require": { @@ -6321,7 +6566,7 @@ ], "support": { "issues": "https://github.com/filp/whoops/issues", - "source": "https://github.com/filp/whoops/tree/2.18.0" + "source": "https://github.com/filp/whoops/tree/2.18.4" }, "funding": [ { @@ -6329,24 +6574,24 @@ "type": "github" } ], - "time": "2025-03-15T12:00:00+00:00" + "time": "2025-08-08T12:00:00+00:00" }, { "name": "hamcrest/hamcrest-php", - "version": "v2.0.1", + "version": "v2.1.1", "source": { "type": "git", "url": "https://github.com/hamcrest/hamcrest-php.git", - "reference": "8c3d0a3f6af734494ad8f6fbbee0ba92422859f3" + "reference": "f8b1c0173b22fa6ec77a81fe63e5b01eba7e6487" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/8c3d0a3f6af734494ad8f6fbbee0ba92422859f3", - "reference": "8c3d0a3f6af734494ad8f6fbbee0ba92422859f3", + "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/f8b1c0173b22fa6ec77a81fe63e5b01eba7e6487", + "reference": "f8b1c0173b22fa6ec77a81fe63e5b01eba7e6487", "shasum": "" }, "require": { - "php": "^5.3|^7.0|^8.0" + "php": "^7.4|^8.0" }, "replace": { "cordoval/hamcrest-php": "*", @@ -6354,8 +6599,8 @@ "kodova/hamcrest-php": "*" }, "require-dev": { - "phpunit/php-file-iterator": "^1.4 || ^2.0", - "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0" + "phpunit/php-file-iterator": "^1.4 || ^2.0 || ^3.0", + "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0 || ^8.0 || ^9.0" }, "type": "library", "extra": { @@ -6378,9 +6623,9 @@ ], "support": { "issues": "https://github.com/hamcrest/hamcrest-php/issues", - "source": "https://github.com/hamcrest/hamcrest-php/tree/v2.0.1" + "source": "https://github.com/hamcrest/hamcrest-php/tree/v2.1.1" }, - "time": "2020-07-09T08:09:16+00:00" + "time": "2025-04-30T06:54:44+00:00" }, { "name": "jean85/pretty-package-versions", @@ -6444,16 +6689,16 @@ }, { "name": "laravel/pail", - "version": "v1.2.2", + "version": "v1.2.3", "source": { "type": "git", "url": "https://github.com/laravel/pail.git", - "reference": "f31f4980f52be17c4667f3eafe034e6826787db2" + "reference": "8cc3d575c1f0e57eeb923f366a37528c50d2385a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pail/zipball/f31f4980f52be17c4667f3eafe034e6826787db2", - "reference": "f31f4980f52be17c4667f3eafe034e6826787db2", + "url": "https://api.github.com/repos/laravel/pail/zipball/8cc3d575c1f0e57eeb923f366a37528c50d2385a", + "reference": "8cc3d575c1f0e57eeb923f366a37528c50d2385a", "shasum": "" }, "require": { @@ -6473,7 +6718,7 @@ "orchestra/testbench-core": "^8.13|^9.0|^10.0", "pestphp/pest": "^2.20|^3.0", "pestphp/pest-plugin-type-coverage": "^2.3|^3.0", - "phpstan/phpstan": "^1.10", + "phpstan/phpstan": "^1.12.27", "symfony/var-dumper": "^6.3|^7.0" }, "type": "library", @@ -6509,6 +6754,7 @@ "description": "Easily delve into your Laravel application's log files directly from the command line.", "homepage": "https://github.com/laravel/pail", "keywords": [ + "dev", "laravel", "logs", "php", @@ -6518,20 +6764,20 @@ "issues": "https://github.com/laravel/pail/issues", "source": "https://github.com/laravel/pail" }, - "time": "2025-01-28T15:15:15+00:00" + "time": "2025-06-05T13:55:57+00:00" }, { "name": "laravel/pint", - "version": "v1.21.2", + "version": "v1.25.1", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "370772e7d9e9da087678a0edf2b11b6960e40558" + "reference": "5016e263f95d97670d71b9a987bd8996ade6d8d9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/370772e7d9e9da087678a0edf2b11b6960e40558", - "reference": "370772e7d9e9da087678a0edf2b11b6960e40558", + "url": "https://api.github.com/repos/laravel/pint/zipball/5016e263f95d97670d71b9a987bd8996ade6d8d9", + "reference": "5016e263f95d97670d71b9a987bd8996ade6d8d9", "shasum": "" }, "require": { @@ -6542,12 +6788,12 @@ "php": "^8.2.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.72.0", - "illuminate/view": "^11.44.2", - "larastan/larastan": "^3.2.0", - "laravel-zero/framework": "^11.36.1", + "friendsofphp/php-cs-fixer": "^3.87.2", + "illuminate/view": "^11.46.0", + "larastan/larastan": "^3.7.1", + "laravel-zero/framework": "^11.45.0", "mockery/mockery": "^1.6.12", - "nunomaduro/termwind": "^2.3", + "nunomaduro/termwind": "^2.3.1", "pestphp/pest": "^2.36.0" }, "bin": [ @@ -6584,20 +6830,20 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2025-03-14T22:31:42+00:00" + "time": "2025-09-19T02:57:12+00:00" }, { "name": "laravel/sail", - "version": "v1.41.0", + "version": "v1.46.0", "source": { "type": "git", "url": "https://github.com/laravel/sail.git", - "reference": "fe1a4ada0abb5e4bd99eb4e4b0d87906c00cdeec" + "reference": "eb90c4f113c4a9637b8fdd16e24cfc64f2b0ae6e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/sail/zipball/fe1a4ada0abb5e4bd99eb4e4b0d87906c00cdeec", - "reference": "fe1a4ada0abb5e4bd99eb4e4b0d87906c00cdeec", + "url": "https://api.github.com/repos/laravel/sail/zipball/eb90c4f113c4a9637b8fdd16e24cfc64f2b0ae6e", + "reference": "eb90c4f113c4a9637b8fdd16e24cfc64f2b0ae6e", "shasum": "" }, "require": { @@ -6647,7 +6893,7 @@ "issues": "https://github.com/laravel/sail/issues", "source": "https://github.com/laravel/sail" }, - "time": "2025-01-24T15:45:36+00:00" + "time": "2025-09-23T13:44:39+00:00" }, { "name": "mockery/mockery", @@ -6734,16 +6980,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.13.0", + "version": "1.13.4", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "024473a478be9df5fdaca2c793f2232fe788e414" + "reference": "07d290f0c47959fd5eed98c95ee5602db07e0b6a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/024473a478be9df5fdaca2c793f2232fe788e414", - "reference": "024473a478be9df5fdaca2c793f2232fe788e414", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/07d290f0c47959fd5eed98c95ee5602db07e0b6a", + "reference": "07d290f0c47959fd5eed98c95ee5602db07e0b6a", "shasum": "" }, "require": { @@ -6782,7 +7028,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.13.0" + "source": "https://github.com/myclabs/DeepCopy/tree/1.13.4" }, "funding": [ { @@ -6790,42 +7036,43 @@ "type": "tidelift" } ], - "time": "2025-02-12T12:17:51+00:00" + "time": "2025-08-01T08:46:24+00:00" }, { "name": "nunomaduro/collision", - "version": "v8.7.0", + "version": "v8.8.2", "source": { "type": "git", "url": "https://github.com/nunomaduro/collision.git", - "reference": "586cb8181a257a2152b6a855ca8d9598878a1a26" + "reference": "60207965f9b7b7a4ce15a0f75d57f9dadb105bdb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/collision/zipball/586cb8181a257a2152b6a855ca8d9598878a1a26", - "reference": "586cb8181a257a2152b6a855ca8d9598878a1a26", + "url": "https://api.github.com/repos/nunomaduro/collision/zipball/60207965f9b7b7a4ce15a0f75d57f9dadb105bdb", + "reference": "60207965f9b7b7a4ce15a0f75d57f9dadb105bdb", "shasum": "" }, "require": { - "filp/whoops": "^2.17.0", - "nunomaduro/termwind": "^2.3.0", + "filp/whoops": "^2.18.1", + "nunomaduro/termwind": "^2.3.1", "php": "^8.2.0", - "symfony/console": "^7.2.1" + "symfony/console": "^7.3.0" }, "conflict": { - "laravel/framework": "<11.39.1 || >=13.0.0", - "phpunit/phpunit": "<11.5.3 || >=12.0.0" + "laravel/framework": "<11.44.2 || >=13.0.0", + "phpunit/phpunit": "<11.5.15 || >=13.0.0" }, "require-dev": { - "larastan/larastan": "^2.10.0", - "laravel/framework": "^11.44.2", - "laravel/pint": "^1.21.2", - "laravel/sail": "^1.41.0", - "laravel/sanctum": "^4.0.8", + "brianium/paratest": "^7.8.3", + "larastan/larastan": "^3.4.2", + "laravel/framework": "^11.44.2 || ^12.18", + "laravel/pint": "^1.22.1", + "laravel/sail": "^1.43.1", + "laravel/sanctum": "^4.1.1", "laravel/tinker": "^2.10.1", - "orchestra/testbench-core": "^9.12.0", - "pestphp/pest": "^3.7.4", - "sebastian/environment": "^6.1.0 || ^7.2.0" + "orchestra/testbench-core": "^9.12.0 || ^10.4", + "pestphp/pest": "^3.8.2", + "sebastian/environment": "^7.2.1 || ^8.0" }, "type": "library", "extra": { @@ -6888,42 +7135,42 @@ "type": "patreon" } ], - "time": "2025-03-14T22:37:40+00:00" + "time": "2025-06-25T02:12:12+00:00" }, { "name": "pestphp/pest", - "version": "v3.8.0", + "version": "v3.8.4", "source": { "type": "git", "url": "https://github.com/pestphp/pest.git", - "reference": "42e1b9f17fc2b2036701f4b968158264bde542d4" + "reference": "72cf695554420e21858cda831d5db193db102574" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pestphp/pest/zipball/42e1b9f17fc2b2036701f4b968158264bde542d4", - "reference": "42e1b9f17fc2b2036701f4b968158264bde542d4", + "url": "https://api.github.com/repos/pestphp/pest/zipball/72cf695554420e21858cda831d5db193db102574", + "reference": "72cf695554420e21858cda831d5db193db102574", "shasum": "" }, "require": { - "brianium/paratest": "^7.8.3", - "nunomaduro/collision": "^8.7.0", - "nunomaduro/termwind": "^2.3.0", + "brianium/paratest": "^7.8.4", + "nunomaduro/collision": "^8.8.2", + "nunomaduro/termwind": "^2.3.1", "pestphp/pest-plugin": "^3.0.0", - "pestphp/pest-plugin-arch": "^3.1.0", + "pestphp/pest-plugin-arch": "^3.1.1", "pestphp/pest-plugin-mutate": "^3.0.5", "php": "^8.2.0", - "phpunit/phpunit": "^11.5.15" + "phpunit/phpunit": "^11.5.33" }, "conflict": { "filp/whoops": "<2.16.0", - "phpunit/phpunit": ">11.5.15", + "phpunit/phpunit": ">11.5.33", "sebastian/exporter": "<6.0.0", "webmozart/assert": "<1.11.0" }, "require-dev": { "pestphp/pest-dev-tools": "^3.4.0", - "pestphp/pest-plugin-type-coverage": "^3.5.0", - "symfony/process": "^7.2.5" + "pestphp/pest-plugin-type-coverage": "^3.6.1", + "symfony/process": "^7.3.0" }, "bin": [ "bin/pest" @@ -6988,7 +7235,7 @@ ], "support": { "issues": "https://github.com/pestphp/pest/issues", - "source": "https://github.com/pestphp/pest/tree/v3.8.0" + "source": "https://github.com/pestphp/pest/tree/v3.8.4" }, "funding": [ { @@ -7000,7 +7247,7 @@ "type": "github" } ], - "time": "2025-03-30T17:49:10+00:00" + "time": "2025-08-20T19:12:42+00:00" }, { "name": "pestphp/pest-plugin", @@ -7074,16 +7321,16 @@ }, { "name": "pestphp/pest-plugin-arch", - "version": "v3.1.0", + "version": "v3.1.1", "source": { "type": "git", "url": "https://github.com/pestphp/pest-plugin-arch.git", - "reference": "ebec636b97ee73936ee8485e15a59c3f5a4c21b2" + "reference": "db7bd9cb1612b223e16618d85475c6f63b9c8daa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pestphp/pest-plugin-arch/zipball/ebec636b97ee73936ee8485e15a59c3f5a4c21b2", - "reference": "ebec636b97ee73936ee8485e15a59c3f5a4c21b2", + "url": "https://api.github.com/repos/pestphp/pest-plugin-arch/zipball/db7bd9cb1612b223e16618d85475c6f63b9c8daa", + "reference": "db7bd9cb1612b223e16618d85475c6f63b9c8daa", "shasum": "" }, "require": { @@ -7092,7 +7339,7 @@ "ta-tikoma/phpunit-architecture-test": "^0.8.4" }, "require-dev": { - "pestphp/pest": "^3.7.5", + "pestphp/pest": "^3.8.1", "pestphp/pest-dev-tools": "^3.4.0" }, "type": "library", @@ -7128,7 +7375,7 @@ "unit" ], "support": { - "source": "https://github.com/pestphp/pest-plugin-arch/tree/v3.1.0" + "source": "https://github.com/pestphp/pest-plugin-arch/tree/v3.1.1" }, "funding": [ { @@ -7140,31 +7387,31 @@ "type": "github" } ], - "time": "2025-03-30T17:28:50+00:00" + "time": "2025-04-16T22:59:48+00:00" }, { "name": "pestphp/pest-plugin-laravel", - "version": "v3.1.0", + "version": "v3.2.0", "source": { "type": "git", "url": "https://github.com/pestphp/pest-plugin-laravel.git", - "reference": "1c4e994476375c72aa7aebaaa97aa98f5d5378cd" + "reference": "6801be82fd92b96e82dd72e563e5674b1ce365fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pestphp/pest-plugin-laravel/zipball/1c4e994476375c72aa7aebaaa97aa98f5d5378cd", - "reference": "1c4e994476375c72aa7aebaaa97aa98f5d5378cd", + "url": "https://api.github.com/repos/pestphp/pest-plugin-laravel/zipball/6801be82fd92b96e82dd72e563e5674b1ce365fc", + "reference": "6801be82fd92b96e82dd72e563e5674b1ce365fc", "shasum": "" }, "require": { - "laravel/framework": "^11.39.1|^12.0.0", - "pestphp/pest": "^3.7.4", + "laravel/framework": "^11.39.1|^12.9.2", + "pestphp/pest": "^3.8.2", "php": "^8.2.0" }, "require-dev": { "laravel/dusk": "^8.2.13|dev-develop", - "orchestra/testbench": "^9.9.0|^10.0.0", - "pestphp/pest-dev-tools": "^3.3.0" + "orchestra/testbench": "^9.9.0|^10.2.1", + "pestphp/pest-dev-tools": "^3.4.0" }, "type": "library", "extra": { @@ -7202,7 +7449,7 @@ "unit" ], "support": { - "source": "https://github.com/pestphp/pest-plugin-laravel/tree/v3.1.0" + "source": "https://github.com/pestphp/pest-plugin-laravel/tree/v3.2.0" }, "funding": [ { @@ -7214,7 +7461,7 @@ "type": "github" } ], - "time": "2025-01-24T13:22:39+00:00" + "time": "2025-04-21T07:40:53+00:00" }, { "name": "pestphp/pest-plugin-mutate", @@ -7461,16 +7708,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "5.6.1", + "version": "5.6.3", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8" + "reference": "94f8051919d1b0369a6bcc7931d679a511c03fe9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8", - "reference": "e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94f8051919d1b0369a6bcc7931d679a511c03fe9", + "reference": "94f8051919d1b0369a6bcc7931d679a511c03fe9", "shasum": "" }, "require": { @@ -7519,9 +7766,9 @@ "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "support": { "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.6.1" + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.6.3" }, - "time": "2024-12-07T09:39:29+00:00" + "time": "2025-08-01T19:43:32+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -7583,16 +7830,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "2.1.0", + "version": "2.3.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "9b30d6fd026b2c132b3985ce6b23bec09ab3aa68" + "reference": "1e0cd5370df5dd2e556a36b9c62f62e555870495" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/9b30d6fd026b2c132b3985ce6b23bec09ab3aa68", - "reference": "9b30d6fd026b2c132b3985ce6b23bec09ab3aa68", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/1e0cd5370df5dd2e556a36b9c62f62e555870495", + "reference": "1e0cd5370df5dd2e556a36b9c62f62e555870495", "shasum": "" }, "require": { @@ -7624,22 +7871,22 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/2.1.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/2.3.0" }, - "time": "2025-02-19T13:28:12+00:00" + "time": "2025-08-30T15:50:23+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "11.0.9", + "version": "11.0.11", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "14d63fbcca18457e49c6f8bebaa91a87e8e188d7" + "reference": "4f7722aa9a7b76aa775e2d9d4e95d1ea16eeeef4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/14d63fbcca18457e49c6f8bebaa91a87e8e188d7", - "reference": "14d63fbcca18457e49c6f8bebaa91a87e8e188d7", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/4f7722aa9a7b76aa775e2d9d4e95d1ea16eeeef4", + "reference": "4f7722aa9a7b76aa775e2d9d4e95d1ea16eeeef4", "shasum": "" }, "require": { @@ -7696,15 +7943,27 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/11.0.9" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/11.0.11" }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/php-code-coverage", + "type": "tidelift" } ], - "time": "2025-02-25T13:26:39+00:00" + "time": "2025-08-27T14:37:49+00:00" }, { "name": "phpunit/php-file-iterator", @@ -7953,16 +8212,16 @@ }, { "name": "phpunit/phpunit", - "version": "11.5.15", + "version": "11.5.33", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "4b6a4ee654e5e0c5e1f17e2f83c0f4c91dee1f9c" + "reference": "5965e9ff57546cb9137c0ff6aa78cb7442b05cf6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/4b6a4ee654e5e0c5e1f17e2f83c0f4c91dee1f9c", - "reference": "4b6a4ee654e5e0c5e1f17e2f83c0f4c91dee1f9c", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/5965e9ff57546cb9137c0ff6aa78cb7442b05cf6", + "reference": "5965e9ff57546cb9137c0ff6aa78cb7442b05cf6", "shasum": "" }, "require": { @@ -7972,24 +8231,24 @@ "ext-mbstring": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.13.0", + "myclabs/deep-copy": "^1.13.4", "phar-io/manifest": "^2.0.4", "phar-io/version": "^3.2.1", "php": ">=8.2", - "phpunit/php-code-coverage": "^11.0.9", + "phpunit/php-code-coverage": "^11.0.10", "phpunit/php-file-iterator": "^5.1.0", "phpunit/php-invoker": "^5.0.1", "phpunit/php-text-template": "^4.0.1", "phpunit/php-timer": "^7.0.1", "sebastian/cli-parser": "^3.0.2", "sebastian/code-unit": "^3.0.3", - "sebastian/comparator": "^6.3.1", + "sebastian/comparator": "^6.3.2", "sebastian/diff": "^6.0.2", - "sebastian/environment": "^7.2.0", + "sebastian/environment": "^7.2.1", "sebastian/exporter": "^6.3.0", "sebastian/global-state": "^7.0.2", "sebastian/object-enumerator": "^6.0.1", - "sebastian/type": "^5.1.2", + "sebastian/type": "^5.1.3", "sebastian/version": "^5.0.2", "staabm/side-effects-detector": "^1.0.5" }, @@ -8034,7 +8293,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.15" + "source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.33" }, "funding": [ { @@ -8045,12 +8304,20 @@ "url": "https://github.com/sebastianbergmann", "type": "github" }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, { "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", "type": "tidelift" } ], - "time": "2025-03-23T16:02:11+00:00" + "time": "2025-08-16T05:19:02+00:00" }, { "name": "sebastian/cli-parser", @@ -8224,16 +8491,16 @@ }, { "name": "sebastian/comparator", - "version": "6.3.1", + "version": "6.3.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "24b8fbc2c8e201bb1308e7b05148d6ab393b6959" + "reference": "85c77556683e6eee4323e4c5468641ca0237e2e8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/24b8fbc2c8e201bb1308e7b05148d6ab393b6959", - "reference": "24b8fbc2c8e201bb1308e7b05148d6ab393b6959", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/85c77556683e6eee4323e4c5468641ca0237e2e8", + "reference": "85c77556683e6eee4323e4c5468641ca0237e2e8", "shasum": "" }, "require": { @@ -8292,15 +8559,27 @@ "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", "security": "https://github.com/sebastianbergmann/comparator/security/policy", - "source": "https://github.com/sebastianbergmann/comparator/tree/6.3.1" + "source": "https://github.com/sebastianbergmann/comparator/tree/6.3.2" }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/comparator", + "type": "tidelift" } ], - "time": "2025-03-07T06:57:01+00:00" + "time": "2025-08-10T08:07:46+00:00" }, { "name": "sebastian/complexity", @@ -8429,23 +8708,23 @@ }, { "name": "sebastian/environment", - "version": "7.2.0", + "version": "7.2.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "855f3ae0ab316bbafe1ba4e16e9f3c078d24a0c5" + "reference": "a5c75038693ad2e8d4b6c15ba2403532647830c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/855f3ae0ab316bbafe1ba4e16e9f3c078d24a0c5", - "reference": "855f3ae0ab316bbafe1ba4e16e9f3c078d24a0c5", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/a5c75038693ad2e8d4b6c15ba2403532647830c4", + "reference": "a5c75038693ad2e8d4b6c15ba2403532647830c4", "shasum": "" }, "require": { "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^11.0" + "phpunit/phpunit": "^11.3" }, "suggest": { "ext-posix": "*" @@ -8481,28 +8760,40 @@ "support": { "issues": "https://github.com/sebastianbergmann/environment/issues", "security": "https://github.com/sebastianbergmann/environment/security/policy", - "source": "https://github.com/sebastianbergmann/environment/tree/7.2.0" + "source": "https://github.com/sebastianbergmann/environment/tree/7.2.1" }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/environment", + "type": "tidelift" } ], - "time": "2024-07-03T04:54:44+00:00" + "time": "2025-05-21T11:55:47+00:00" }, { "name": "sebastian/exporter", - "version": "6.3.0", + "version": "6.3.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "3473f61172093b2da7de1fb5782e1f24cc036dc3" + "reference": "70a298763b40b213ec087c51c739efcaa90bcd74" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/3473f61172093b2da7de1fb5782e1f24cc036dc3", - "reference": "3473f61172093b2da7de1fb5782e1f24cc036dc3", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/70a298763b40b213ec087c51c739efcaa90bcd74", + "reference": "70a298763b40b213ec087c51c739efcaa90bcd74", "shasum": "" }, "require": { @@ -8516,7 +8807,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "6.1-dev" + "dev-main": "6.3-dev" } }, "autoload": { @@ -8559,15 +8850,27 @@ "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", "security": "https://github.com/sebastianbergmann/exporter/security/policy", - "source": "https://github.com/sebastianbergmann/exporter/tree/6.3.0" + "source": "https://github.com/sebastianbergmann/exporter/tree/6.3.2" }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/exporter", + "type": "tidelift" } ], - "time": "2024-12-05T09:17:50+00:00" + "time": "2025-09-24T06:12:51+00:00" }, { "name": "sebastian/global-state", @@ -8805,23 +9108,23 @@ }, { "name": "sebastian/recursion-context", - "version": "6.0.2", + "version": "6.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "694d156164372abbd149a4b85ccda2e4670c0e16" + "reference": "f6458abbf32a6c8174f8f26261475dc133b3d9dc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/694d156164372abbd149a4b85ccda2e4670c0e16", - "reference": "694d156164372abbd149a4b85ccda2e4670c0e16", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/f6458abbf32a6c8174f8f26261475dc133b3d9dc", + "reference": "f6458abbf32a6c8174f8f26261475dc133b3d9dc", "shasum": "" }, "require": { "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^11.0" + "phpunit/phpunit": "^11.3" }, "type": "library", "extra": { @@ -8857,28 +9160,40 @@ "support": { "issues": "https://github.com/sebastianbergmann/recursion-context/issues", "security": "https://github.com/sebastianbergmann/recursion-context/security/policy", - "source": "https://github.com/sebastianbergmann/recursion-context/tree/6.0.2" + "source": "https://github.com/sebastianbergmann/recursion-context/tree/6.0.3" }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/recursion-context", + "type": "tidelift" } ], - "time": "2024-07-03T05:10:34+00:00" + "time": "2025-08-13T04:42:22+00:00" }, { "name": "sebastian/type", - "version": "5.1.2", + "version": "5.1.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "a8a7e30534b0eb0c77cd9d07e82de1a114389f5e" + "reference": "f77d2d4e78738c98d9a68d2596fe5e8fa380f449" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/a8a7e30534b0eb0c77cd9d07e82de1a114389f5e", - "reference": "a8a7e30534b0eb0c77cd9d07e82de1a114389f5e", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/f77d2d4e78738c98d9a68d2596fe5e8fa380f449", + "reference": "f77d2d4e78738c98d9a68d2596fe5e8fa380f449", "shasum": "" }, "require": { @@ -8914,15 +9229,27 @@ "support": { "issues": "https://github.com/sebastianbergmann/type/issues", "security": "https://github.com/sebastianbergmann/type/security/policy", - "source": "https://github.com/sebastianbergmann/type/tree/5.1.2" + "source": "https://github.com/sebastianbergmann/type/tree/5.1.3" }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/type", + "type": "tidelift" } ], - "time": "2025-03-18T13:35:50+00:00" + "time": "2025-08-09T06:55:48+00:00" }, { "name": "sebastian/version", @@ -9032,16 +9359,16 @@ }, { "name": "symfony/yaml", - "version": "v7.2.5", + "version": "v7.3.3", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "4c4b6f4cfcd7e52053f0c8bfad0f7f30fb924912" + "reference": "d4f4a66866fe2451f61296924767280ab5732d9d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/4c4b6f4cfcd7e52053f0c8bfad0f7f30fb924912", - "reference": "4c4b6f4cfcd7e52053f0c8bfad0f7f30fb924912", + "url": "https://api.github.com/repos/symfony/yaml/zipball/d4f4a66866fe2451f61296924767280ab5732d9d", + "reference": "d4f4a66866fe2451f61296924767280ab5732d9d", "shasum": "" }, "require": { @@ -9084,7 +9411,7 @@ "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v7.2.5" + "source": "https://github.com/symfony/yaml/tree/v7.3.3" }, "funding": [ { @@ -9095,32 +9422,36 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2025-03-03T07:12:39+00:00" + "time": "2025-08-27T11:34:33+00:00" }, { "name": "ta-tikoma/phpunit-architecture-test", - "version": "0.8.4", + "version": "0.8.5", "source": { "type": "git", "url": "https://github.com/ta-tikoma/phpunit-architecture-test.git", - "reference": "89f0dea1cb0f0d5744d3ec1764a286af5e006636" + "reference": "cf6fb197b676ba716837c886baca842e4db29005" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ta-tikoma/phpunit-architecture-test/zipball/89f0dea1cb0f0d5744d3ec1764a286af5e006636", - "reference": "89f0dea1cb0f0d5744d3ec1764a286af5e006636", + "url": "https://api.github.com/repos/ta-tikoma/phpunit-architecture-test/zipball/cf6fb197b676ba716837c886baca842e4db29005", + "reference": "cf6fb197b676ba716837c886baca842e4db29005", "shasum": "" }, "require": { "nikic/php-parser": "^4.18.0 || ^5.0.0", "php": "^8.1.0", "phpdocumentor/reflection-docblock": "^5.3.0", - "phpunit/phpunit": "^10.5.5 || ^11.0.0", + "phpunit/phpunit": "^10.5.5 || ^11.0.0 || ^12.0.0", "symfony/finder": "^6.4.0 || ^7.0.0" }, "require-dev": { @@ -9157,9 +9488,9 @@ ], "support": { "issues": "https://github.com/ta-tikoma/phpunit-architecture-test/issues", - "source": "https://github.com/ta-tikoma/phpunit-architecture-test/tree/0.8.4" + "source": "https://github.com/ta-tikoma/phpunit-architecture-test/tree/0.8.5" }, - "time": "2024-01-05T14:10:56+00:00" + "time": "2025-04-20T20:23:40+00:00" }, { "name": "theseer/tokenizer", @@ -9214,12 +9545,12 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": true, "prefer-lowest": false, "platform": { "php": "^8.2" }, - "platform-dev": [], - "plugin-api-version": "2.3.0" + "platform-dev": {}, + "plugin-api-version": "2.6.0" } diff --git a/backend/package-lock.json b/backend/package-lock.json index d2371c6..29e5849 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -1,9 +1,10 @@ { - "name": "backend", + "name": "html", "lockfileVersion": 3, "requires": true, "packages": { "": { + "name": "html", "dependencies": { "@tailwindcss/vite": "^4.0.7", "autoprefixer": "^10.4.20", @@ -420,9 +421,9 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.34.8", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.34.8.tgz", - "integrity": "sha512-q217OSE8DTp8AFHuNHXo0Y86e1wtlfVrXiAlwkIvGRQv9zbc6mE3sjIVfwI8sYUyNxwOg0j/Vm1RKM04JcWLJw==", + "version": "4.52.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.52.4.tgz", + "integrity": "sha512-BTm2qKNnWIQ5auf4deoetINJm2JzvihvGb9R6K/ETwKLql/Bb3Eg2H1FBp1gUb4YGbydMA3jcmQTR73q7J+GAA==", "cpu": [ "arm" ], @@ -433,9 +434,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.34.8", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.34.8.tgz", - "integrity": "sha512-Gigjz7mNWaOL9wCggvoK3jEIUUbGul656opstjaUSGC3eT0BM7PofdAJaBfPFWWkXNVAXbaQtC99OCg4sJv70Q==", + "version": "4.52.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.52.4.tgz", + "integrity": "sha512-P9LDQiC5vpgGFgz7GSM6dKPCiqR3XYN1WwJKA4/BUVDjHpYsf3iBEmVz62uyq20NGYbiGPR5cNHI7T1HqxNs2w==", "cpu": [ "arm64" ], @@ -446,9 +447,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.34.8", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.34.8.tgz", - "integrity": "sha512-02rVdZ5tgdUNRxIUrFdcMBZQoaPMrxtwSb+/hOfBdqkatYHR3lZ2A2EGyHq2sGOd0Owk80oV3snlDASC24He3Q==", + "version": "4.52.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.52.4.tgz", + "integrity": "sha512-QRWSW+bVccAvZF6cbNZBJwAehmvG9NwfWHwMy4GbWi/BQIA/laTIktebT2ipVjNncqE6GLPxOok5hsECgAxGZg==", "cpu": [ "arm64" ], @@ -459,9 +460,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.34.8", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.34.8.tgz", - "integrity": "sha512-qIP/elwR/tq/dYRx3lgwK31jkZvMiD6qUtOycLhTzCvrjbZ3LjQnEM9rNhSGpbLXVJYQ3rq39A6Re0h9tU2ynw==", + "version": "4.52.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.52.4.tgz", + "integrity": "sha512-hZgP05pResAkRJxL1b+7yxCnXPGsXU0fG9Yfd6dUaoGk+FhdPKCJ5L1Sumyxn8kvw8Qi5PvQ8ulenUbRjzeCTw==", "cpu": [ "x64" ], @@ -472,9 +473,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-arm64": { - "version": "4.34.8", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.34.8.tgz", - "integrity": "sha512-IQNVXL9iY6NniYbTaOKdrlVP3XIqazBgJOVkddzJlqnCpRi/yAeSOa8PLcECFSQochzqApIOE1GHNu3pCz+BDA==", + "version": "4.52.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.52.4.tgz", + "integrity": "sha512-xmc30VshuBNUd58Xk4TKAEcRZHaXlV+tCxIXELiE9sQuK3kG8ZFgSPi57UBJt8/ogfhAF5Oz4ZSUBN77weM+mQ==", "cpu": [ "arm64" ], @@ -485,9 +486,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-x64": { - "version": "4.34.8", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.34.8.tgz", - "integrity": "sha512-TYXcHghgnCqYFiE3FT5QwXtOZqDj5GmaFNTNt3jNC+vh22dc/ukG2cG+pi75QO4kACohZzidsq7yKTKwq/Jq7Q==", + "version": "4.52.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.52.4.tgz", + "integrity": "sha512-WdSLpZFjOEqNZGmHflxyifolwAiZmDQzuOzIq9L27ButpCVpD7KzTRtEG1I0wMPFyiyUdOO+4t8GvrnBLQSwpw==", "cpu": [ "x64" ], @@ -498,9 +499,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.34.8", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.34.8.tgz", - "integrity": "sha512-A4iphFGNkWRd+5m3VIGuqHnG3MVnqKe7Al57u9mwgbyZ2/xF9Jio72MaY7xxh+Y87VAHmGQr73qoKL9HPbXj1g==", + "version": "4.52.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.52.4.tgz", + "integrity": "sha512-xRiOu9Of1FZ4SxVbB0iEDXc4ddIcjCv2aj03dmW8UrZIW7aIQ9jVJdLBIhxBI+MaTnGAKyvMwPwQnoOEvP7FgQ==", "cpu": [ "arm" ], @@ -511,9 +512,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.34.8", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.34.8.tgz", - "integrity": "sha512-S0lqKLfTm5u+QTxlFiAnb2J/2dgQqRy/XvziPtDd1rKZFXHTyYLoVL58M/XFwDI01AQCDIevGLbQrMAtdyanpA==", + "version": "4.52.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.52.4.tgz", + "integrity": "sha512-FbhM2p9TJAmEIEhIgzR4soUcsW49e9veAQCziwbR+XWB2zqJ12b4i/+hel9yLiD8pLncDH4fKIPIbt5238341Q==", "cpu": [ "arm" ], @@ -524,9 +525,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.34.8", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.34.8.tgz", - "integrity": "sha512-jpz9YOuPiSkL4G4pqKrus0pn9aYwpImGkosRKwNi+sJSkz+WU3anZe6hi73StLOQdfXYXC7hUfsQlTnjMd3s1A==", + "version": "4.52.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.52.4.tgz", + "integrity": "sha512-4n4gVwhPHR9q/g8lKCyz0yuaD0MvDf7dV4f9tHt0C73Mp8h38UCtSCSE6R9iBlTbXlmA8CjpsZoujhszefqueg==", "cpu": [ "arm64" ], @@ -537,9 +538,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.34.8", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.34.8.tgz", - "integrity": "sha512-KdSfaROOUJXgTVxJNAZ3KwkRc5nggDk+06P6lgi1HLv1hskgvxHUKZ4xtwHkVYJ1Rep4GNo+uEfycCRRxht7+Q==", + "version": "4.52.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.52.4.tgz", + "integrity": "sha512-u0n17nGA0nvi/11gcZKsjkLj1QIpAuPFQbR48Subo7SmZJnGxDpspyw2kbpuoQnyK+9pwf3pAoEXerJs/8Mi9g==", "cpu": [ "arm64" ], @@ -549,10 +550,10 @@ "linux" ] }, - "node_modules/@rollup/rollup-linux-loongarch64-gnu": { - "version": "4.34.8", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.34.8.tgz", - "integrity": "sha512-NyF4gcxwkMFRjgXBM6g2lkT58OWztZvw5KkV2K0qqSnUEqCVcqdh2jN4gQrTn/YUpAcNKyFHfoOZEer9nwo6uQ==", + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.52.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.52.4.tgz", + "integrity": "sha512-0G2c2lpYtbTuXo8KEJkDkClE/+/2AFPdPAbmaHoE870foRFs4pBrDehilMcrSScrN/fB/1HTaWO4bqw+ewBzMQ==", "cpu": [ "loong64" ], @@ -562,10 +563,10 @@ "linux" ] }, - "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { - "version": "4.34.8", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.34.8.tgz", - "integrity": "sha512-LMJc999GkhGvktHU85zNTDImZVUCJ1z/MbAJTnviiWmmjyckP5aQsHtcujMjpNdMZPT2rQEDBlJfubhs3jsMfw==", + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.52.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.52.4.tgz", + "integrity": "sha512-teSACug1GyZHmPDv14VNbvZFX779UqWTsd7KtTM9JIZRDI5NUwYSIS30kzI8m06gOPB//jtpqlhmraQ68b5X2g==", "cpu": [ "ppc64" ], @@ -576,9 +577,22 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.34.8", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.34.8.tgz", - "integrity": "sha512-xAQCAHPj8nJq1PI3z8CIZzXuXCstquz7cIOL73HHdXiRcKk8Ywwqtx2wrIy23EcTn4aZ2fLJNBB8d0tQENPCmw==", + "version": "4.52.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.52.4.tgz", + "integrity": "sha512-/MOEW3aHjjs1p4Pw1Xk4+3egRevx8Ji9N6HUIA1Ifh8Q+cg9dremvFCUbOX2Zebz80BwJIgCBUemjqhU5XI5Eg==", + "cpu": [ + "riscv64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.52.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.52.4.tgz", + "integrity": "sha512-1HHmsRyh845QDpEWzOFtMCph5Ts+9+yllCrREuBR/vg2RogAQGGBRC8lDPrPOMnrdOJ+mt1WLMOC2Kao/UwcvA==", "cpu": [ "riscv64" ], @@ -589,9 +603,9 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.34.8", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.34.8.tgz", - "integrity": "sha512-DdePVk1NDEuc3fOe3dPPTb+rjMtuFw89gw6gVWxQFAuEqqSdDKnrwzZHrUYdac7A7dXl9Q2Vflxpme15gUWQFA==", + "version": "4.52.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.52.4.tgz", + "integrity": "sha512-seoeZp4L/6D1MUyjWkOMRU6/iLmCU2EjbMTyAG4oIOs1/I82Y5lTeaxW0KBfkUdHAWN7j25bpkt0rjnOgAcQcA==", "cpu": [ "s390x" ], @@ -615,9 +629,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.34.8", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.34.8.tgz", - "integrity": "sha512-SCXcP0ZpGFIe7Ge+McxY5zKxiEI5ra+GT3QRxL0pMMtxPfpyLAKleZODi1zdRHkz5/BhueUrYtYVgubqe9JBNQ==", + "version": "4.52.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.52.4.tgz", + "integrity": "sha512-dtBZYjDmCQ9hW+WgEkaffvRRCKm767wWhxsFW3Lw86VXz/uJRuD438/XvbZT//B96Vs8oTA8Q4A0AfHbrxP9zw==", "cpu": [ "x64" ], @@ -627,10 +641,23 @@ "linux" ] }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.52.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.52.4.tgz", + "integrity": "sha512-1ox+GqgRWqaB1RnyZXL8PD6E5f7YyRUJYnCqKpNzxzP0TkaUh112NDrR9Tt+C8rJ4x5G9Mk8PQR3o7Ku2RKqKA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.34.8", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.34.8.tgz", - "integrity": "sha512-YHYsgzZgFJzTRbth4h7Or0m5O74Yda+hLin0irAIobkLQFRQd1qWmnoVfwmKm9TXIZVAD0nZ+GEb2ICicLyCnQ==", + "version": "4.52.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.52.4.tgz", + "integrity": "sha512-8GKr640PdFNXwzIE0IrkMWUNUomILLkfeHjXBi/nUvFlpZP+FA8BKGKpacjW6OUUHaNI6sUURxR2U2g78FOHWQ==", "cpu": [ "arm64" ], @@ -641,9 +668,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.34.8", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.34.8.tgz", - "integrity": "sha512-r3NRQrXkHr4uWy5TOjTpTYojR9XmF0j/RYgKCef+Ag46FWUTltm5ziticv8LdNsDMehjJ543x/+TJAek/xBA2w==", + "version": "4.52.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.52.4.tgz", + "integrity": "sha512-AIy/jdJ7WtJ/F6EcfOb2GjR9UweO0n43jNObQMb6oGxkYTfLcnN7vYYpG+CN3lLxrQkzWnMOoNSHTW54pgbVxw==", "cpu": [ "ia32" ], @@ -653,10 +680,23 @@ "win32" ] }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.52.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.52.4.tgz", + "integrity": "sha512-UF9KfsH9yEam0UjTwAgdK0anlQ7c8/pWPU2yVjyWcF1I1thABt6WXE47cI71pGiZ8wGvxohBoLnxM04L/wj8mQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.34.8", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.34.8.tgz", - "integrity": "sha512-U0FaE5O1BCpZSeE6gBl3c5ObhePQSfk9vDRToMmTkbhCOgW4jqvtS5LGyQ76L1fH8sM0keRp4uDTsbjiUyjk0g==", + "version": "4.52.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.52.4.tgz", + "integrity": "sha512-bf9PtUa0u8IXDVxzRToFQKsNCRz9qLYfR/MpECxl4mRoWYjAeFjgxj1XdZr2M/GNVpT05p+LgQOHopYDlUu6/w==", "cpu": [ "x64" ], @@ -891,9 +931,9 @@ } }, "node_modules/@types/estree": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", - "integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", + "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", "license": "MIT" }, "node_modules/ansi-regex": { @@ -964,13 +1004,13 @@ } }, "node_modules/axios": { - "version": "1.7.9", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz", - "integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==", + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.12.2.tgz", + "integrity": "sha512-vMJzPewAlRyOgxV2dU0Cuz2O8zzzx9VYtbJOaBgXFeLc4IV/Eg50n4LowmehOOR61S8ZMpc2K5Sa7g6A4jfkUw==", "license": "MIT", "dependencies": { "follow-redirects": "^1.15.6", - "form-data": "^4.0.0", + "form-data": "^4.0.4", "proxy-from-env": "^1.1.0" } }, @@ -993,6 +1033,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "caniuse-lite": "^1.0.30001688", "electron-to-chromium": "^1.5.73", @@ -1311,14 +1352,15 @@ } }, "node_modules/form-data": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.2.tgz", - "integrity": "sha512-hGfm/slu0ZabnNt4oaRZ6uREyfCj6P4fT/n6A1rGV+Z0VdGXjfOhVUpkn6qVQONHGIFwmveGXyDs75+nr6FM8w==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz", + "integrity": "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==", "license": "MIT", "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", "es-set-tostringtag": "^2.1.0", + "hasown": "^2.0.2", "mime-types": "^2.1.12" }, "engines": { @@ -1844,6 +1886,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "nanoid": "^3.3.8", "picocolors": "^1.1.1", @@ -1875,12 +1918,12 @@ } }, "node_modules/rollup": { - "version": "4.34.8", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.34.8.tgz", - "integrity": "sha512-489gTVMzAYdiZHFVA/ig/iYFllCcWFHMvUHI1rpFmkoUtRlQxqh6/yiNqnYibjMZ2b/+FUQwldG+aLsEt6bglQ==", + "version": "4.52.4", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.52.4.tgz", + "integrity": "sha512-CLEVl+MnPAiKh5pl4dEWSyMTpuflgNQiLGhMv8ezD5W/qP8AKvmYpCOKRRNOh7oRKnauBZ4SyeYkMS+1VSyKwQ==", "license": "MIT", "dependencies": { - "@types/estree": "1.0.6" + "@types/estree": "1.0.8" }, "bin": { "rollup": "dist/bin/rollup" @@ -1890,32 +1933,35 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.34.8", - "@rollup/rollup-android-arm64": "4.34.8", - "@rollup/rollup-darwin-arm64": "4.34.8", - "@rollup/rollup-darwin-x64": "4.34.8", - "@rollup/rollup-freebsd-arm64": "4.34.8", - "@rollup/rollup-freebsd-x64": "4.34.8", - "@rollup/rollup-linux-arm-gnueabihf": "4.34.8", - "@rollup/rollup-linux-arm-musleabihf": "4.34.8", - "@rollup/rollup-linux-arm64-gnu": "4.34.8", - "@rollup/rollup-linux-arm64-musl": "4.34.8", - "@rollup/rollup-linux-loongarch64-gnu": "4.34.8", - "@rollup/rollup-linux-powerpc64le-gnu": "4.34.8", - "@rollup/rollup-linux-riscv64-gnu": "4.34.8", - "@rollup/rollup-linux-s390x-gnu": "4.34.8", - "@rollup/rollup-linux-x64-gnu": "4.34.8", - "@rollup/rollup-linux-x64-musl": "4.34.8", - "@rollup/rollup-win32-arm64-msvc": "4.34.8", - "@rollup/rollup-win32-ia32-msvc": "4.34.8", - "@rollup/rollup-win32-x64-msvc": "4.34.8", + "@rollup/rollup-android-arm-eabi": "4.52.4", + "@rollup/rollup-android-arm64": "4.52.4", + "@rollup/rollup-darwin-arm64": "4.52.4", + "@rollup/rollup-darwin-x64": "4.52.4", + "@rollup/rollup-freebsd-arm64": "4.52.4", + "@rollup/rollup-freebsd-x64": "4.52.4", + "@rollup/rollup-linux-arm-gnueabihf": "4.52.4", + "@rollup/rollup-linux-arm-musleabihf": "4.52.4", + "@rollup/rollup-linux-arm64-gnu": "4.52.4", + "@rollup/rollup-linux-arm64-musl": "4.52.4", + "@rollup/rollup-linux-loong64-gnu": "4.52.4", + "@rollup/rollup-linux-ppc64-gnu": "4.52.4", + "@rollup/rollup-linux-riscv64-gnu": "4.52.4", + "@rollup/rollup-linux-riscv64-musl": "4.52.4", + "@rollup/rollup-linux-s390x-gnu": "4.52.4", + "@rollup/rollup-linux-x64-gnu": "4.52.4", + "@rollup/rollup-linux-x64-musl": "4.52.4", + "@rollup/rollup-openharmony-arm64": "4.52.4", + "@rollup/rollup-win32-arm64-msvc": "4.52.4", + "@rollup/rollup-win32-ia32-msvc": "4.52.4", + "@rollup/rollup-win32-x64-gnu": "4.52.4", + "@rollup/rollup-win32-x64-msvc": "4.52.4", "fsevents": "~2.3.2" } }, "node_modules/rollup/node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.34.8", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.34.8.tgz", - "integrity": "sha512-8y7ED8gjxITUltTUEJLQdgpbPh1sUQ0kMTmufRF/Ns5tI9TNMNlhWtmPKKHCU0SilX+3MJkZ0zERYYGIVBYHIA==", + "version": "4.52.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.52.4.tgz", + "integrity": "sha512-Wi6AXf0k0L7E2gteNsNHUs7UMwCIhsCTs6+tqQ5GPwVRWMaflqGec4Sd8n6+FNFDw9vGcReqk2KzBDhCa1DLYg==", "cpu": [ "x64" ], @@ -2011,6 +2057,52 @@ "node": ">=6" } }, + "node_modules/tinyglobby": { + "version": "0.2.15", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", + "integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==", + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.3" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/tinyglobby/node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/tinyglobby/node_modules/picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/tree-kill": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", @@ -2057,14 +2149,18 @@ } }, "node_modules/vite": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/vite/-/vite-6.2.0.tgz", - "integrity": "sha512-7dPxoo+WsT/64rDcwoOjk76XHj+TqNTIvHKcuMQ1k4/SeHDaQt5GFAeLYzrimZrMpn/O6DtdI03WUjdxuPM0oQ==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/vite/-/vite-6.4.0.tgz", + "integrity": "sha512-oLnWs9Hak/LOlKjeSpOwD6JMks8BeICEdYMJBf6P4Lac/pO9tKiv/XhXnAM7nNfSkZahjlCZu9sS50zL8fSnsw==", "license": "MIT", + "peer": true, "dependencies": { "esbuild": "^0.25.0", + "fdir": "^6.4.4", + "picomatch": "^4.0.2", "postcss": "^8.5.3", - "rollup": "^4.30.1" + "rollup": "^4.34.9", + "tinyglobby": "^0.2.13" }, "bin": { "vite": "bin/vite.js" @@ -2137,6 +2233,36 @@ "picomatch": "^2.3.1" } }, + "node_modules/vite/node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/vite/node_modules/picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", diff --git a/backend/vite.config.js b/backend/vite.config.js index 8299591..dc94106 100644 --- a/backend/vite.config.js +++ b/backend/vite.config.js @@ -1,15 +1,24 @@ -// npm run dev # dev server -// npm run build # build for production -// npm run preview # preview production build - +/** + * Vite-Konfiguration für Backend (Thats-Me) + * - Domain: thats-me.test + * - Port: 5173 + * - Verwendet FluxUI + * - Build-Verzeichnis: public/build/thats-me + * + * Starten mit: npm run dev + */ import { defineConfig } from "vite"; import laravel from "laravel-vite-plugin"; import tailwindcss from "@tailwindcss/vite"; -import fs from "fs"; -// Pfade zu deinen MAMP-Zertifikaten -// const certPath = "/Applications/MAMP/Library/OpenSSL/certs/thats-me.test.crt"; -// const keyPath = "/Applications/MAMP/Library/OpenSSL/certs/thats-me.test.key"; +const httpsConfig = + process.env.NODE_ENV === "production" + ? { + // In Produktion: echte Zertifikate verwenden + key: process.env.SSL_KEY_PATH, + cert: process.env.SSL_CERT_PATH, + } + : true; // Self-signed für Entwicklung export default defineConfig({ plugins: [ @@ -20,17 +29,34 @@ export default defineConfig({ tailwindcss(), ], server: { - // https: { - // key: fs.readFileSync(keyPath), - // cert: fs.readFileSync(certPath), - // }, - cors: true, // Ergänze diese Zeile - host: "192.168.1.8", - port: 5173, - hmr: { - host: "192.168.1.8", - protocol: "https", + https: false, // Traefik übernimmt SSL + cors: { + origin: ["https://thats-me.test", "https://assets.thats-me.test"], + credentials: true, + }, + host: "0.0.0.0", + port: 5173, + strictPort: true, + allowedHosts: [ + "assets.thats-me.test", + "thats-me.test", + "localhost", + "0.0.0.0", + ], + hmr: { + host: "assets.thats-me.test", + protocol: "wss", + }, + origin: "https://assets.thats-me.test", // Ohne Port! + }, + build: { + outDir: "public/build/thats-me", + assetsDir: "", + manifest: "manifest.json", + rollupOptions: { + output: { + manualChunks: undefined, + }, }, - origin: "https://192.168.1.8:5173", }, }); diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3ab9c9e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,162 @@ +services: + # Laravel Backend Service + laravel.test: + build: + context: './backend/vendor/laravel/sail/runtimes/8.4' + dockerfile: Dockerfile + args: + WWWGROUP: '${WWWGROUP:-20}' + WWWUSER: '${WWWUSER:-501}' + image: 'sail-8.4/app' + extra_hosts: + - 'host.docker.internal:host-gateway' + ports: + - '${VITE_PORT:-5179}:5173' + environment: + WWWUSER: '${WWWUSER:-501}' + WWWGROUP: '${WWWGROUP:-20}' + LARAVEL_SAIL: 1 + XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}' + XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}' + IGNITION_LOCAL_SITES_PATH: '${PWD}' + DB_CONNECTION: mysql + DB_HOST: mysql + DB_PORT: 3306 + DB_DATABASE: thats-me + DB_USERNAME: sail + DB_PASSWORD: password + MAIL_HOST: mailpit + MAIL_PORT: 1025 + REDIS_HOST: redis + volumes: + - './backend:/var/www/html' + networks: + - sail + - proxy + depends_on: + - mysql + - mailpit + - redis + labels: + - "traefik.enable=true" + + # Domain 1: Hauptdomain thats-me.test (Webseite/Landingpage) + - "traefik.http.routers.thatsme-main.rule=Host(`thats-me.test`)" + - "traefik.http.routers.thatsme-main.entrypoints=websecure" + - "traefik.http.routers.thatsme-main.tls=true" + - "traefik.http.routers.thatsme-main.service=thatsme-service" + + # Domain 2: portal.thats-me.test (Admin Panel) + - "traefik.http.routers.thatsme-portal.rule=Host(`portal.thats-me.test`)" + - "traefik.http.routers.thatsme-portal.entrypoints=websecure" + - "traefik.http.routers.thatsme-portal.tls=true" + - "traefik.http.routers.thatsme-portal.service=thatsme-service" + + # Domain 3: api.thats-me.test (API für Quasar App) + - "traefik.http.routers.thatsme-api.rule=Host(`api.thats-me.test`)" + - "traefik.http.routers.thatsme-api.entrypoints=websecure" + - "traefik.http.routers.thatsme-api.tls=true" + - "traefik.http.routers.thatsme-api.service=thatsme-service" + + # Vite Asset Domain für Backend Development + - "traefik.http.routers.thatsme-assets.rule=Host(`assets.thats-me.test`)" + - "traefik.http.routers.thatsme-assets.entrypoints=websecure" + - "traefik.http.routers.thatsme-assets.tls=true" + - "traefik.http.routers.thatsme-assets.service=thatsme-assets-service" + + # Service Definitions + - "traefik.http.services.thatsme-service.loadbalancer.server.port=80" + - "traefik.http.services.thatsme-assets-service.loadbalancer.server.port=5173" + - "traefik.http.services.thatsme-assets-service.loadbalancer.server.scheme=http" + - "traefik.docker.network=proxy" + + # Quasar Frontend Service + quasar.app: + image: 'node:20-alpine' + working_dir: /app + command: sh -c "npm install && npm run dev" + ports: + - '${QUASAR_PORT:-9000}:9000' + environment: + NODE_ENV: development + volumes: + - './frontend:/app' + networks: + - sail + - proxy + labels: + - "traefik.enable=true" + + # Domain 4: app.thats-me.test (Quasar Frontend App) + - "traefik.http.routers.thatsme-app.rule=Host(`app.thats-me.test`)" + - "traefik.http.routers.thatsme-app.entrypoints=websecure" + - "traefik.http.routers.thatsme-app.tls=true" + - "traefik.http.routers.thatsme-app.service=thatsme-app-service" + + # Service Definition + - "traefik.http.services.thatsme-app-service.loadbalancer.server.port=9000" + - "traefik.http.services.thatsme-app-service.loadbalancer.server.scheme=http" + - "traefik.docker.network=proxy" + + # MySQL Database + mysql: + image: 'mysql/mysql-server:8.0' + ports: + - '${FORWARD_DB_PORT:-33070}:3306' + environment: + MYSQL_ROOT_PASSWORD: '${DB_PASSWORD:-password}' + MYSQL_ROOT_HOST: '%' + MYSQL_DATABASE: '${DB_DATABASE:-thats-me}' + MYSQL_USER: '${DB_USERNAME:-sail}' + MYSQL_PASSWORD: '${DB_PASSWORD:-password}' + MYSQL_ALLOW_EMPTY_PASSWORD: 1 + volumes: + - 'sail-mysql:/var/lib/mysql' + - './backend/vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh' + networks: + - sail + healthcheck: + test: + - CMD + - mysqladmin + - ping + - '-p${DB_PASSWORD:-password}' + retries: 3 + timeout: 5s + + # Mailpit für E-Mail Testing + mailpit: + image: 'axllent/mailpit:latest' + ports: + - '${FORWARD_MAILPIT_PORT:-1028}:1025' + - '${FORWARD_MAILPIT_DASHBOARD_PORT:-8028}:8025' + networks: + - sail + + # Redis Cache/Queue + redis: + image: 'redis:alpine' + ports: + - '${FORWARD_REDIS_PORT:-6383}:6379' + volumes: + - 'sail-redis:/data' + networks: + - sail + healthcheck: + test: + - CMD + - redis-cli + - ping + retries: 3 + timeout: 5s + +networks: + sail: + driver: bridge + proxy: + external: true +volumes: + sail-mysql: + driver: local + sail-redis: + driver: local diff --git a/dot-line-system/.gitignore b/dot-line-system/.gitignore new file mode 100644 index 0000000..a547bf3 --- /dev/null +++ b/dot-line-system/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/dot-line-system/.history/index_20250515080205.html b/dot-line-system/.history/index_20250515080205.html new file mode 100644 index 0000000..a991726 --- /dev/null +++ b/dot-line-system/.history/index_20250515080205.html @@ -0,0 +1,86 @@ + + + + + + + + Connected Dots Visualization + + + + +
+ + +
+
+
+
+ +
+ + + diff --git a/dot-line-system/.history/index_20250515093839.html b/dot-line-system/.history/index_20250515093839.html new file mode 100644 index 0000000..8020d80 --- /dev/null +++ b/dot-line-system/.history/index_20250515093839.html @@ -0,0 +1,86 @@ + + + + + + + + Connected Dots Visualization + + + + + + + +
+
+
+
+ + + + + diff --git a/dot-line-system/.history/index_20250522083017.html b/dot-line-system/.history/index_20250522083017.html new file mode 100644 index 0000000..1e0cd44 --- /dev/null +++ b/dot-line-system/.history/index_20250522083017.html @@ -0,0 +1,125 @@ + + + + + + + + Connected Dots Visualization + + + + + + + +
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/dot-line-system/.history/index_20250522083042.html b/dot-line-system/.history/index_20250522083042.html new file mode 100644 index 0000000..31c10e6 --- /dev/null +++ b/dot-line-system/.history/index_20250522083042.html @@ -0,0 +1,92 @@ + + + + + + + + Connected Dots Visualization + + + + + + + +
+
+
+
+ + + + + + \ No newline at end of file diff --git a/dot-line-system/.history/index_20250522083155.html b/dot-line-system/.history/index_20250522083155.html new file mode 100644 index 0000000..a4f6d5a --- /dev/null +++ b/dot-line-system/.history/index_20250522083155.html @@ -0,0 +1,93 @@ + + + + + + + + Connected Dots Visualization + + + + + + + +
+
+
+
+ + + + + + \ No newline at end of file diff --git a/dot-line-system/.history/index_20250522085953.html b/dot-line-system/.history/index_20250522085953.html new file mode 100644 index 0000000..bc2c92b --- /dev/null +++ b/dot-line-system/.history/index_20250522085953.html @@ -0,0 +1,28 @@ + + + + + + + + Connected Dots Visualization + + + + + + + + +
+
+
+
+ + + + + + \ No newline at end of file diff --git a/dot-line-system/.history/index_20250522090004.html b/dot-line-system/.history/index_20250522090004.html new file mode 100644 index 0000000..fa0ba23 --- /dev/null +++ b/dot-line-system/.history/index_20250522090004.html @@ -0,0 +1,28 @@ + + + + + + + + Connected Dots Visualization + + + + + + + + +
+
+
+
+ + + + + + \ No newline at end of file diff --git a/dot-line-system/.history/index_20250522090012.html b/dot-line-system/.history/index_20250522090012.html new file mode 100644 index 0000000..f556919 --- /dev/null +++ b/dot-line-system/.history/index_20250522090012.html @@ -0,0 +1,25 @@ + + + + + + + + Connected Dots Visualization + + + + + + + +
+
+
+
+ + + + + + \ No newline at end of file diff --git a/dot-line-system/.history/index_20250522090611.html b/dot-line-system/.history/index_20250522090611.html new file mode 100644 index 0000000..014c674 --- /dev/null +++ b/dot-line-system/.history/index_20250522090611.html @@ -0,0 +1,26 @@ + + + + + + + + Connected Dots Visualization + + + + + + + +
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/dot-line-system/.history/index_20250522090656.html b/dot-line-system/.history/index_20250522090656.html new file mode 100644 index 0000000..014c674 --- /dev/null +++ b/dot-line-system/.history/index_20250522090656.html @@ -0,0 +1,26 @@ + + + + + + + + Connected Dots Visualization + + + + + + + +
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/dot-line-system/.history/index_20250522090717.html b/dot-line-system/.history/index_20250522090717.html new file mode 100644 index 0000000..bc7028c --- /dev/null +++ b/dot-line-system/.history/index_20250522090717.html @@ -0,0 +1,27 @@ + + + + + + + + Connected Dots Visualization + + + + + + + +
+
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/dot-line-system/.history/index_20250522090730.html b/dot-line-system/.history/index_20250522090730.html new file mode 100644 index 0000000..014c674 --- /dev/null +++ b/dot-line-system/.history/index_20250522090730.html @@ -0,0 +1,26 @@ + + + + + + + + Connected Dots Visualization + + + + + + + +
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/dot-line-system/.history/index_20250522095109.html b/dot-line-system/.history/index_20250522095109.html new file mode 100644 index 0000000..d03862f --- /dev/null +++ b/dot-line-system/.history/index_20250522095109.html @@ -0,0 +1,29 @@ + + + + + + + + Connected Dots Visualization + + + + + + + + + + +
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/dot-line-system/.history/index_20250522114322.html b/dot-line-system/.history/index_20250522114322.html new file mode 100644 index 0000000..d03862f --- /dev/null +++ b/dot-line-system/.history/index_20250522114322.html @@ -0,0 +1,29 @@ + + + + + + + + Connected Dots Visualization + + + + + + + + + + +
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/dot-line-system/.history/index_20250522114359.html b/dot-line-system/.history/index_20250522114359.html new file mode 100644 index 0000000..4112aaf --- /dev/null +++ b/dot-line-system/.history/index_20250522114359.html @@ -0,0 +1,30 @@ + + + + + + + + Connected Dots Visualization + + + + + + + + + + +
+
+ +
+
+
+ + + + + + \ No newline at end of file diff --git a/dot-line-system/.history/index_20250522114425.html b/dot-line-system/.history/index_20250522114425.html new file mode 100644 index 0000000..d03862f --- /dev/null +++ b/dot-line-system/.history/index_20250522114425.html @@ -0,0 +1,29 @@ + + + + + + + + Connected Dots Visualization + + + + + + + + + + +
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/dot-line-system/.history/index_20250522114819.html b/dot-line-system/.history/index_20250522114819.html new file mode 100644 index 0000000..d03862f --- /dev/null +++ b/dot-line-system/.history/index_20250522114819.html @@ -0,0 +1,29 @@ + + + + + + + + Connected Dots Visualization + + + + + + + + + + +
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/dot-line-system/.history/index_20250522130240.html b/dot-line-system/.history/index_20250522130240.html new file mode 100644 index 0000000..d03862f --- /dev/null +++ b/dot-line-system/.history/index_20250522130240.html @@ -0,0 +1,29 @@ + + + + + + + + Connected Dots Visualization + + + + + + + + + + +
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/dot-line-system/.history/index_20250522130258.html b/dot-line-system/.history/index_20250522130258.html new file mode 100644 index 0000000..d03862f --- /dev/null +++ b/dot-line-system/.history/index_20250522130258.html @@ -0,0 +1,29 @@ + + + + + + + + Connected Dots Visualization + + + + + + + + + + +
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/dot-line-system/.history/index_20250522130455.html b/dot-line-system/.history/index_20250522130455.html new file mode 100644 index 0000000..d03862f --- /dev/null +++ b/dot-line-system/.history/index_20250522130455.html @@ -0,0 +1,29 @@ + + + + + + + + Connected Dots Visualization + + + + + + + + + + +
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/dot-line-system/.history/index_20250522130505.html b/dot-line-system/.history/index_20250522130505.html new file mode 100644 index 0000000..6adfe7f --- /dev/null +++ b/dot-line-system/.history/index_20250522130505.html @@ -0,0 +1,25 @@ + + + + + + + + Connected Dots Visualization + + + + + + + + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/dot-line-system/.history/index_20250522130518.html b/dot-line-system/.history/index_20250522130518.html new file mode 100644 index 0000000..9309940 --- /dev/null +++ b/dot-line-system/.history/index_20250522130518.html @@ -0,0 +1,25 @@ + + + + + + + + Connected Dots Visualization + + + + + + + + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/dot-line-system/.history/index_20250522130539.html b/dot-line-system/.history/index_20250522130539.html new file mode 100644 index 0000000..9309940 --- /dev/null +++ b/dot-line-system/.history/index_20250522130539.html @@ -0,0 +1,25 @@ + + + + + + + + Connected Dots Visualization + + + + + + + + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/dot-line-system/.history/index_20250522130613.html b/dot-line-system/.history/index_20250522130613.html new file mode 100644 index 0000000..9309940 --- /dev/null +++ b/dot-line-system/.history/index_20250522130613.html @@ -0,0 +1,25 @@ + + + + + + + + Connected Dots Visualization + + + + + + + + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/dot-line-system/.history/index_20250522132851.html b/dot-line-system/.history/index_20250522132851.html new file mode 100644 index 0000000..77ca0c9 --- /dev/null +++ b/dot-line-system/.history/index_20250522132851.html @@ -0,0 +1,25 @@ + + + + + + + + Connected Dots Visualization + + + + + + + + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/dot-line-system/.history/index_20250522133036.html b/dot-line-system/.history/index_20250522133036.html new file mode 100644 index 0000000..77ca0c9 --- /dev/null +++ b/dot-line-system/.history/index_20250522133036.html @@ -0,0 +1,25 @@ + + + + + + + + Connected Dots Visualization + + + + + + + + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/dot-line-system/.history/index_20250522222202.html b/dot-line-system/.history/index_20250522222202.html new file mode 100644 index 0000000..77ca0c9 --- /dev/null +++ b/dot-line-system/.history/index_20250522222202.html @@ -0,0 +1,25 @@ + + + + + + + + Connected Dots Visualization + + + + + + + + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/dot-line-system/.history/index_20250522222233.html b/dot-line-system/.history/index_20250522222233.html new file mode 100644 index 0000000..415baa6 --- /dev/null +++ b/dot-line-system/.history/index_20250522222233.html @@ -0,0 +1,25 @@ + + + + + + + + Life Line + + + + + + + + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/dot-line-system/.history/package_20250515093313.json b/dot-line-system/.history/package_20250515093313.json new file mode 100644 index 0000000..6d93786 --- /dev/null +++ b/dot-line-system/.history/package_20250515093313.json @@ -0,0 +1,15 @@ +{ + "name": "dot-line-system", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc && vite build", + "preview": "vite preview" + }, + "devDependencies": { + "typescript": "~5.7.2", + "vite": "^6.3.5" + } +} diff --git a/dot-line-system/.history/package_20250515093412.json b/dot-line-system/.history/package_20250515093412.json new file mode 100644 index 0000000..9c7aefd --- /dev/null +++ b/dot-line-system/.history/package_20250515093412.json @@ -0,0 +1,20 @@ +{ + "name": "dot-line-system", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc && vite build", + "preview": "vite preview" + }, + "devDependencies": { + "typescript": "~5.7.2", + "vite": "^6.3.5" + }, + "scripts": { + "build": "vite build", + "start": "vite", + "tsc": "tsc" +} +} diff --git a/dot-line-system/.history/package_20250515093415.json b/dot-line-system/.history/package_20250515093415.json new file mode 100644 index 0000000..882780f --- /dev/null +++ b/dot-line-system/.history/package_20250515093415.json @@ -0,0 +1,20 @@ +{ + "name": "dot-line-system", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc && vite build", + "preview": "vite preview" + }, + "devDependencies": { + "typescript": "~5.7.2", + "vite": "^6.3.5" + }, + "scripts": { + "build": "vite build", + "start": "vite", + "tsc": "tsc" + } +} diff --git a/dot-line-system/.history/readme_20250521221324.md b/dot-line-system/.history/readme_20250521221324.md new file mode 100644 index 0000000..e69de29 diff --git a/dot-line-system/.history/readme_20250521221329.md b/dot-line-system/.history/readme_20250521221329.md new file mode 100644 index 0000000..b896a08 --- /dev/null +++ b/dot-line-system/.history/readme_20250521221329.md @@ -0,0 +1 @@ +npm run dev \ No newline at end of file diff --git a/dot-line-system/.history/readme_20250521221343.md b/dot-line-system/.history/readme_20250521221343.md new file mode 100644 index 0000000..c2d989b --- /dev/null +++ b/dot-line-system/.history/readme_20250521221343.md @@ -0,0 +1,2 @@ +*Start the project* +npm run dev \ No newline at end of file diff --git a/dot-line-system/.history/readme_20250521221558.md b/dot-line-system/.history/readme_20250521221558.md new file mode 100644 index 0000000..509d6b0 --- /dev/null +++ b/dot-line-system/.history/readme_20250521221558.md @@ -0,0 +1,3 @@ +**Start the project** + +npm run dev \ No newline at end of file diff --git a/dot-line-system/.history/readme_20250521221603.md b/dot-line-system/.history/readme_20250521221603.md new file mode 100644 index 0000000..ca40a30 --- /dev/null +++ b/dot-line-system/.history/readme_20250521221603.md @@ -0,0 +1,2 @@ +**Start the project** +npm run dev \ No newline at end of file diff --git a/dot-line-system/.history/readme_20250521221932.md b/dot-line-system/.history/readme_20250521221932.md new file mode 100644 index 0000000..46e160d --- /dev/null +++ b/dot-line-system/.history/readme_20250521221932.md @@ -0,0 +1,4 @@ +**Start the project** +npm install + +npm run \ No newline at end of file diff --git a/dot-line-system/.history/readme_20250522081835.md b/dot-line-system/.history/readme_20250522081835.md new file mode 100644 index 0000000..16dac6d --- /dev/null +++ b/dot-line-system/.history/readme_20250522081835.md @@ -0,0 +1,7 @@ +**Prepare the project** +npm install + +**Start the project** +npm start + +http://localhost:5173/ \ No newline at end of file diff --git a/dot-line-system/.history/readme_20250522081843.md b/dot-line-system/.history/readme_20250522081843.md new file mode 100644 index 0000000..2d357b2 --- /dev/null +++ b/dot-line-system/.history/readme_20250522081843.md @@ -0,0 +1,8 @@ +**Prepare the project** +npm install + +**Start the project** +npm start + +**Aufrufen** +http://localhost:5173/ \ No newline at end of file diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250515080205.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250515080205.ts new file mode 100644 index 0000000..67a6b1d --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250515080205.ts @@ -0,0 +1,545 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor(containerId: string, dots: DotConfig[], config?: Partial) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 200, + tooltipHeight: 150, + ...config + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + this.gridGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.curvePath = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + this.dotsGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.tooltipGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter(dot => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map(dot => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = {current: 0, total: imageUrls.length}; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log('All images preloaded successfully'); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + }; + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = 'connected-dots-styles'; + + if (!document.getElementById(styleId)) { + const style = document.createElement('style'); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute('width', `${this.config.totalWidth}`); + this.svg.setAttribute('height', `${this.config.height}`); + this.svg.style.overflow = 'visible'; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add('grid'); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute('fill', 'none'); + this.curvePath.setAttribute('stroke', 'white'); + this.curvePath.setAttribute('stroke-width', '2'); + this.curvePath.setAttribute('stroke-linecap', 'round'); + this.curvePath.classList.add('curve-path'); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add('tooltips'); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * (this.config.height / 2 * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints(dots: DotConfig[], index: number): ControlPoints { + const tension = this.config.tension * 150; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ''; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY(this.dots[0].value)}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints(this.dots, i); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', '0'); + line.setAttribute('y1', this.getDotY(value).toString()); + line.setAttribute('x2', this.config.totalWidth.toString()); + line.setAttribute('y2', this.getDotY(value).toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', '10'); + text.setAttribute('y', (this.getDotY(value) + 4).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil(this.config.totalWidth / this.config.xUnitSize); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', x.toString()); + line.setAttribute('y1', '0'); + line.setAttribute('x2', x.toString()); + line.setAttribute('y2', this.config.height.toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', x.toString()); + text.setAttribute('y', (this.config.height / 2 + 20).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.setAttribute('text-anchor', 'middle'); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + tooltip.classList.add('dot-tooltip'); + tooltip.setAttribute('data-dot-id', dot.id.toString()); + + // Calculate tooltip position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + + // Calculate tooltip Y position, ensuring it stays within the container + let tooltipY = y - tooltipHeight - 20; // Position above the dot with some spacing + + // Ensure tooltip doesn't go above the container + tooltipY = Math.max(tooltipY, 10); // Keep at least 10px from the top + + // Background rectangle + const bg = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); + bg.setAttribute('x', tooltipX.toString()); + bg.setAttribute('y', tooltipY.toString()); + bg.setAttribute('width', tooltipWidth.toString()); + bg.setAttribute('height', tooltipHeight.toString()); + bg.setAttribute('rx', '5'); + bg.setAttribute('ry', '5'); + bg.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(bg); + + // Tooltip arrow (pointing to the dot) + const arrow = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + arrow.setAttribute('d', `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${tooltipY + tooltipHeight - 10} L ${x + 10} ${tooltipY + tooltipHeight - 10} Z`); + arrow.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(arrow); + + // Image (if provided) + if (dot.imageUrl) { + const imgContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + imgContainer.setAttribute('x', (tooltipX + 10).toString()); + imgContainer.setAttribute('y', (tooltipY + 10).toString()); + imgContainer.setAttribute('width', (tooltipWidth - 20).toString()); + imgContainer.setAttribute('height', (tooltipHeight / 2).toString()); + + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.className = 'tooltip-img'; + + imgContainer.appendChild(img); + tooltip.appendChild(imgContainer); + } + + // Title (if provided) + if (dot.title) { + const title = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + title.setAttribute('x', (tooltipX + 10).toString()); + title.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 26).toString() + : (tooltipY + 25).toString()); + title.setAttribute('fill', 'white'); + title.setAttribute('font-size', '14'); + title.setAttribute('font-weight', 'bold'); + title.textContent = dot.title; + tooltip.appendChild(title); + } + + // Description (if provided) + if (dot.description) { + const descriptionFO = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + descriptionFO.setAttribute('x', (tooltipX + 10).toString()); + descriptionFO.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 32).toString() + : dot.title + ? (tooltipY + 35).toString() + : (tooltipY + 15).toString()); + descriptionFO.setAttribute('width', (tooltipWidth - 20).toString()); + descriptionFO.setAttribute('height', (tooltipHeight / 2 - 10).toString()); + + const descriptionDiv = document.createElement('div'); + descriptionDiv.style.color = 'white'; + descriptionDiv.style.fontSize = '12px'; + descriptionDiv.style.overflow = 'hidden'; + descriptionDiv.textContent = dot.description; + + descriptionFO.appendChild(descriptionDiv); + tooltip.appendChild(descriptionFO); + } + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute('d', pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); + circle.setAttribute('cx', x.toString()); + circle.setAttribute('cy', y.toString()); + circle.setAttribute('r', this.config.dotRadius.toString()); + circle.setAttribute('fill', 'white'); + circle.setAttribute('data-dot-id', dot.id.toString()); + circle.classList.add('dot'); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener('click', () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error('Dot has no link'); + throw new Error('Dot has no link'); + } + }); + } + + this.dotsGroup.appendChild(circle); + }; + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute('width', `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute('height', `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250515094002.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250515094002.ts new file mode 100644 index 0000000..55596ee --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250515094002.ts @@ -0,0 +1,545 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor(containerId: string, dots: DotConfig[], config?: Partial) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 200; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 200, + tooltipHeight: 150, + ...config + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + this.gridGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.curvePath = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + this.dotsGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.tooltipGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter(dot => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map(dot => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = {current: 0, total: imageUrls.length}; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log('All images preloaded successfully'); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + }; + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = 'connected-dots-styles'; + + if (!document.getElementById(styleId)) { + const style = document.createElement('style'); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute('width', `${this.config.totalWidth}`); + this.svg.setAttribute('height', `${this.config.height}`); + this.svg.style.overflow = 'visible'; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add('grid'); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute('fill', 'none'); + this.curvePath.setAttribute('stroke', 'white'); + this.curvePath.setAttribute('stroke-width', '2'); + this.curvePath.setAttribute('stroke-linecap', 'round'); + this.curvePath.classList.add('curve-path'); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add('tooltips'); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * (this.config.height / 2 * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints(dots: DotConfig[], index: number): ControlPoints { + const tension = this.config.tension * 150; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ''; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY(this.dots[0].value)}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints(this.dots, i); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', '0'); + line.setAttribute('y1', this.getDotY(value).toString()); + line.setAttribute('x2', this.config.totalWidth.toString()); + line.setAttribute('y2', this.getDotY(value).toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', '10'); + text.setAttribute('y', (this.getDotY(value) + 4).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil(this.config.totalWidth / this.config.xUnitSize); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', x.toString()); + line.setAttribute('y1', '0'); + line.setAttribute('x2', x.toString()); + line.setAttribute('y2', this.config.height.toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', x.toString()); + text.setAttribute('y', (this.config.height / 2 + 20).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.setAttribute('text-anchor', 'middle'); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + tooltip.classList.add('dot-tooltip'); + tooltip.setAttribute('data-dot-id', dot.id.toString()); + + // Calculate tooltip position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + + // Calculate tooltip Y position, ensuring it stays within the container + let tooltipY = y - tooltipHeight - 20; // Position above the dot with some spacing + + // Ensure tooltip doesn't go above the container + tooltipY = Math.max(tooltipY, 10); // Keep at least 10px from the top + + // Background rectangle + const bg = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); + bg.setAttribute('x', tooltipX.toString()); + bg.setAttribute('y', tooltipY.toString()); + bg.setAttribute('width', tooltipWidth.toString()); + bg.setAttribute('height', tooltipHeight.toString()); + bg.setAttribute('rx', '5'); + bg.setAttribute('ry', '5'); + bg.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(bg); + + // Tooltip arrow (pointing to the dot) + const arrow = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + arrow.setAttribute('d', `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${tooltipY + tooltipHeight - 10} L ${x + 10} ${tooltipY + tooltipHeight - 10} Z`); + arrow.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(arrow); + + // Image (if provided) + if (dot.imageUrl) { + const imgContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + imgContainer.setAttribute('x', (tooltipX + 10).toString()); + imgContainer.setAttribute('y', (tooltipY + 10).toString()); + imgContainer.setAttribute('width', (tooltipWidth - 20).toString()); + imgContainer.setAttribute('height', (tooltipHeight / 2).toString()); + + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.className = 'tooltip-img'; + + imgContainer.appendChild(img); + tooltip.appendChild(imgContainer); + } + + // Title (if provided) + if (dot.title) { + const title = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + title.setAttribute('x', (tooltipX + 10).toString()); + title.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 26).toString() + : (tooltipY + 25).toString()); + title.setAttribute('fill', 'white'); + title.setAttribute('font-size', '14'); + title.setAttribute('font-weight', 'bold'); + title.textContent = dot.title; + tooltip.appendChild(title); + } + + // Description (if provided) + if (dot.description) { + const descriptionFO = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + descriptionFO.setAttribute('x', (tooltipX + 10).toString()); + descriptionFO.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 32).toString() + : dot.title + ? (tooltipY + 35).toString() + : (tooltipY + 15).toString()); + descriptionFO.setAttribute('width', (tooltipWidth - 20).toString()); + descriptionFO.setAttribute('height', (tooltipHeight / 2 - 10).toString()); + + const descriptionDiv = document.createElement('div'); + descriptionDiv.style.color = 'white'; + descriptionDiv.style.fontSize = '12px'; + descriptionDiv.style.overflow = 'hidden'; + descriptionDiv.textContent = dot.description; + + descriptionFO.appendChild(descriptionDiv); + tooltip.appendChild(descriptionFO); + } + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute('d', pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); + circle.setAttribute('cx', x.toString()); + circle.setAttribute('cy', y.toString()); + circle.setAttribute('r', this.config.dotRadius.toString()); + circle.setAttribute('fill', 'white'); + circle.setAttribute('data-dot-id', dot.id.toString()); + circle.classList.add('dot'); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener('click', () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error('Dot has no link'); + throw new Error('Dot has no link'); + } + }); + } + + this.dotsGroup.appendChild(circle); + }; + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute('width', `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute('height', `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250515094010.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250515094010.ts new file mode 100644 index 0000000..430cc96 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250515094010.ts @@ -0,0 +1,545 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor(containerId: string, dots: DotConfig[], config?: Partial) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 160; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 200, + tooltipHeight: 150, + ...config + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + this.gridGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.curvePath = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + this.dotsGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.tooltipGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter(dot => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map(dot => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = {current: 0, total: imageUrls.length}; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log('All images preloaded successfully'); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + }; + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = 'connected-dots-styles'; + + if (!document.getElementById(styleId)) { + const style = document.createElement('style'); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute('width', `${this.config.totalWidth}`); + this.svg.setAttribute('height', `${this.config.height}`); + this.svg.style.overflow = 'visible'; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add('grid'); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute('fill', 'none'); + this.curvePath.setAttribute('stroke', 'white'); + this.curvePath.setAttribute('stroke-width', '2'); + this.curvePath.setAttribute('stroke-linecap', 'round'); + this.curvePath.classList.add('curve-path'); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add('tooltips'); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * (this.config.height / 2 * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints(dots: DotConfig[], index: number): ControlPoints { + const tension = this.config.tension * 150; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ''; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY(this.dots[0].value)}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints(this.dots, i); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', '0'); + line.setAttribute('y1', this.getDotY(value).toString()); + line.setAttribute('x2', this.config.totalWidth.toString()); + line.setAttribute('y2', this.getDotY(value).toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', '10'); + text.setAttribute('y', (this.getDotY(value) + 4).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil(this.config.totalWidth / this.config.xUnitSize); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', x.toString()); + line.setAttribute('y1', '0'); + line.setAttribute('x2', x.toString()); + line.setAttribute('y2', this.config.height.toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', x.toString()); + text.setAttribute('y', (this.config.height / 2 + 20).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.setAttribute('text-anchor', 'middle'); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + tooltip.classList.add('dot-tooltip'); + tooltip.setAttribute('data-dot-id', dot.id.toString()); + + // Calculate tooltip position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + + // Calculate tooltip Y position, ensuring it stays within the container + let tooltipY = y - tooltipHeight - 20; // Position above the dot with some spacing + + // Ensure tooltip doesn't go above the container + tooltipY = Math.max(tooltipY, 10); // Keep at least 10px from the top + + // Background rectangle + const bg = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); + bg.setAttribute('x', tooltipX.toString()); + bg.setAttribute('y', tooltipY.toString()); + bg.setAttribute('width', tooltipWidth.toString()); + bg.setAttribute('height', tooltipHeight.toString()); + bg.setAttribute('rx', '5'); + bg.setAttribute('ry', '5'); + bg.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(bg); + + // Tooltip arrow (pointing to the dot) + const arrow = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + arrow.setAttribute('d', `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${tooltipY + tooltipHeight - 10} L ${x + 10} ${tooltipY + tooltipHeight - 10} Z`); + arrow.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(arrow); + + // Image (if provided) + if (dot.imageUrl) { + const imgContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + imgContainer.setAttribute('x', (tooltipX + 10).toString()); + imgContainer.setAttribute('y', (tooltipY + 10).toString()); + imgContainer.setAttribute('width', (tooltipWidth - 20).toString()); + imgContainer.setAttribute('height', (tooltipHeight / 2).toString()); + + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.className = 'tooltip-img'; + + imgContainer.appendChild(img); + tooltip.appendChild(imgContainer); + } + + // Title (if provided) + if (dot.title) { + const title = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + title.setAttribute('x', (tooltipX + 10).toString()); + title.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 26).toString() + : (tooltipY + 25).toString()); + title.setAttribute('fill', 'white'); + title.setAttribute('font-size', '14'); + title.setAttribute('font-weight', 'bold'); + title.textContent = dot.title; + tooltip.appendChild(title); + } + + // Description (if provided) + if (dot.description) { + const descriptionFO = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + descriptionFO.setAttribute('x', (tooltipX + 10).toString()); + descriptionFO.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 32).toString() + : dot.title + ? (tooltipY + 35).toString() + : (tooltipY + 15).toString()); + descriptionFO.setAttribute('width', (tooltipWidth - 20).toString()); + descriptionFO.setAttribute('height', (tooltipHeight / 2 - 10).toString()); + + const descriptionDiv = document.createElement('div'); + descriptionDiv.style.color = 'white'; + descriptionDiv.style.fontSize = '12px'; + descriptionDiv.style.overflow = 'hidden'; + descriptionDiv.textContent = dot.description; + + descriptionFO.appendChild(descriptionDiv); + tooltip.appendChild(descriptionFO); + } + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute('d', pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); + circle.setAttribute('cx', x.toString()); + circle.setAttribute('cy', y.toString()); + circle.setAttribute('r', this.config.dotRadius.toString()); + circle.setAttribute('fill', 'white'); + circle.setAttribute('data-dot-id', dot.id.toString()); + circle.classList.add('dot'); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener('click', () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error('Dot has no link'); + throw new Error('Dot has no link'); + } + }); + } + + this.dotsGroup.appendChild(circle); + }; + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute('width', `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute('height', `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250515094030.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250515094030.ts new file mode 100644 index 0000000..c9bbcbb --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250515094030.ts @@ -0,0 +1,545 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor(containerId: string, dots: DotConfig[], config?: Partial) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 160; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 10) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 200, + tooltipHeight: 150, + ...config + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + this.gridGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.curvePath = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + this.dotsGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.tooltipGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter(dot => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map(dot => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = {current: 0, total: imageUrls.length}; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log('All images preloaded successfully'); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + }; + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = 'connected-dots-styles'; + + if (!document.getElementById(styleId)) { + const style = document.createElement('style'); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute('width', `${this.config.totalWidth}`); + this.svg.setAttribute('height', `${this.config.height}`); + this.svg.style.overflow = 'visible'; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add('grid'); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute('fill', 'none'); + this.curvePath.setAttribute('stroke', 'white'); + this.curvePath.setAttribute('stroke-width', '2'); + this.curvePath.setAttribute('stroke-linecap', 'round'); + this.curvePath.classList.add('curve-path'); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add('tooltips'); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * (this.config.height / 2 * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints(dots: DotConfig[], index: number): ControlPoints { + const tension = this.config.tension * 150; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ''; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY(this.dots[0].value)}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints(this.dots, i); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', '0'); + line.setAttribute('y1', this.getDotY(value).toString()); + line.setAttribute('x2', this.config.totalWidth.toString()); + line.setAttribute('y2', this.getDotY(value).toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', '10'); + text.setAttribute('y', (this.getDotY(value) + 4).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil(this.config.totalWidth / this.config.xUnitSize); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', x.toString()); + line.setAttribute('y1', '0'); + line.setAttribute('x2', x.toString()); + line.setAttribute('y2', this.config.height.toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', x.toString()); + text.setAttribute('y', (this.config.height / 2 + 20).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.setAttribute('text-anchor', 'middle'); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + tooltip.classList.add('dot-tooltip'); + tooltip.setAttribute('data-dot-id', dot.id.toString()); + + // Calculate tooltip position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + + // Calculate tooltip Y position, ensuring it stays within the container + let tooltipY = y - tooltipHeight - 20; // Position above the dot with some spacing + + // Ensure tooltip doesn't go above the container + tooltipY = Math.max(tooltipY, 10); // Keep at least 10px from the top + + // Background rectangle + const bg = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); + bg.setAttribute('x', tooltipX.toString()); + bg.setAttribute('y', tooltipY.toString()); + bg.setAttribute('width', tooltipWidth.toString()); + bg.setAttribute('height', tooltipHeight.toString()); + bg.setAttribute('rx', '5'); + bg.setAttribute('ry', '5'); + bg.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(bg); + + // Tooltip arrow (pointing to the dot) + const arrow = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + arrow.setAttribute('d', `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${tooltipY + tooltipHeight - 10} L ${x + 10} ${tooltipY + tooltipHeight - 10} Z`); + arrow.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(arrow); + + // Image (if provided) + if (dot.imageUrl) { + const imgContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + imgContainer.setAttribute('x', (tooltipX + 10).toString()); + imgContainer.setAttribute('y', (tooltipY + 10).toString()); + imgContainer.setAttribute('width', (tooltipWidth - 20).toString()); + imgContainer.setAttribute('height', (tooltipHeight / 2).toString()); + + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.className = 'tooltip-img'; + + imgContainer.appendChild(img); + tooltip.appendChild(imgContainer); + } + + // Title (if provided) + if (dot.title) { + const title = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + title.setAttribute('x', (tooltipX + 10).toString()); + title.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 26).toString() + : (tooltipY + 25).toString()); + title.setAttribute('fill', 'white'); + title.setAttribute('font-size', '14'); + title.setAttribute('font-weight', 'bold'); + title.textContent = dot.title; + tooltip.appendChild(title); + } + + // Description (if provided) + if (dot.description) { + const descriptionFO = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + descriptionFO.setAttribute('x', (tooltipX + 10).toString()); + descriptionFO.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 32).toString() + : dot.title + ? (tooltipY + 35).toString() + : (tooltipY + 15).toString()); + descriptionFO.setAttribute('width', (tooltipWidth - 20).toString()); + descriptionFO.setAttribute('height', (tooltipHeight / 2 - 10).toString()); + + const descriptionDiv = document.createElement('div'); + descriptionDiv.style.color = 'white'; + descriptionDiv.style.fontSize = '12px'; + descriptionDiv.style.overflow = 'hidden'; + descriptionDiv.textContent = dot.description; + + descriptionFO.appendChild(descriptionDiv); + tooltip.appendChild(descriptionFO); + } + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute('d', pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); + circle.setAttribute('cx', x.toString()); + circle.setAttribute('cy', y.toString()); + circle.setAttribute('r', this.config.dotRadius.toString()); + circle.setAttribute('fill', 'white'); + circle.setAttribute('data-dot-id', dot.id.toString()); + circle.classList.add('dot'); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener('click', () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error('Dot has no link'); + throw new Error('Dot has no link'); + } + }); + } + + this.dotsGroup.appendChild(circle); + }; + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute('width', `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute('height', `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250515094033.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250515094033.ts new file mode 100644 index 0000000..430cc96 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250515094033.ts @@ -0,0 +1,545 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor(containerId: string, dots: DotConfig[], config?: Partial) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 160; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 200, + tooltipHeight: 150, + ...config + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + this.gridGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.curvePath = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + this.dotsGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.tooltipGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter(dot => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map(dot => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = {current: 0, total: imageUrls.length}; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log('All images preloaded successfully'); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + }; + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = 'connected-dots-styles'; + + if (!document.getElementById(styleId)) { + const style = document.createElement('style'); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute('width', `${this.config.totalWidth}`); + this.svg.setAttribute('height', `${this.config.height}`); + this.svg.style.overflow = 'visible'; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add('grid'); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute('fill', 'none'); + this.curvePath.setAttribute('stroke', 'white'); + this.curvePath.setAttribute('stroke-width', '2'); + this.curvePath.setAttribute('stroke-linecap', 'round'); + this.curvePath.classList.add('curve-path'); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add('tooltips'); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * (this.config.height / 2 * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints(dots: DotConfig[], index: number): ControlPoints { + const tension = this.config.tension * 150; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ''; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY(this.dots[0].value)}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints(this.dots, i); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', '0'); + line.setAttribute('y1', this.getDotY(value).toString()); + line.setAttribute('x2', this.config.totalWidth.toString()); + line.setAttribute('y2', this.getDotY(value).toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', '10'); + text.setAttribute('y', (this.getDotY(value) + 4).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil(this.config.totalWidth / this.config.xUnitSize); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', x.toString()); + line.setAttribute('y1', '0'); + line.setAttribute('x2', x.toString()); + line.setAttribute('y2', this.config.height.toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', x.toString()); + text.setAttribute('y', (this.config.height / 2 + 20).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.setAttribute('text-anchor', 'middle'); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + tooltip.classList.add('dot-tooltip'); + tooltip.setAttribute('data-dot-id', dot.id.toString()); + + // Calculate tooltip position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + + // Calculate tooltip Y position, ensuring it stays within the container + let tooltipY = y - tooltipHeight - 20; // Position above the dot with some spacing + + // Ensure tooltip doesn't go above the container + tooltipY = Math.max(tooltipY, 10); // Keep at least 10px from the top + + // Background rectangle + const bg = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); + bg.setAttribute('x', tooltipX.toString()); + bg.setAttribute('y', tooltipY.toString()); + bg.setAttribute('width', tooltipWidth.toString()); + bg.setAttribute('height', tooltipHeight.toString()); + bg.setAttribute('rx', '5'); + bg.setAttribute('ry', '5'); + bg.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(bg); + + // Tooltip arrow (pointing to the dot) + const arrow = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + arrow.setAttribute('d', `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${tooltipY + tooltipHeight - 10} L ${x + 10} ${tooltipY + tooltipHeight - 10} Z`); + arrow.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(arrow); + + // Image (if provided) + if (dot.imageUrl) { + const imgContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + imgContainer.setAttribute('x', (tooltipX + 10).toString()); + imgContainer.setAttribute('y', (tooltipY + 10).toString()); + imgContainer.setAttribute('width', (tooltipWidth - 20).toString()); + imgContainer.setAttribute('height', (tooltipHeight / 2).toString()); + + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.className = 'tooltip-img'; + + imgContainer.appendChild(img); + tooltip.appendChild(imgContainer); + } + + // Title (if provided) + if (dot.title) { + const title = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + title.setAttribute('x', (tooltipX + 10).toString()); + title.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 26).toString() + : (tooltipY + 25).toString()); + title.setAttribute('fill', 'white'); + title.setAttribute('font-size', '14'); + title.setAttribute('font-weight', 'bold'); + title.textContent = dot.title; + tooltip.appendChild(title); + } + + // Description (if provided) + if (dot.description) { + const descriptionFO = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + descriptionFO.setAttribute('x', (tooltipX + 10).toString()); + descriptionFO.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 32).toString() + : dot.title + ? (tooltipY + 35).toString() + : (tooltipY + 15).toString()); + descriptionFO.setAttribute('width', (tooltipWidth - 20).toString()); + descriptionFO.setAttribute('height', (tooltipHeight / 2 - 10).toString()); + + const descriptionDiv = document.createElement('div'); + descriptionDiv.style.color = 'white'; + descriptionDiv.style.fontSize = '12px'; + descriptionDiv.style.overflow = 'hidden'; + descriptionDiv.textContent = dot.description; + + descriptionFO.appendChild(descriptionDiv); + tooltip.appendChild(descriptionFO); + } + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute('d', pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); + circle.setAttribute('cx', x.toString()); + circle.setAttribute('cy', y.toString()); + circle.setAttribute('r', this.config.dotRadius.toString()); + circle.setAttribute('fill', 'white'); + circle.setAttribute('data-dot-id', dot.id.toString()); + circle.classList.add('dot'); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener('click', () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error('Dot has no link'); + throw new Error('Dot has no link'); + } + }); + } + + this.dotsGroup.appendChild(circle); + }; + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute('width', `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute('height', `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250515094036.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250515094036.ts new file mode 100644 index 0000000..67a6b1d --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250515094036.ts @@ -0,0 +1,545 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor(containerId: string, dots: DotConfig[], config?: Partial) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 200, + tooltipHeight: 150, + ...config + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + this.gridGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.curvePath = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + this.dotsGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.tooltipGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter(dot => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map(dot => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = {current: 0, total: imageUrls.length}; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log('All images preloaded successfully'); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + }; + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = 'connected-dots-styles'; + + if (!document.getElementById(styleId)) { + const style = document.createElement('style'); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute('width', `${this.config.totalWidth}`); + this.svg.setAttribute('height', `${this.config.height}`); + this.svg.style.overflow = 'visible'; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add('grid'); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute('fill', 'none'); + this.curvePath.setAttribute('stroke', 'white'); + this.curvePath.setAttribute('stroke-width', '2'); + this.curvePath.setAttribute('stroke-linecap', 'round'); + this.curvePath.classList.add('curve-path'); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add('tooltips'); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * (this.config.height / 2 * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints(dots: DotConfig[], index: number): ControlPoints { + const tension = this.config.tension * 150; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ''; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY(this.dots[0].value)}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints(this.dots, i); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', '0'); + line.setAttribute('y1', this.getDotY(value).toString()); + line.setAttribute('x2', this.config.totalWidth.toString()); + line.setAttribute('y2', this.getDotY(value).toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', '10'); + text.setAttribute('y', (this.getDotY(value) + 4).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil(this.config.totalWidth / this.config.xUnitSize); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', x.toString()); + line.setAttribute('y1', '0'); + line.setAttribute('x2', x.toString()); + line.setAttribute('y2', this.config.height.toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', x.toString()); + text.setAttribute('y', (this.config.height / 2 + 20).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.setAttribute('text-anchor', 'middle'); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + tooltip.classList.add('dot-tooltip'); + tooltip.setAttribute('data-dot-id', dot.id.toString()); + + // Calculate tooltip position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + + // Calculate tooltip Y position, ensuring it stays within the container + let tooltipY = y - tooltipHeight - 20; // Position above the dot with some spacing + + // Ensure tooltip doesn't go above the container + tooltipY = Math.max(tooltipY, 10); // Keep at least 10px from the top + + // Background rectangle + const bg = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); + bg.setAttribute('x', tooltipX.toString()); + bg.setAttribute('y', tooltipY.toString()); + bg.setAttribute('width', tooltipWidth.toString()); + bg.setAttribute('height', tooltipHeight.toString()); + bg.setAttribute('rx', '5'); + bg.setAttribute('ry', '5'); + bg.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(bg); + + // Tooltip arrow (pointing to the dot) + const arrow = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + arrow.setAttribute('d', `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${tooltipY + tooltipHeight - 10} L ${x + 10} ${tooltipY + tooltipHeight - 10} Z`); + arrow.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(arrow); + + // Image (if provided) + if (dot.imageUrl) { + const imgContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + imgContainer.setAttribute('x', (tooltipX + 10).toString()); + imgContainer.setAttribute('y', (tooltipY + 10).toString()); + imgContainer.setAttribute('width', (tooltipWidth - 20).toString()); + imgContainer.setAttribute('height', (tooltipHeight / 2).toString()); + + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.className = 'tooltip-img'; + + imgContainer.appendChild(img); + tooltip.appendChild(imgContainer); + } + + // Title (if provided) + if (dot.title) { + const title = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + title.setAttribute('x', (tooltipX + 10).toString()); + title.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 26).toString() + : (tooltipY + 25).toString()); + title.setAttribute('fill', 'white'); + title.setAttribute('font-size', '14'); + title.setAttribute('font-weight', 'bold'); + title.textContent = dot.title; + tooltip.appendChild(title); + } + + // Description (if provided) + if (dot.description) { + const descriptionFO = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + descriptionFO.setAttribute('x', (tooltipX + 10).toString()); + descriptionFO.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 32).toString() + : dot.title + ? (tooltipY + 35).toString() + : (tooltipY + 15).toString()); + descriptionFO.setAttribute('width', (tooltipWidth - 20).toString()); + descriptionFO.setAttribute('height', (tooltipHeight / 2 - 10).toString()); + + const descriptionDiv = document.createElement('div'); + descriptionDiv.style.color = 'white'; + descriptionDiv.style.fontSize = '12px'; + descriptionDiv.style.overflow = 'hidden'; + descriptionDiv.textContent = dot.description; + + descriptionFO.appendChild(descriptionDiv); + tooltip.appendChild(descriptionFO); + } + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute('d', pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); + circle.setAttribute('cx', x.toString()); + circle.setAttribute('cy', y.toString()); + circle.setAttribute('r', this.config.dotRadius.toString()); + circle.setAttribute('fill', 'white'); + circle.setAttribute('data-dot-id', dot.id.toString()); + circle.classList.add('dot'); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener('click', () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error('Dot has no link'); + throw new Error('Dot has no link'); + } + }); + } + + this.dotsGroup.appendChild(circle); + }; + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute('width', `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute('height', `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250515094059.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250515094059.ts new file mode 100644 index 0000000..4a059d8 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250515094059.ts @@ -0,0 +1,545 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor(containerId: string, dots: DotConfig[], config?: Partial) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + this.gridGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.curvePath = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + this.dotsGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.tooltipGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter(dot => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map(dot => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = {current: 0, total: imageUrls.length}; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log('All images preloaded successfully'); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + }; + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = 'connected-dots-styles'; + + if (!document.getElementById(styleId)) { + const style = document.createElement('style'); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute('width', `${this.config.totalWidth}`); + this.svg.setAttribute('height', `${this.config.height}`); + this.svg.style.overflow = 'visible'; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add('grid'); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute('fill', 'none'); + this.curvePath.setAttribute('stroke', 'white'); + this.curvePath.setAttribute('stroke-width', '2'); + this.curvePath.setAttribute('stroke-linecap', 'round'); + this.curvePath.classList.add('curve-path'); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add('tooltips'); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * (this.config.height / 2 * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints(dots: DotConfig[], index: number): ControlPoints { + const tension = this.config.tension * 150; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ''; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY(this.dots[0].value)}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints(this.dots, i); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', '0'); + line.setAttribute('y1', this.getDotY(value).toString()); + line.setAttribute('x2', this.config.totalWidth.toString()); + line.setAttribute('y2', this.getDotY(value).toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', '10'); + text.setAttribute('y', (this.getDotY(value) + 4).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil(this.config.totalWidth / this.config.xUnitSize); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', x.toString()); + line.setAttribute('y1', '0'); + line.setAttribute('x2', x.toString()); + line.setAttribute('y2', this.config.height.toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', x.toString()); + text.setAttribute('y', (this.config.height / 2 + 20).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.setAttribute('text-anchor', 'middle'); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + tooltip.classList.add('dot-tooltip'); + tooltip.setAttribute('data-dot-id', dot.id.toString()); + + // Calculate tooltip position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + + // Calculate tooltip Y position, ensuring it stays within the container + let tooltipY = y - tooltipHeight - 20; // Position above the dot with some spacing + + // Ensure tooltip doesn't go above the container + tooltipY = Math.max(tooltipY, 10); // Keep at least 10px from the top + + // Background rectangle + const bg = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); + bg.setAttribute('x', tooltipX.toString()); + bg.setAttribute('y', tooltipY.toString()); + bg.setAttribute('width', tooltipWidth.toString()); + bg.setAttribute('height', tooltipHeight.toString()); + bg.setAttribute('rx', '5'); + bg.setAttribute('ry', '5'); + bg.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(bg); + + // Tooltip arrow (pointing to the dot) + const arrow = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + arrow.setAttribute('d', `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${tooltipY + tooltipHeight - 10} L ${x + 10} ${tooltipY + tooltipHeight - 10} Z`); + arrow.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(arrow); + + // Image (if provided) + if (dot.imageUrl) { + const imgContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + imgContainer.setAttribute('x', (tooltipX + 10).toString()); + imgContainer.setAttribute('y', (tooltipY + 10).toString()); + imgContainer.setAttribute('width', (tooltipWidth - 20).toString()); + imgContainer.setAttribute('height', (tooltipHeight / 2).toString()); + + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.className = 'tooltip-img'; + + imgContainer.appendChild(img); + tooltip.appendChild(imgContainer); + } + + // Title (if provided) + if (dot.title) { + const title = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + title.setAttribute('x', (tooltipX + 10).toString()); + title.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 26).toString() + : (tooltipY + 25).toString()); + title.setAttribute('fill', 'white'); + title.setAttribute('font-size', '14'); + title.setAttribute('font-weight', 'bold'); + title.textContent = dot.title; + tooltip.appendChild(title); + } + + // Description (if provided) + if (dot.description) { + const descriptionFO = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + descriptionFO.setAttribute('x', (tooltipX + 10).toString()); + descriptionFO.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 32).toString() + : dot.title + ? (tooltipY + 35).toString() + : (tooltipY + 15).toString()); + descriptionFO.setAttribute('width', (tooltipWidth - 20).toString()); + descriptionFO.setAttribute('height', (tooltipHeight / 2 - 10).toString()); + + const descriptionDiv = document.createElement('div'); + descriptionDiv.style.color = 'white'; + descriptionDiv.style.fontSize = '12px'; + descriptionDiv.style.overflow = 'hidden'; + descriptionDiv.textContent = dot.description; + + descriptionFO.appendChild(descriptionDiv); + tooltip.appendChild(descriptionFO); + } + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute('d', pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); + circle.setAttribute('cx', x.toString()); + circle.setAttribute('cy', y.toString()); + circle.setAttribute('r', this.config.dotRadius.toString()); + circle.setAttribute('fill', 'white'); + circle.setAttribute('data-dot-id', dot.id.toString()); + circle.classList.add('dot'); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener('click', () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error('Dot has no link'); + throw new Error('Dot has no link'); + } + }); + } + + this.dotsGroup.appendChild(circle); + }; + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute('width', `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute('height', `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250515094215.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250515094215.ts new file mode 100644 index 0000000..2af0be1 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250515094215.ts @@ -0,0 +1,545 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor(containerId: string, dots: DotConfig[], config?: Partial) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + this.gridGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.curvePath = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + this.dotsGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.tooltipGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter(dot => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map(dot => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = {current: 0, total: imageUrls.length}; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log('All images preloaded successfully'); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + }; + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = 'connected-dots-styles'; + + if (!document.getElementById(styleId)) { + const style = document.createElement('style'); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute('width', `${this.config.totalWidth}`); + this.svg.setAttribute('height', `${this.config.height}`); + this.svg.style.overflow = 'visible'; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add('grid'); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute('fill', 'none'); + this.curvePath.setAttribute('stroke', 'white'); + this.curvePath.setAttribute('stroke-width', '2'); + this.curvePath.setAttribute('stroke-linecap', 'round'); + this.curvePath.classList.add('curve-path'); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add('tooltips'); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * (this.config.height / 2 * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints(dots: DotConfig[], index: number): ControlPoints { + const tension = this.config.tension * 250; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ''; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY(this.dots[0].value)}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints(this.dots, i); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', '0'); + line.setAttribute('y1', this.getDotY(value).toString()); + line.setAttribute('x2', this.config.totalWidth.toString()); + line.setAttribute('y2', this.getDotY(value).toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', '10'); + text.setAttribute('y', (this.getDotY(value) + 4).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil(this.config.totalWidth / this.config.xUnitSize); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', x.toString()); + line.setAttribute('y1', '0'); + line.setAttribute('x2', x.toString()); + line.setAttribute('y2', this.config.height.toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', x.toString()); + text.setAttribute('y', (this.config.height / 2 + 20).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.setAttribute('text-anchor', 'middle'); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + tooltip.classList.add('dot-tooltip'); + tooltip.setAttribute('data-dot-id', dot.id.toString()); + + // Calculate tooltip position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + + // Calculate tooltip Y position, ensuring it stays within the container + let tooltipY = y - tooltipHeight - 20; // Position above the dot with some spacing + + // Ensure tooltip doesn't go above the container + tooltipY = Math.max(tooltipY, 10); // Keep at least 10px from the top + + // Background rectangle + const bg = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); + bg.setAttribute('x', tooltipX.toString()); + bg.setAttribute('y', tooltipY.toString()); + bg.setAttribute('width', tooltipWidth.toString()); + bg.setAttribute('height', tooltipHeight.toString()); + bg.setAttribute('rx', '5'); + bg.setAttribute('ry', '5'); + bg.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(bg); + + // Tooltip arrow (pointing to the dot) + const arrow = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + arrow.setAttribute('d', `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${tooltipY + tooltipHeight - 10} L ${x + 10} ${tooltipY + tooltipHeight - 10} Z`); + arrow.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(arrow); + + // Image (if provided) + if (dot.imageUrl) { + const imgContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + imgContainer.setAttribute('x', (tooltipX + 10).toString()); + imgContainer.setAttribute('y', (tooltipY + 10).toString()); + imgContainer.setAttribute('width', (tooltipWidth - 20).toString()); + imgContainer.setAttribute('height', (tooltipHeight / 2).toString()); + + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.className = 'tooltip-img'; + + imgContainer.appendChild(img); + tooltip.appendChild(imgContainer); + } + + // Title (if provided) + if (dot.title) { + const title = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + title.setAttribute('x', (tooltipX + 10).toString()); + title.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 26).toString() + : (tooltipY + 25).toString()); + title.setAttribute('fill', 'white'); + title.setAttribute('font-size', '14'); + title.setAttribute('font-weight', 'bold'); + title.textContent = dot.title; + tooltip.appendChild(title); + } + + // Description (if provided) + if (dot.description) { + const descriptionFO = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + descriptionFO.setAttribute('x', (tooltipX + 10).toString()); + descriptionFO.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 32).toString() + : dot.title + ? (tooltipY + 35).toString() + : (tooltipY + 15).toString()); + descriptionFO.setAttribute('width', (tooltipWidth - 20).toString()); + descriptionFO.setAttribute('height', (tooltipHeight / 2 - 10).toString()); + + const descriptionDiv = document.createElement('div'); + descriptionDiv.style.color = 'white'; + descriptionDiv.style.fontSize = '12px'; + descriptionDiv.style.overflow = 'hidden'; + descriptionDiv.textContent = dot.description; + + descriptionFO.appendChild(descriptionDiv); + tooltip.appendChild(descriptionFO); + } + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute('d', pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); + circle.setAttribute('cx', x.toString()); + circle.setAttribute('cy', y.toString()); + circle.setAttribute('r', this.config.dotRadius.toString()); + circle.setAttribute('fill', 'white'); + circle.setAttribute('data-dot-id', dot.id.toString()); + circle.classList.add('dot'); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener('click', () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error('Dot has no link'); + throw new Error('Dot has no link'); + } + }); + } + + this.dotsGroup.appendChild(circle); + }; + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute('width', `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute('height', `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250515094221.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250515094221.ts new file mode 100644 index 0000000..04e0114 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250515094221.ts @@ -0,0 +1,545 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor(containerId: string, dots: DotConfig[], config?: Partial) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + this.gridGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.curvePath = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + this.dotsGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.tooltipGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter(dot => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map(dot => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = {current: 0, total: imageUrls.length}; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log('All images preloaded successfully'); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + }; + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = 'connected-dots-styles'; + + if (!document.getElementById(styleId)) { + const style = document.createElement('style'); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute('width', `${this.config.totalWidth}`); + this.svg.setAttribute('height', `${this.config.height}`); + this.svg.style.overflow = 'visible'; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add('grid'); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute('fill', 'none'); + this.curvePath.setAttribute('stroke', 'white'); + this.curvePath.setAttribute('stroke-width', '2'); + this.curvePath.setAttribute('stroke-linecap', 'round'); + this.curvePath.classList.add('curve-path'); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add('tooltips'); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * (this.config.height / 2 * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints(dots: DotConfig[], index: number): ControlPoints { + const tension = this.config.tension * 300; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ''; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY(this.dots[0].value)}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints(this.dots, i); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', '0'); + line.setAttribute('y1', this.getDotY(value).toString()); + line.setAttribute('x2', this.config.totalWidth.toString()); + line.setAttribute('y2', this.getDotY(value).toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', '10'); + text.setAttribute('y', (this.getDotY(value) + 4).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil(this.config.totalWidth / this.config.xUnitSize); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', x.toString()); + line.setAttribute('y1', '0'); + line.setAttribute('x2', x.toString()); + line.setAttribute('y2', this.config.height.toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', x.toString()); + text.setAttribute('y', (this.config.height / 2 + 20).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.setAttribute('text-anchor', 'middle'); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + tooltip.classList.add('dot-tooltip'); + tooltip.setAttribute('data-dot-id', dot.id.toString()); + + // Calculate tooltip position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + + // Calculate tooltip Y position, ensuring it stays within the container + let tooltipY = y - tooltipHeight - 20; // Position above the dot with some spacing + + // Ensure tooltip doesn't go above the container + tooltipY = Math.max(tooltipY, 10); // Keep at least 10px from the top + + // Background rectangle + const bg = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); + bg.setAttribute('x', tooltipX.toString()); + bg.setAttribute('y', tooltipY.toString()); + bg.setAttribute('width', tooltipWidth.toString()); + bg.setAttribute('height', tooltipHeight.toString()); + bg.setAttribute('rx', '5'); + bg.setAttribute('ry', '5'); + bg.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(bg); + + // Tooltip arrow (pointing to the dot) + const arrow = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + arrow.setAttribute('d', `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${tooltipY + tooltipHeight - 10} L ${x + 10} ${tooltipY + tooltipHeight - 10} Z`); + arrow.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(arrow); + + // Image (if provided) + if (dot.imageUrl) { + const imgContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + imgContainer.setAttribute('x', (tooltipX + 10).toString()); + imgContainer.setAttribute('y', (tooltipY + 10).toString()); + imgContainer.setAttribute('width', (tooltipWidth - 20).toString()); + imgContainer.setAttribute('height', (tooltipHeight / 2).toString()); + + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.className = 'tooltip-img'; + + imgContainer.appendChild(img); + tooltip.appendChild(imgContainer); + } + + // Title (if provided) + if (dot.title) { + const title = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + title.setAttribute('x', (tooltipX + 10).toString()); + title.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 26).toString() + : (tooltipY + 25).toString()); + title.setAttribute('fill', 'white'); + title.setAttribute('font-size', '14'); + title.setAttribute('font-weight', 'bold'); + title.textContent = dot.title; + tooltip.appendChild(title); + } + + // Description (if provided) + if (dot.description) { + const descriptionFO = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + descriptionFO.setAttribute('x', (tooltipX + 10).toString()); + descriptionFO.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 32).toString() + : dot.title + ? (tooltipY + 35).toString() + : (tooltipY + 15).toString()); + descriptionFO.setAttribute('width', (tooltipWidth - 20).toString()); + descriptionFO.setAttribute('height', (tooltipHeight / 2 - 10).toString()); + + const descriptionDiv = document.createElement('div'); + descriptionDiv.style.color = 'white'; + descriptionDiv.style.fontSize = '12px'; + descriptionDiv.style.overflow = 'hidden'; + descriptionDiv.textContent = dot.description; + + descriptionFO.appendChild(descriptionDiv); + tooltip.appendChild(descriptionFO); + } + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute('d', pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); + circle.setAttribute('cx', x.toString()); + circle.setAttribute('cy', y.toString()); + circle.setAttribute('r', this.config.dotRadius.toString()); + circle.setAttribute('fill', 'white'); + circle.setAttribute('data-dot-id', dot.id.toString()); + circle.classList.add('dot'); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener('click', () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error('Dot has no link'); + throw new Error('Dot has no link'); + } + }); + } + + this.dotsGroup.appendChild(circle); + }; + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute('width', `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute('height', `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250515094419.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250515094419.ts new file mode 100644 index 0000000..6b48da2 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250515094419.ts @@ -0,0 +1,545 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor(containerId: string, dots: DotConfig[], config?: Partial) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + this.gridGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.curvePath = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + this.dotsGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.tooltipGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter(dot => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map(dot => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = {current: 0, total: imageUrls.length}; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log('All images preloaded successfully'); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + }; + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = 'connected-dots-styles'; + + if (!document.getElementById(styleId)) { + const style = document.createElement('style'); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute('width', `${this.config.totalWidth}`); + this.svg.setAttribute('height', `${this.config.height}`); + this.svg.style.overflow = 'visible'; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add('grid'); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute('fill', 'none'); + this.curvePath.setAttribute('stroke', 'white'); + this.curvePath.setAttribute('stroke-width', '2'); + this.curvePath.setAttribute('stroke-linecap', 'round'); + this.curvePath.classList.add('curve-path'); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add('tooltips'); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * (this.config.height / 2 * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints(dots: DotConfig[], index: number): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ''; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY(this.dots[0].value)}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints(this.dots, i); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', '0'); + line.setAttribute('y1', this.getDotY(value).toString()); + line.setAttribute('x2', this.config.totalWidth.toString()); + line.setAttribute('y2', this.getDotY(value).toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', '10'); + text.setAttribute('y', (this.getDotY(value) + 4).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil(this.config.totalWidth / this.config.xUnitSize); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', x.toString()); + line.setAttribute('y1', '0'); + line.setAttribute('x2', x.toString()); + line.setAttribute('y2', this.config.height.toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', x.toString()); + text.setAttribute('y', (this.config.height / 2 + 20).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.setAttribute('text-anchor', 'middle'); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + tooltip.classList.add('dot-tooltip'); + tooltip.setAttribute('data-dot-id', dot.id.toString()); + + // Calculate tooltip position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + + // Calculate tooltip Y position, ensuring it stays within the container + let tooltipY = y - tooltipHeight - 20; // Position above the dot with some spacing + + // Ensure tooltip doesn't go above the container + tooltipY = Math.max(tooltipY, 10); // Keep at least 10px from the top + + // Background rectangle + const bg = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); + bg.setAttribute('x', tooltipX.toString()); + bg.setAttribute('y', tooltipY.toString()); + bg.setAttribute('width', tooltipWidth.toString()); + bg.setAttribute('height', tooltipHeight.toString()); + bg.setAttribute('rx', '5'); + bg.setAttribute('ry', '5'); + bg.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(bg); + + // Tooltip arrow (pointing to the dot) + const arrow = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + arrow.setAttribute('d', `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${tooltipY + tooltipHeight - 10} L ${x + 10} ${tooltipY + tooltipHeight - 10} Z`); + arrow.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(arrow); + + // Image (if provided) + if (dot.imageUrl) { + const imgContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + imgContainer.setAttribute('x', (tooltipX + 10).toString()); + imgContainer.setAttribute('y', (tooltipY + 10).toString()); + imgContainer.setAttribute('width', (tooltipWidth - 20).toString()); + imgContainer.setAttribute('height', (tooltipHeight / 2).toString()); + + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.className = 'tooltip-img'; + + imgContainer.appendChild(img); + tooltip.appendChild(imgContainer); + } + + // Title (if provided) + if (dot.title) { + const title = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + title.setAttribute('x', (tooltipX + 10).toString()); + title.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 26).toString() + : (tooltipY + 25).toString()); + title.setAttribute('fill', 'white'); + title.setAttribute('font-size', '14'); + title.setAttribute('font-weight', 'bold'); + title.textContent = dot.title; + tooltip.appendChild(title); + } + + // Description (if provided) + if (dot.description) { + const descriptionFO = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + descriptionFO.setAttribute('x', (tooltipX + 10).toString()); + descriptionFO.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 32).toString() + : dot.title + ? (tooltipY + 35).toString() + : (tooltipY + 15).toString()); + descriptionFO.setAttribute('width', (tooltipWidth - 20).toString()); + descriptionFO.setAttribute('height', (tooltipHeight / 2 - 10).toString()); + + const descriptionDiv = document.createElement('div'); + descriptionDiv.style.color = 'white'; + descriptionDiv.style.fontSize = '12px'; + descriptionDiv.style.overflow = 'hidden'; + descriptionDiv.textContent = dot.description; + + descriptionFO.appendChild(descriptionDiv); + tooltip.appendChild(descriptionFO); + } + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute('d', pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); + circle.setAttribute('cx', x.toString()); + circle.setAttribute('cy', y.toString()); + circle.setAttribute('r', this.config.dotRadius.toString()); + circle.setAttribute('fill', 'white'); + circle.setAttribute('data-dot-id', dot.id.toString()); + circle.classList.add('dot'); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener('click', () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error('Dot has no link'); + throw new Error('Dot has no link'); + } + }); + } + + this.dotsGroup.appendChild(circle); + }; + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute('width', `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute('height', `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522091556.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522091556.ts new file mode 100644 index 0000000..5374d09 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522091556.ts @@ -0,0 +1,553 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor(containerId: string, dots: DotConfig[], config?: Partial) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + this.gridGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.curvePath = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + this.dotsGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.tooltipGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter(dot => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map(dot => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = {current: 0, total: imageUrls.length}; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log('All images preloaded successfully'); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + }; + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = 'connected-dots-styles'; + + if (!document.getElementById(styleId)) { + const style = document.createElement('style'); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute('width', `${this.config.totalWidth}`); + this.svg.setAttribute('height', `${this.config.height}`); + this.svg.style.overflow = 'visible'; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add('grid'); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute('fill', 'none'); + this.curvePath.setAttribute('stroke', 'white'); + this.curvePath.setAttribute('stroke-width', '2'); + this.curvePath.setAttribute('stroke-linecap', 'round'); + this.curvePath.classList.add('curve-path'); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add('tooltips'); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * (this.config.height / 2 * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints(dots: DotConfig[], index: number): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ''; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY(this.dots[0].value)}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints(this.dots, i); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', '0'); + line.setAttribute('y1', this.getDotY(value).toString()); + line.setAttribute('x2', this.config.totalWidth.toString()); + line.setAttribute('y2', this.getDotY(value).toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', '10'); + text.setAttribute('y', (this.getDotY(value) + 4).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil(this.config.totalWidth / this.config.xUnitSize); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', x.toString()); + line.setAttribute('y1', '0'); + line.setAttribute('x2', x.toString()); + line.setAttribute('y2', this.config.height.toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', x.toString()); + text.setAttribute('y', (this.config.height / 2 + 20).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.setAttribute('text-anchor', 'middle'); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + tooltip.classList.add('dot-tooltip'); + tooltip.setAttribute('data-dot-id', dot.id.toString()); + + // Calculate tooltip position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + + // Calculate tooltip Y position, ensuring it stays within the container + let tooltipY = y - tooltipHeight - 20; // Position above the dot with some spacing + + // Ensure tooltip doesn't go above the container + tooltipY = Math.max(tooltipY, 10); // Keep at least 10px from the top + + // Background rectangle + const bg = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); + bg.setAttribute('x', tooltipX.toString()); + bg.setAttribute('y', tooltipY.toString()); + bg.setAttribute('width', tooltipWidth.toString()); + bg.setAttribute('height', tooltipHeight.toString()); + bg.setAttribute('rx', '5'); + bg.setAttribute('ry', '5'); + bg.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(bg); + + // Tooltip arrow (pointing to the dot) + const arrow = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + arrow.setAttribute('d', `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${tooltipY + tooltipHeight - 10} L ${x + 10} ${tooltipY + tooltipHeight - 10} Z`); + arrow.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(arrow); + + // Image (if provided) + // Image (if provided) +if (dot.imageUrl) { + const imgContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + imgContainer.setAttribute('x', (tooltipX + 10).toString()); + imgContainer.setAttribute('y', (tooltipY + 10).toString()); + + // Set width and height to the same value for a square aspect + const imageSize = Math.min((tooltipWidth - 20), (tooltipHeight / 2)); + imgContainer.setAttribute('width', imageSize.toString()); + imgContainer.setAttribute('height', imageSize.toString()); + + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.className = 'tooltip-img'; + img.style.width = '100%'; + img.style.height = '100%'; + img.style.objectFit = 'cover'; // Ensure the image covers the space while maintaining aspect ratio + + imgContainer.appendChild(img); + tooltip.appendChild(imgContainer); +} + + + // Title (if provided) + if (dot.title) { + const title = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + title.setAttribute('x', (tooltipX + 10).toString()); + title.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 26).toString() + : (tooltipY + 25).toString()); + title.setAttribute('fill', 'white'); + title.setAttribute('font-size', '14'); + title.setAttribute('font-weight', 'bold'); + title.textContent = dot.title; + tooltip.appendChild(title); + } + + // Description (if provided) + if (dot.description) { + const descriptionFO = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + descriptionFO.setAttribute('x', (tooltipX + 10).toString()); + descriptionFO.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 32).toString() + : dot.title + ? (tooltipY + 35).toString() + : (tooltipY + 15).toString()); + descriptionFO.setAttribute('width', (tooltipWidth - 20).toString()); + descriptionFO.setAttribute('height', (tooltipHeight / 2 - 10).toString()); + + const descriptionDiv = document.createElement('div'); + descriptionDiv.style.color = 'white'; + descriptionDiv.style.fontSize = '12px'; + descriptionDiv.style.overflow = 'hidden'; + descriptionDiv.textContent = dot.description; + + descriptionFO.appendChild(descriptionDiv); + tooltip.appendChild(descriptionFO); + } + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute('d', pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); + circle.setAttribute('cx', x.toString()); + circle.setAttribute('cy', y.toString()); + circle.setAttribute('r', this.config.dotRadius.toString()); + circle.setAttribute('fill', 'white'); + circle.setAttribute('data-dot-id', dot.id.toString()); + circle.classList.add('dot'); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener('click', () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error('Dot has no link'); + throw new Error('Dot has no link'); + } + }); + } + + this.dotsGroup.appendChild(circle); + }; + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute('width', `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute('height', `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522091605.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522091605.ts new file mode 100644 index 0000000..96417a8 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522091605.ts @@ -0,0 +1,553 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor(containerId: string, dots: DotConfig[], config?: Partial) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + this.gridGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.curvePath = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + this.dotsGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.tooltipGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter(dot => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map(dot => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = {current: 0, total: imageUrls.length}; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log('All images preloaded successfully'); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + }; + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = 'connected-dots-styles'; + + if (!document.getElementById(styleId)) { + const style = document.createElement('style'); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute('width', `${this.config.totalWidth}`); + this.svg.setAttribute('height', `${this.config.height}`); + this.svg.style.overflow = 'visible'; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add('grid'); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute('fill', 'none'); + this.curvePath.setAttribute('stroke', 'white'); + this.curvePath.setAttribute('stroke-width', '2'); + this.curvePath.setAttribute('stroke-linecap', 'round'); + this.curvePath.classList.add('curve-path'); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add('tooltips'); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * (this.config.height / 2 * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints(dots: DotConfig[], index: number): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ''; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY(this.dots[0].value)}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints(this.dots, i); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', '0'); + line.setAttribute('y1', this.getDotY(value).toString()); + line.setAttribute('x2', this.config.totalWidth.toString()); + line.setAttribute('y2', this.getDotY(value).toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', '10'); + text.setAttribute('y', (this.getDotY(value) + 4).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil(this.config.totalWidth / this.config.xUnitSize); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', x.toString()); + line.setAttribute('y1', '0'); + line.setAttribute('x2', x.toString()); + line.setAttribute('y2', this.config.height.toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', x.toString()); + text.setAttribute('y', (this.config.height / 2 + 20).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.setAttribute('text-anchor', 'middle'); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + tooltip.classList.add('dot-tooltip'); + tooltip.setAttribute('data-dot-id', dot.id.toString()); + + // Calculate tooltip position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + + // Calculate tooltip Y position, ensuring it stays within the container + let tooltipY = y - tooltipHeight - 20; // Position above the dot with some spacing + + // Ensure tooltip doesn't go above the container + tooltipY = Math.max(tooltipY, 10); // Keep at least 10px from the top + + // Background rectangle + const bg = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); + bg.setAttribute('x', tooltipX.toString()); + bg.setAttribute('y', tooltipY.toString()); + bg.setAttribute('width', tooltipWidth.toString()); + bg.setAttribute('height', tooltipHeight.toString()); + bg.setAttribute('rx', '5'); + bg.setAttribute('ry', '5'); + bg.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(bg); + + // Tooltip arrow (pointing to the dot) + const arrow = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + arrow.setAttribute('d', `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${tooltipY + tooltipHeight - 10} L ${x + 10} ${tooltipY + tooltipHeight - 10} Z`); + arrow.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(arrow); + + // Image (if provided) + // Image (if provided) + if (dot.imageUrl) { + const imgContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + imgContainer.setAttribute('x', (tooltipX + 10).toString()); + imgContainer.setAttribute('y', (tooltipY + 10).toString()); + + // Set width and height to the same value for a square aspect + const imageSize = Math.min((tooltipWidth - 20), (tooltipHeight / 2)); + imgContainer.setAttribute('width', imageSize.toString()); + imgContainer.setAttribute('height', imageSize.toString()); + + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.className = 'tooltip-img'; + img.style.width = '100%'; + img.style.height = '100%'; + img.style.objectFit = 'cover'; // Ensure the image covers the space while maintaining aspect ratio + + imgContainer.appendChild(img); + tooltip.appendChild(imgContainer); + } + + + // Title (if provided) + if (dot.title) { + const title = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + title.setAttribute('x', (tooltipX + 10).toString()); + title.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 26).toString() + : (tooltipY + 25).toString()); + title.setAttribute('fill', 'white'); + title.setAttribute('font-size', '14'); + title.setAttribute('font-weight', 'bold'); + title.textContent = dot.title; + tooltip.appendChild(title); + } + + // Description (if provided) + if (dot.description) { + const descriptionFO = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + descriptionFO.setAttribute('x', (tooltipX + 10).toString()); + descriptionFO.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 32).toString() + : dot.title + ? (tooltipY + 35).toString() + : (tooltipY + 15).toString()); + descriptionFO.setAttribute('width', (tooltipWidth - 20).toString()); + descriptionFO.setAttribute('height', (tooltipHeight / 2 - 10).toString()); + + const descriptionDiv = document.createElement('div'); + descriptionDiv.style.color = 'white'; + descriptionDiv.style.fontSize = '12px'; + descriptionDiv.style.overflow = 'hidden'; + descriptionDiv.textContent = dot.description; + + descriptionFO.appendChild(descriptionDiv); + tooltip.appendChild(descriptionFO); + } + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute('d', pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); + circle.setAttribute('cx', x.toString()); + circle.setAttribute('cy', y.toString()); + circle.setAttribute('r', this.config.dotRadius.toString()); + circle.setAttribute('fill', 'white'); + circle.setAttribute('data-dot-id', dot.id.toString()); + circle.classList.add('dot'); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener('click', () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error('Dot has no link'); + throw new Error('Dot has no link'); + } + }); + } + + this.dotsGroup.appendChild(circle); + }; + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute('width', `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute('height', `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522091611.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522091611.ts new file mode 100644 index 0000000..92dfc80 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522091611.ts @@ -0,0 +1,551 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor(containerId: string, dots: DotConfig[], config?: Partial) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + this.gridGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.curvePath = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + this.dotsGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.tooltipGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter(dot => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map(dot => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = {current: 0, total: imageUrls.length}; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log('All images preloaded successfully'); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + }; + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = 'connected-dots-styles'; + + if (!document.getElementById(styleId)) { + const style = document.createElement('style'); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute('width', `${this.config.totalWidth}`); + this.svg.setAttribute('height', `${this.config.height}`); + this.svg.style.overflow = 'visible'; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add('grid'); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute('fill', 'none'); + this.curvePath.setAttribute('stroke', 'white'); + this.curvePath.setAttribute('stroke-width', '2'); + this.curvePath.setAttribute('stroke-linecap', 'round'); + this.curvePath.classList.add('curve-path'); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add('tooltips'); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * (this.config.height / 2 * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints(dots: DotConfig[], index: number): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ''; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY(this.dots[0].value)}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints(this.dots, i); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', '0'); + line.setAttribute('y1', this.getDotY(value).toString()); + line.setAttribute('x2', this.config.totalWidth.toString()); + line.setAttribute('y2', this.getDotY(value).toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', '10'); + text.setAttribute('y', (this.getDotY(value) + 4).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil(this.config.totalWidth / this.config.xUnitSize); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', x.toString()); + line.setAttribute('y1', '0'); + line.setAttribute('x2', x.toString()); + line.setAttribute('y2', this.config.height.toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', x.toString()); + text.setAttribute('y', (this.config.height / 2 + 20).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.setAttribute('text-anchor', 'middle'); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + tooltip.classList.add('dot-tooltip'); + tooltip.setAttribute('data-dot-id', dot.id.toString()); + + // Calculate tooltip position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + + // Calculate tooltip Y position, ensuring it stays within the container + let tooltipY = y - tooltipHeight - 20; // Position above the dot with some spacing + + // Ensure tooltip doesn't go above the container + tooltipY = Math.max(tooltipY, 10); // Keep at least 10px from the top + + // Background rectangle + const bg = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); + bg.setAttribute('x', tooltipX.toString()); + bg.setAttribute('y', tooltipY.toString()); + bg.setAttribute('width', tooltipWidth.toString()); + bg.setAttribute('height', tooltipHeight.toString()); + bg.setAttribute('rx', '5'); + bg.setAttribute('ry', '5'); + bg.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(bg); + + // Tooltip arrow (pointing to the dot) + const arrow = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + arrow.setAttribute('d', `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${tooltipY + tooltipHeight - 10} L ${x + 10} ${tooltipY + tooltipHeight - 10} Z`); + arrow.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(arrow); + + // Image (if provided) + if (dot.imageUrl) { + const imgContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + imgContainer.setAttribute('x', (tooltipX + 10).toString()); + imgContainer.setAttribute('y', (tooltipY + 10).toString()); + + // Set width and height to the same value for a square aspect + const imageSize = Math.min((tooltipWidth - 20), (tooltipHeight / 2)); + imgContainer.setAttribute('width', imageSize.toString()); + imgContainer.setAttribute('height', imageSize.toString()); + + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.className = 'tooltip-img'; + img.style.width = '100%'; + img.style.height = '100%'; + img.style.objectFit = 'cover'; // Ensure the image covers the space while maintaining aspect ratio + + imgContainer.appendChild(img); + tooltip.appendChild(imgContainer); + } + + // Title (if provided) + if (dot.title) { + const title = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + title.setAttribute('x', (tooltipX + 10).toString()); + title.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 26).toString() + : (tooltipY + 25).toString()); + title.setAttribute('fill', 'white'); + title.setAttribute('font-size', '14'); + title.setAttribute('font-weight', 'bold'); + title.textContent = dot.title; + tooltip.appendChild(title); + } + + // Description (if provided) + if (dot.description) { + const descriptionFO = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + descriptionFO.setAttribute('x', (tooltipX + 10).toString()); + descriptionFO.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 32).toString() + : dot.title + ? (tooltipY + 35).toString() + : (tooltipY + 15).toString()); + descriptionFO.setAttribute('width', (tooltipWidth - 20).toString()); + descriptionFO.setAttribute('height', (tooltipHeight / 2 - 10).toString()); + + const descriptionDiv = document.createElement('div'); + descriptionDiv.style.color = 'white'; + descriptionDiv.style.fontSize = '12px'; + descriptionDiv.style.overflow = 'hidden'; + descriptionDiv.textContent = dot.description; + + descriptionFO.appendChild(descriptionDiv); + tooltip.appendChild(descriptionFO); + } + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute('d', pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); + circle.setAttribute('cx', x.toString()); + circle.setAttribute('cy', y.toString()); + circle.setAttribute('r', this.config.dotRadius.toString()); + circle.setAttribute('fill', 'white'); + circle.setAttribute('data-dot-id', dot.id.toString()); + circle.classList.add('dot'); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener('click', () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error('Dot has no link'); + throw new Error('Dot has no link'); + } + }); + } + + this.dotsGroup.appendChild(circle); + }; + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute('width', `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute('height', `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522091723.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522091723.ts new file mode 100644 index 0000000..cc5d6e1 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522091723.ts @@ -0,0 +1,561 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor(containerId: string, dots: DotConfig[], config?: Partial) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + this.gridGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.curvePath = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + this.dotsGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.tooltipGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter(dot => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map(dot => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = {current: 0, total: imageUrls.length}; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log('All images preloaded successfully'); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + }; + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = 'connected-dots-styles'; + + if (!document.getElementById(styleId)) { + const style = document.createElement('style'); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute('width', `${this.config.totalWidth}`); + this.svg.setAttribute('height', `${this.config.height}`); + this.svg.style.overflow = 'visible'; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add('grid'); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute('fill', 'none'); + this.curvePath.setAttribute('stroke', 'white'); + this.curvePath.setAttribute('stroke-width', '2'); + this.curvePath.setAttribute('stroke-linecap', 'round'); + this.curvePath.classList.add('curve-path'); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add('tooltips'); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * (this.config.height / 2 * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints(dots: DotConfig[], index: number): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ''; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY(this.dots[0].value)}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints(this.dots, i); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', '0'); + line.setAttribute('y1', this.getDotY(value).toString()); + line.setAttribute('x2', this.config.totalWidth.toString()); + line.setAttribute('y2', this.getDotY(value).toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', '10'); + text.setAttribute('y', (this.getDotY(value) + 4).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil(this.config.totalWidth / this.config.xUnitSize); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', x.toString()); + line.setAttribute('y1', '0'); + line.setAttribute('x2', x.toString()); + line.setAttribute('y2', this.config.height.toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', x.toString()); + text.setAttribute('y', (this.config.height / 2 + 20).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.setAttribute('text-anchor', 'middle'); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + tooltip.classList.add('dot-tooltip'); + tooltip.setAttribute('data-dot-id', dot.id.toString()); + + // Calculate tooltip position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + + // Calculate tooltip Y position, ensuring it stays within the container + let tooltipY = y - tooltipHeight - 20; // Position above the dot with some spacing + + // Ensure tooltip doesn't go above the container + tooltipY = Math.max(tooltipY, 10); // Keep at least 10px from the top + + // Background rectangle + // Create a square background for the tooltip + const bg = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); + bg.setAttribute('x', tooltipX.toString()); + bg.setAttribute('y', tooltipY.toString()); + + // Make the width and height equal for a square shape + const squareSize = Math.min(tooltipWidth, tooltipHeight); + bg.setAttribute('width', squareSize.toString()); + bg.setAttribute('height', squareSize.toString()); + + // Optional: Adjust corner rounding if needed + bg.setAttribute('rx', '5'); // You can change this value for rounder corners + bg.setAttribute('ry', '5'); + + // Set the fill color to white + bg.setAttribute('fill', 'white'); + + tooltip.appendChild(bg); + + + // Tooltip arrow (pointing to the dot) + const arrow = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + arrow.setAttribute('d', `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${tooltipY + tooltipHeight - 10} L ${x + 10} ${tooltipY + tooltipHeight - 10} Z`); + arrow.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(arrow); + + // Image (if provided) + if (dot.imageUrl) { + const imgContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + imgContainer.setAttribute('x', (tooltipX + 10).toString()); + imgContainer.setAttribute('y', (tooltipY + 10).toString()); + + // Set width and height to the same value for a square aspect + const imageSize = Math.min((tooltipWidth - 20), (tooltipHeight / 2)); + imgContainer.setAttribute('width', imageSize.toString()); + imgContainer.setAttribute('height', imageSize.toString()); + + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.className = 'tooltip-img'; + img.style.width = '100%'; + img.style.height = '100%'; + img.style.objectFit = 'cover'; // Ensure the image covers the space while maintaining aspect ratio + + imgContainer.appendChild(img); + tooltip.appendChild(imgContainer); + } + + // Title (if provided) + if (dot.title) { + const title = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + title.setAttribute('x', (tooltipX + 10).toString()); + title.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 26).toString() + : (tooltipY + 25).toString()); + title.setAttribute('fill', 'white'); + title.setAttribute('font-size', '14'); + title.setAttribute('font-weight', 'bold'); + title.textContent = dot.title; + tooltip.appendChild(title); + } + + // Description (if provided) + if (dot.description) { + const descriptionFO = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + descriptionFO.setAttribute('x', (tooltipX + 10).toString()); + descriptionFO.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 32).toString() + : dot.title + ? (tooltipY + 35).toString() + : (tooltipY + 15).toString()); + descriptionFO.setAttribute('width', (tooltipWidth - 20).toString()); + descriptionFO.setAttribute('height', (tooltipHeight / 2 - 10).toString()); + + const descriptionDiv = document.createElement('div'); + descriptionDiv.style.color = 'white'; + descriptionDiv.style.fontSize = '12px'; + descriptionDiv.style.overflow = 'hidden'; + descriptionDiv.textContent = dot.description; + + descriptionFO.appendChild(descriptionDiv); + tooltip.appendChild(descriptionFO); + } + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute('d', pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); + circle.setAttribute('cx', x.toString()); + circle.setAttribute('cy', y.toString()); + circle.setAttribute('r', this.config.dotRadius.toString()); + circle.setAttribute('fill', 'white'); + circle.setAttribute('data-dot-id', dot.id.toString()); + circle.classList.add('dot'); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener('click', () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error('Dot has no link'); + throw new Error('Dot has no link'); + } + }); + } + + this.dotsGroup.appendChild(circle); + }; + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute('width', `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute('height', `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522091732.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522091732.ts new file mode 100644 index 0000000..1f2397f --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522091732.ts @@ -0,0 +1,561 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor(containerId: string, dots: DotConfig[], config?: Partial) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + this.gridGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.curvePath = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + this.dotsGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.tooltipGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter(dot => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map(dot => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = {current: 0, total: imageUrls.length}; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log('All images preloaded successfully'); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + }; + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = 'connected-dots-styles'; + + if (!document.getElementById(styleId)) { + const style = document.createElement('style'); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute('width', `${this.config.totalWidth}`); + this.svg.setAttribute('height', `${this.config.height}`); + this.svg.style.overflow = 'visible'; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add('grid'); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute('fill', 'none'); + this.curvePath.setAttribute('stroke', 'white'); + this.curvePath.setAttribute('stroke-width', '2'); + this.curvePath.setAttribute('stroke-linecap', 'round'); + this.curvePath.classList.add('curve-path'); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add('tooltips'); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * (this.config.height / 2 * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints(dots: DotConfig[], index: number): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ''; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY(this.dots[0].value)}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints(this.dots, i); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', '0'); + line.setAttribute('y1', this.getDotY(value).toString()); + line.setAttribute('x2', this.config.totalWidth.toString()); + line.setAttribute('y2', this.getDotY(value).toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', '10'); + text.setAttribute('y', (this.getDotY(value) + 4).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil(this.config.totalWidth / this.config.xUnitSize); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', x.toString()); + line.setAttribute('y1', '0'); + line.setAttribute('x2', x.toString()); + line.setAttribute('y2', this.config.height.toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', x.toString()); + text.setAttribute('y', (this.config.height / 2 + 20).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.setAttribute('text-anchor', 'middle'); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + tooltip.classList.add('dot-tooltip'); + tooltip.setAttribute('data-dot-id', dot.id.toString()); + + // Calculate tooltip position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + + // Calculate tooltip Y position, ensuring it stays within the container + let tooltipY = y - tooltipHeight - 20; // Position above the dot with some spacing + + // Ensure tooltip doesn't go above the container + tooltipY = Math.max(tooltipY, 10); // Keep at least 10px from the top + + // Background rectangle + // Create a square background for the tooltip + const bg = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); + bg.setAttribute('x', tooltipX.toString()); + bg.setAttribute('y', tooltipY.toString()); + + // Make the width and height equal for a square shape + const squareSize = Math.min(tooltipWidth, tooltipHeight); + bg.setAttribute('width', squareSize.toString()); + bg.setAttribute('height', squareSize.toString()); + + // Optional: Adjust corner rounding if needed + bg.setAttribute('rx', '2'); // You can change this value for rounder corners + bg.setAttribute('ry', '2'); + + // Set the fill color to white + bg.setAttribute('fill', 'white'); + + tooltip.appendChild(bg); + + + // Tooltip arrow (pointing to the dot) + const arrow = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + arrow.setAttribute('d', `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${tooltipY + tooltipHeight - 10} L ${x + 10} ${tooltipY + tooltipHeight - 10} Z`); + arrow.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(arrow); + + // Image (if provided) + if (dot.imageUrl) { + const imgContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + imgContainer.setAttribute('x', (tooltipX + 10).toString()); + imgContainer.setAttribute('y', (tooltipY + 10).toString()); + + // Set width and height to the same value for a square aspect + const imageSize = Math.min((tooltipWidth - 20), (tooltipHeight / 2)); + imgContainer.setAttribute('width', imageSize.toString()); + imgContainer.setAttribute('height', imageSize.toString()); + + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.className = 'tooltip-img'; + img.style.width = '100%'; + img.style.height = '100%'; + img.style.objectFit = 'cover'; // Ensure the image covers the space while maintaining aspect ratio + + imgContainer.appendChild(img); + tooltip.appendChild(imgContainer); + } + + // Title (if provided) + if (dot.title) { + const title = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + title.setAttribute('x', (tooltipX + 10).toString()); + title.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 26).toString() + : (tooltipY + 25).toString()); + title.setAttribute('fill', 'white'); + title.setAttribute('font-size', '14'); + title.setAttribute('font-weight', 'bold'); + title.textContent = dot.title; + tooltip.appendChild(title); + } + + // Description (if provided) + if (dot.description) { + const descriptionFO = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + descriptionFO.setAttribute('x', (tooltipX + 10).toString()); + descriptionFO.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 32).toString() + : dot.title + ? (tooltipY + 35).toString() + : (tooltipY + 15).toString()); + descriptionFO.setAttribute('width', (tooltipWidth - 20).toString()); + descriptionFO.setAttribute('height', (tooltipHeight / 2 - 10).toString()); + + const descriptionDiv = document.createElement('div'); + descriptionDiv.style.color = 'white'; + descriptionDiv.style.fontSize = '12px'; + descriptionDiv.style.overflow = 'hidden'; + descriptionDiv.textContent = dot.description; + + descriptionFO.appendChild(descriptionDiv); + tooltip.appendChild(descriptionFO); + } + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute('d', pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); + circle.setAttribute('cx', x.toString()); + circle.setAttribute('cy', y.toString()); + circle.setAttribute('r', this.config.dotRadius.toString()); + circle.setAttribute('fill', 'white'); + circle.setAttribute('data-dot-id', dot.id.toString()); + circle.classList.add('dot'); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener('click', () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error('Dot has no link'); + throw new Error('Dot has no link'); + } + }); + } + + this.dotsGroup.appendChild(circle); + }; + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute('width', `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute('height', `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522091747.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522091747.ts new file mode 100644 index 0000000..fe1a619 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522091747.ts @@ -0,0 +1,561 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor(containerId: string, dots: DotConfig[], config?: Partial) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + this.gridGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.curvePath = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + this.dotsGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.tooltipGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter(dot => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map(dot => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = {current: 0, total: imageUrls.length}; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log('All images preloaded successfully'); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + }; + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = 'connected-dots-styles'; + + if (!document.getElementById(styleId)) { + const style = document.createElement('style'); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute('width', `${this.config.totalWidth}`); + this.svg.setAttribute('height', `${this.config.height}`); + this.svg.style.overflow = 'visible'; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add('grid'); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute('fill', 'none'); + this.curvePath.setAttribute('stroke', 'white'); + this.curvePath.setAttribute('stroke-width', '2'); + this.curvePath.setAttribute('stroke-linecap', 'round'); + this.curvePath.classList.add('curve-path'); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add('tooltips'); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * (this.config.height / 2 * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints(dots: DotConfig[], index: number): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ''; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY(this.dots[0].value)}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints(this.dots, i); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', '0'); + line.setAttribute('y1', this.getDotY(value).toString()); + line.setAttribute('x2', this.config.totalWidth.toString()); + line.setAttribute('y2', this.getDotY(value).toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', '10'); + text.setAttribute('y', (this.getDotY(value) + 4).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil(this.config.totalWidth / this.config.xUnitSize); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', x.toString()); + line.setAttribute('y1', '0'); + line.setAttribute('x2', x.toString()); + line.setAttribute('y2', this.config.height.toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', x.toString()); + text.setAttribute('y', (this.config.height / 2 + 20).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.setAttribute('text-anchor', 'middle'); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + tooltip.classList.add('dot-tooltip'); + tooltip.setAttribute('data-dot-id', dot.id.toString()); + + // Calculate tooltip position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + + // Calculate tooltip Y position, ensuring it stays within the container + let tooltipY = y - tooltipHeight - 20; // Position above the dot with some spacing + + // Ensure tooltip doesn't go above the container + tooltipY = Math.max(tooltipY, 10); // Keep at least 10px from the top + + // Background rectangle + // Create a square background for the tooltip + const bg = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); + bg.setAttribute('x', tooltipX.toString()); + bg.setAttribute('y', tooltipY.toString()); + + // Make the width and height equal for a square shape + const squareSize = Math.min(tooltipWidth, tooltipHeight); + bg.setAttribute('width', squareSize.toString()); + bg.setAttribute('height', squareSize.toString()); + + // Optional: Adjust corner rounding if needed + bg.setAttribute('rx', '10'); // You can change this value for rounder corners + bg.setAttribute('ry', '10'); + + // Set the fill color to white + bg.setAttribute('fill', 'white'); + + tooltip.appendChild(bg); + + + // Tooltip arrow (pointing to the dot) + const arrow = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + arrow.setAttribute('d', `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${tooltipY + tooltipHeight - 10} L ${x + 10} ${tooltipY + tooltipHeight - 10} Z`); + arrow.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(arrow); + + // Image (if provided) + if (dot.imageUrl) { + const imgContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + imgContainer.setAttribute('x', (tooltipX + 10).toString()); + imgContainer.setAttribute('y', (tooltipY + 10).toString()); + + // Set width and height to the same value for a square aspect + const imageSize = Math.min((tooltipWidth - 20), (tooltipHeight / 2)); + imgContainer.setAttribute('width', imageSize.toString()); + imgContainer.setAttribute('height', imageSize.toString()); + + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.className = 'tooltip-img'; + img.style.width = '100%'; + img.style.height = '100%'; + img.style.objectFit = 'cover'; // Ensure the image covers the space while maintaining aspect ratio + + imgContainer.appendChild(img); + tooltip.appendChild(imgContainer); + } + + // Title (if provided) + if (dot.title) { + const title = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + title.setAttribute('x', (tooltipX + 10).toString()); + title.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 26).toString() + : (tooltipY + 25).toString()); + title.setAttribute('fill', 'white'); + title.setAttribute('font-size', '14'); + title.setAttribute('font-weight', 'bold'); + title.textContent = dot.title; + tooltip.appendChild(title); + } + + // Description (if provided) + if (dot.description) { + const descriptionFO = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + descriptionFO.setAttribute('x', (tooltipX + 10).toString()); + descriptionFO.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 32).toString() + : dot.title + ? (tooltipY + 35).toString() + : (tooltipY + 15).toString()); + descriptionFO.setAttribute('width', (tooltipWidth - 20).toString()); + descriptionFO.setAttribute('height', (tooltipHeight / 2 - 10).toString()); + + const descriptionDiv = document.createElement('div'); + descriptionDiv.style.color = 'white'; + descriptionDiv.style.fontSize = '12px'; + descriptionDiv.style.overflow = 'hidden'; + descriptionDiv.textContent = dot.description; + + descriptionFO.appendChild(descriptionDiv); + tooltip.appendChild(descriptionFO); + } + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute('d', pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); + circle.setAttribute('cx', x.toString()); + circle.setAttribute('cy', y.toString()); + circle.setAttribute('r', this.config.dotRadius.toString()); + circle.setAttribute('fill', 'white'); + circle.setAttribute('data-dot-id', dot.id.toString()); + circle.classList.add('dot'); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener('click', () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error('Dot has no link'); + throw new Error('Dot has no link'); + } + }); + } + + this.dotsGroup.appendChild(circle); + }; + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute('width', `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute('height', `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522091858.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522091858.ts new file mode 100644 index 0000000..3dde4dc --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522091858.ts @@ -0,0 +1,565 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor(containerId: string, dots: DotConfig[], config?: Partial) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + this.gridGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.curvePath = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + this.dotsGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.tooltipGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter(dot => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map(dot => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = {current: 0, total: imageUrls.length}; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log('All images preloaded successfully'); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + }; + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = 'connected-dots-styles'; + + if (!document.getElementById(styleId)) { + const style = document.createElement('style'); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute('width', `${this.config.totalWidth}`); + this.svg.setAttribute('height', `${this.config.height}`); + this.svg.style.overflow = 'visible'; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add('grid'); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute('fill', 'none'); + this.curvePath.setAttribute('stroke', 'white'); + this.curvePath.setAttribute('stroke-width', '2'); + this.curvePath.setAttribute('stroke-linecap', 'round'); + this.curvePath.classList.add('curve-path'); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add('tooltips'); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * (this.config.height / 2 * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints(dots: DotConfig[], index: number): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ''; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY(this.dots[0].value)}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints(this.dots, i); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', '0'); + line.setAttribute('y1', this.getDotY(value).toString()); + line.setAttribute('x2', this.config.totalWidth.toString()); + line.setAttribute('y2', this.getDotY(value).toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', '10'); + text.setAttribute('y', (this.getDotY(value) + 4).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil(this.config.totalWidth / this.config.xUnitSize); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', x.toString()); + line.setAttribute('y1', '0'); + line.setAttribute('x2', x.toString()); + line.setAttribute('y2', this.config.height.toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', x.toString()); + text.setAttribute('y', (this.config.height / 2 + 20).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.setAttribute('text-anchor', 'middle'); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + tooltip.classList.add('dot-tooltip'); + tooltip.setAttribute('data-dot-id', dot.id.toString()); + + // Calculate tooltip position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + + // Calculate tooltip Y position, ensuring it stays within the container + let tooltipY = y - tooltipHeight - 20; // Position above the dot with some spacing + + // Ensure tooltip doesn't go above the container + tooltipY = Math.max(tooltipY, 10); // Keep at least 10px from the top + + // Background rectangle + // Create a rectangle for the tooltip with a 9:16 aspect ratio + const bg = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); + bg.setAttribute('x', tooltipX.toString()); + bg.setAttribute('y', tooltipY.toString()); + + // Calculate width and height based on ratio + const height = tooltipHeight; + const width = (9 / 16) * height; + + // Set the width and height for a 9:16 aspect ratio + bg.setAttribute('width', width.toString()); + bg.setAttribute('height', height.toString()); + + // Remove any background fill + bg.setAttribute('fill', 'none'); + + // Optional: Adjust corner rounding if needed + bg.setAttribute('rx', '5'); // You can set this to 0 for sharp corners + bg.setAttribute('ry', '5'); + + tooltip.appendChild(bg); + + + + // Tooltip arrow (pointing to the dot) + const arrow = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + arrow.setAttribute('d', `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${tooltipY + tooltipHeight - 10} L ${x + 10} ${tooltipY + tooltipHeight - 10} Z`); + arrow.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(arrow); + + // Image (if provided) + if (dot.imageUrl) { + const imgContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + imgContainer.setAttribute('x', (tooltipX + 10).toString()); + imgContainer.setAttribute('y', (tooltipY + 10).toString()); + + // Set width and height to the same value for a square aspect + const imageSize = Math.min((tooltipWidth - 20), (tooltipHeight / 2)); + imgContainer.setAttribute('width', imageSize.toString()); + imgContainer.setAttribute('height', imageSize.toString()); + + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.className = 'tooltip-img'; + img.style.width = '100%'; + img.style.height = '100%'; + img.style.objectFit = 'cover'; // Ensure the image covers the space while maintaining aspect ratio + + imgContainer.appendChild(img); + tooltip.appendChild(imgContainer); + } + + // Title (if provided) + if (dot.title) { + const title = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + title.setAttribute('x', (tooltipX + 10).toString()); + title.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 26).toString() + : (tooltipY + 25).toString()); + title.setAttribute('fill', 'white'); + title.setAttribute('font-size', '14'); + title.setAttribute('font-weight', 'bold'); + title.textContent = dot.title; + tooltip.appendChild(title); + } + + // Description (if provided) + if (dot.description) { + const descriptionFO = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + descriptionFO.setAttribute('x', (tooltipX + 10).toString()); + descriptionFO.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 32).toString() + : dot.title + ? (tooltipY + 35).toString() + : (tooltipY + 15).toString()); + descriptionFO.setAttribute('width', (tooltipWidth - 20).toString()); + descriptionFO.setAttribute('height', (tooltipHeight / 2 - 10).toString()); + + const descriptionDiv = document.createElement('div'); + descriptionDiv.style.color = 'white'; + descriptionDiv.style.fontSize = '12px'; + descriptionDiv.style.overflow = 'hidden'; + descriptionDiv.textContent = dot.description; + + descriptionFO.appendChild(descriptionDiv); + tooltip.appendChild(descriptionFO); + } + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute('d', pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); + circle.setAttribute('cx', x.toString()); + circle.setAttribute('cy', y.toString()); + circle.setAttribute('r', this.config.dotRadius.toString()); + circle.setAttribute('fill', 'white'); + circle.setAttribute('data-dot-id', dot.id.toString()); + circle.classList.add('dot'); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener('click', () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error('Dot has no link'); + throw new Error('Dot has no link'); + } + }); + } + + this.dotsGroup.appendChild(circle); + }; + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute('width', `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute('height', `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522091957.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522091957.ts new file mode 100644 index 0000000..8ab4815 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522091957.ts @@ -0,0 +1,570 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor(containerId: string, dots: DotConfig[], config?: Partial) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + this.gridGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.curvePath = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + this.dotsGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.tooltipGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter(dot => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map(dot => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = {current: 0, total: imageUrls.length}; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log('All images preloaded successfully'); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + }; + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = 'connected-dots-styles'; + + if (!document.getElementById(styleId)) { + const style = document.createElement('style'); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute('width', `${this.config.totalWidth}`); + this.svg.setAttribute('height', `${this.config.height}`); + this.svg.style.overflow = 'visible'; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add('grid'); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute('fill', 'none'); + this.curvePath.setAttribute('stroke', 'white'); + this.curvePath.setAttribute('stroke-width', '2'); + this.curvePath.setAttribute('stroke-linecap', 'round'); + this.curvePath.classList.add('curve-path'); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add('tooltips'); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * (this.config.height / 2 * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints(dots: DotConfig[], index: number): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ''; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY(this.dots[0].value)}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints(this.dots, i); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', '0'); + line.setAttribute('y1', this.getDotY(value).toString()); + line.setAttribute('x2', this.config.totalWidth.toString()); + line.setAttribute('y2', this.getDotY(value).toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', '10'); + text.setAttribute('y', (this.getDotY(value) + 4).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil(this.config.totalWidth / this.config.xUnitSize); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', x.toString()); + line.setAttribute('y1', '0'); + line.setAttribute('x2', x.toString()); + line.setAttribute('y2', this.config.height.toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', x.toString()); + text.setAttribute('y', (this.config.height / 2 + 20).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.setAttribute('text-anchor', 'middle'); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + tooltip.classList.add('dot-tooltip'); + tooltip.setAttribute('data-dot-id', dot.id.toString()); + + // Calculate tooltip position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + + // Calculate tooltip Y position, ensuring it stays within the container + let tooltipY = y - tooltipHeight - 20; // Position above the dot with some spacing + + // Ensure tooltip doesn't go above the container + tooltipY = Math.max(tooltipY, 10); // Keep at least 10px from the top + + // Background rectangle + // Create a rectangle for the tooltip with a 9:16 aspect ratio + const bg = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); + bg.setAttribute('x', tooltipX.toString()); + bg.setAttribute('y', tooltipY.toString()); + + // Calculate width and height based on ratio + const height = tooltipHeight; + const width = (9 / 16) * height; + + // Set the width and height for a 9:16 aspect ratio + bg.setAttribute('width', width.toString()); + bg.setAttribute('height', height.toString()); + + // Remove any background fill + bg.setAttribute('fill', 'none'); + + // Optional: Adjust corner rounding if needed + bg.setAttribute('rx', '5'); // You can set this to 0 for sharp corners + bg.setAttribute('ry', '5'); + + tooltip.appendChild(bg); + + + + // Tooltip arrow (pointing to the dot) + const arrow = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + arrow.setAttribute('d', `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${tooltipY + tooltipHeight - 10} L ${x + 10} ${tooltipY + tooltipHeight - 10} Z`); + arrow.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(arrow); + + // Image (if provided) + if (dot.imageUrl) { + const imgContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + imgContainer.setAttribute('x', (tooltipX + 10).toString()); + imgContainer.setAttribute('y', (tooltipY + 10).toString()); + + // Set width and height to the same value for a square aspect ratio + const imageSize = Math.min((tooltipWidth - 20), (tooltipHeight / 2)); + imgContainer.setAttribute('width', imageSize.toString()); + imgContainer.setAttribute('height', imageSize.toString()); + + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.className = 'tooltip-img'; + img.style.width = '100%'; + img.style.height = '100%'; + img.style.objectFit = 'cover'; // Ensure the image covers the space while maintaining aspect ratio + + // Make the image circular and add a white border + img.style.borderRadius = '50%'; // Makes the image round + img.style.border = '1px solid white'; // Adds a 1px white border around the image + + imgContainer.appendChild(img); + tooltip.appendChild(imgContainer); + } + + + // Title (if provided) + if (dot.title) { + const title = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + title.setAttribute('x', (tooltipX + 10).toString()); + title.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 26).toString() + : (tooltipY + 25).toString()); + title.setAttribute('fill', 'white'); + title.setAttribute('font-size', '14'); + title.setAttribute('font-weight', 'bold'); + title.textContent = dot.title; + tooltip.appendChild(title); + } + + // Description (if provided) + if (dot.description) { + const descriptionFO = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + descriptionFO.setAttribute('x', (tooltipX + 10).toString()); + descriptionFO.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 32).toString() + : dot.title + ? (tooltipY + 35).toString() + : (tooltipY + 15).toString()); + descriptionFO.setAttribute('width', (tooltipWidth - 20).toString()); + descriptionFO.setAttribute('height', (tooltipHeight / 2 - 10).toString()); + + const descriptionDiv = document.createElement('div'); + descriptionDiv.style.color = 'white'; + descriptionDiv.style.fontSize = '12px'; + descriptionDiv.style.overflow = 'hidden'; + descriptionDiv.textContent = dot.description; + + descriptionFO.appendChild(descriptionDiv); + tooltip.appendChild(descriptionFO); + } + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute('d', pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); + circle.setAttribute('cx', x.toString()); + circle.setAttribute('cy', y.toString()); + circle.setAttribute('r', this.config.dotRadius.toString()); + circle.setAttribute('fill', 'white'); + circle.setAttribute('data-dot-id', dot.id.toString()); + circle.classList.add('dot'); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener('click', () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error('Dot has no link'); + throw new Error('Dot has no link'); + } + }); + } + + this.dotsGroup.appendChild(circle); + }; + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute('width', `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute('height', `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522092004.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522092004.ts new file mode 100644 index 0000000..c8fde55 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522092004.ts @@ -0,0 +1,570 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor(containerId: string, dots: DotConfig[], config?: Partial) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + this.gridGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.curvePath = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + this.dotsGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.tooltipGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter(dot => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map(dot => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = {current: 0, total: imageUrls.length}; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log('All images preloaded successfully'); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + }; + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = 'connected-dots-styles'; + + if (!document.getElementById(styleId)) { + const style = document.createElement('style'); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute('width', `${this.config.totalWidth}`); + this.svg.setAttribute('height', `${this.config.height}`); + this.svg.style.overflow = 'visible'; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add('grid'); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute('fill', 'none'); + this.curvePath.setAttribute('stroke', 'white'); + this.curvePath.setAttribute('stroke-width', '2'); + this.curvePath.setAttribute('stroke-linecap', 'round'); + this.curvePath.classList.add('curve-path'); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add('tooltips'); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * (this.config.height / 2 * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints(dots: DotConfig[], index: number): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ''; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY(this.dots[0].value)}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints(this.dots, i); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', '0'); + line.setAttribute('y1', this.getDotY(value).toString()); + line.setAttribute('x2', this.config.totalWidth.toString()); + line.setAttribute('y2', this.getDotY(value).toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', '10'); + text.setAttribute('y', (this.getDotY(value) + 4).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil(this.config.totalWidth / this.config.xUnitSize); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', x.toString()); + line.setAttribute('y1', '0'); + line.setAttribute('x2', x.toString()); + line.setAttribute('y2', this.config.height.toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', x.toString()); + text.setAttribute('y', (this.config.height / 2 + 20).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.setAttribute('text-anchor', 'middle'); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + tooltip.classList.add('dot-tooltip'); + tooltip.setAttribute('data-dot-id', dot.id.toString()); + + // Calculate tooltip position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + + // Calculate tooltip Y position, ensuring it stays within the container + let tooltipY = y - tooltipHeight - 20; // Position above the dot with some spacing + + // Ensure tooltip doesn't go above the container + tooltipY = Math.max(tooltipY, 10); // Keep at least 10px from the top + + // Background rectangle + // Create a rectangle for the tooltip with a 9:16 aspect ratio + const bg = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); + bg.setAttribute('x', tooltipX.toString()); + bg.setAttribute('y', tooltipY.toString()); + + // Calculate width and height based on ratio + const height = tooltipHeight; + const width = (9 / 16) * height; + + // Set the width and height for a 9:16 aspect ratio + bg.setAttribute('width', width.toString()); + bg.setAttribute('height', height.toString()); + + // Remove any background fill + bg.setAttribute('fill', 'none'); + + // Optional: Adjust corner rounding if needed + bg.setAttribute('rx', '5'); // You can set this to 0 for sharp corners + bg.setAttribute('ry', '5'); + + tooltip.appendChild(bg); + + + + // Tooltip arrow (pointing to the dot) + const arrow = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + arrow.setAttribute('d', `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${tooltipY + tooltipHeight - 10} L ${x + 10} ${tooltipY + tooltipHeight - 10} Z`); + arrow.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(arrow); + + // Image (if provided) + if (dot.imageUrl) { + const imgContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + imgContainer.setAttribute('x', (tooltipX + 10).toString()); + imgContainer.setAttribute('y', (tooltipY + 10).toString()); + + // Set width and height to the same value for a square aspect ratio + const imageSize = Math.min((tooltipWidth - 20), (tooltipHeight / 2)); + imgContainer.setAttribute('width', imageSize.toString()); + imgContainer.setAttribute('height', imageSize.toString()); + + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.className = 'tooltip-img'; + img.style.width = '100%'; + img.style.height = '100%'; + img.style.objectFit = 'cover'; // Ensure the image covers the space while maintaining aspect ratio + + // Make the image circular and add a white border + img.style.borderRadius = '50%'; // Makes the image round + img.style.border = '2px solid white'; // Adds a 1px white border around the image + + imgContainer.appendChild(img); + tooltip.appendChild(imgContainer); + } + + + // Title (if provided) + if (dot.title) { + const title = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + title.setAttribute('x', (tooltipX + 10).toString()); + title.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 26).toString() + : (tooltipY + 25).toString()); + title.setAttribute('fill', 'white'); + title.setAttribute('font-size', '14'); + title.setAttribute('font-weight', 'bold'); + title.textContent = dot.title; + tooltip.appendChild(title); + } + + // Description (if provided) + if (dot.description) { + const descriptionFO = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + descriptionFO.setAttribute('x', (tooltipX + 10).toString()); + descriptionFO.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 32).toString() + : dot.title + ? (tooltipY + 35).toString() + : (tooltipY + 15).toString()); + descriptionFO.setAttribute('width', (tooltipWidth - 20).toString()); + descriptionFO.setAttribute('height', (tooltipHeight / 2 - 10).toString()); + + const descriptionDiv = document.createElement('div'); + descriptionDiv.style.color = 'white'; + descriptionDiv.style.fontSize = '12px'; + descriptionDiv.style.overflow = 'hidden'; + descriptionDiv.textContent = dot.description; + + descriptionFO.appendChild(descriptionDiv); + tooltip.appendChild(descriptionFO); + } + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute('d', pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); + circle.setAttribute('cx', x.toString()); + circle.setAttribute('cy', y.toString()); + circle.setAttribute('r', this.config.dotRadius.toString()); + circle.setAttribute('fill', 'white'); + circle.setAttribute('data-dot-id', dot.id.toString()); + circle.classList.add('dot'); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener('click', () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error('Dot has no link'); + throw new Error('Dot has no link'); + } + }); + } + + this.dotsGroup.appendChild(circle); + }; + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute('width', `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute('height', `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522092036.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522092036.ts new file mode 100644 index 0000000..72817cb --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522092036.ts @@ -0,0 +1,570 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor(containerId: string, dots: DotConfig[], config?: Partial) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + this.gridGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.curvePath = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + this.dotsGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.tooltipGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter(dot => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map(dot => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = {current: 0, total: imageUrls.length}; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log('All images preloaded successfully'); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + }; + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = 'connected-dots-styles'; + + if (!document.getElementById(styleId)) { + const style = document.createElement('style'); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute('width', `${this.config.totalWidth}`); + this.svg.setAttribute('height', `${this.config.height}`); + this.svg.style.overflow = 'visible'; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add('grid'); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute('fill', 'none'); + this.curvePath.setAttribute('stroke', 'white'); + this.curvePath.setAttribute('stroke-width', '2'); + this.curvePath.setAttribute('stroke-linecap', 'round'); + this.curvePath.classList.add('curve-path'); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add('tooltips'); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * (this.config.height / 2 * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints(dots: DotConfig[], index: number): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ''; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY(this.dots[0].value)}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints(this.dots, i); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', '0'); + line.setAttribute('y1', this.getDotY(value).toString()); + line.setAttribute('x2', this.config.totalWidth.toString()); + line.setAttribute('y2', this.getDotY(value).toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', '10'); + text.setAttribute('y', (this.getDotY(value) + 4).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil(this.config.totalWidth / this.config.xUnitSize); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', x.toString()); + line.setAttribute('y1', '0'); + line.setAttribute('x2', x.toString()); + line.setAttribute('y2', this.config.height.toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', x.toString()); + text.setAttribute('y', (this.config.height / 2 + 20).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.setAttribute('text-anchor', 'middle'); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + tooltip.classList.add('dot-tooltip'); + tooltip.setAttribute('data-dot-id', dot.id.toString()); + + // Calculate tooltip position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + + // Calculate tooltip Y position, ensuring it stays within the container + let tooltipY = y - tooltipHeight - 20; // Position above the dot with some spacing + + // Ensure tooltip doesn't go above the container + tooltipY = Math.max(tooltipY, 10); // Keep at least 10px from the top + + // Background rectangle + // Create a rectangle for the tooltip with a 9:16 aspect ratio + const bg = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); + bg.setAttribute('x', tooltipX.toString()); + bg.setAttribute('y', tooltipY.toString()); + + // Calculate width and height based on ratio + const height = tooltipHeight; + const width = (9 / 16) * height; + + // Set the width and height for a 9:16 aspect ratio + bg.setAttribute('width', width.toString()); + bg.setAttribute('height', height.toString()); + + // Remove any background fill + bg.setAttribute('fill', 'none'); + + // Optional: Adjust corner rounding if needed + bg.setAttribute('rx', '5'); // You can set this to 0 for sharp corners + bg.setAttribute('ry', '5'); + + tooltip.appendChild(bg); + + + + // Tooltip arrow (pointing to the dot) + const arrow = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + arrow.setAttribute('d', `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${tooltipY + tooltipHeight - 10} L ${x + 10} ${tooltipY + tooltipHeight - 10} Z`); + arrow.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(arrow); + + // Image (if provided) + if (dot.imageUrl) { + const imgContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + imgContainer.setAttribute('x', (tooltipX + 10).toString()); + imgContainer.setAttribute('y', (tooltipY + 10).toString()); + + // Set width and height to the same value for a square aspect ratio + const imageSize = Math.min((tooltipWidth - 20), (tooltipHeight / 2)); + imgContainer.setAttribute('width', imageSize.toString()); + imgContainer.setAttribute('height', imageSize.toString()); + + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.className = 'tooltip-img'; + img.style.width = '100%'; + img.style.height = 'calc(100% - 4px)'; + img.style.objectFit = 'cover'; // Ensure the image covers the space while maintaining aspect ratio + + // Make the image circular and add a white border + img.style.borderRadius = '50%'; // Makes the image round + img.style.border = '2px solid white'; // Adds a 1px white border around the image + + imgContainer.appendChild(img); + tooltip.appendChild(imgContainer); + } + + + // Title (if provided) + if (dot.title) { + const title = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + title.setAttribute('x', (tooltipX + 10).toString()); + title.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 26).toString() + : (tooltipY + 25).toString()); + title.setAttribute('fill', 'white'); + title.setAttribute('font-size', '14'); + title.setAttribute('font-weight', 'bold'); + title.textContent = dot.title; + tooltip.appendChild(title); + } + + // Description (if provided) + if (dot.description) { + const descriptionFO = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + descriptionFO.setAttribute('x', (tooltipX + 10).toString()); + descriptionFO.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 32).toString() + : dot.title + ? (tooltipY + 35).toString() + : (tooltipY + 15).toString()); + descriptionFO.setAttribute('width', (tooltipWidth - 20).toString()); + descriptionFO.setAttribute('height', (tooltipHeight / 2 - 10).toString()); + + const descriptionDiv = document.createElement('div'); + descriptionDiv.style.color = 'white'; + descriptionDiv.style.fontSize = '12px'; + descriptionDiv.style.overflow = 'hidden'; + descriptionDiv.textContent = dot.description; + + descriptionFO.appendChild(descriptionDiv); + tooltip.appendChild(descriptionFO); + } + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute('d', pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); + circle.setAttribute('cx', x.toString()); + circle.setAttribute('cy', y.toString()); + circle.setAttribute('r', this.config.dotRadius.toString()); + circle.setAttribute('fill', 'white'); + circle.setAttribute('data-dot-id', dot.id.toString()); + circle.classList.add('dot'); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener('click', () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error('Dot has no link'); + throw new Error('Dot has no link'); + } + }); + } + + this.dotsGroup.appendChild(circle); + }; + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute('width', `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute('height', `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522092041.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522092041.ts new file mode 100644 index 0000000..11e1464 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522092041.ts @@ -0,0 +1,570 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor(containerId: string, dots: DotConfig[], config?: Partial) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + this.gridGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.curvePath = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + this.dotsGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + this.tooltipGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter(dot => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map(dot => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = {current: 0, total: imageUrls.length}; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log('All images preloaded successfully'); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + }; + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = 'connected-dots-styles'; + + if (!document.getElementById(styleId)) { + const style = document.createElement('style'); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute('width', `${this.config.totalWidth}`); + this.svg.setAttribute('height', `${this.config.height}`); + this.svg.style.overflow = 'visible'; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add('grid'); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute('fill', 'none'); + this.curvePath.setAttribute('stroke', 'white'); + this.curvePath.setAttribute('stroke-width', '2'); + this.curvePath.setAttribute('stroke-linecap', 'round'); + this.curvePath.classList.add('curve-path'); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add('tooltips'); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * (this.config.height / 2 * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints(dots: DotConfig[], index: number): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ''; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY(this.dots[0].value)}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints(this.dots, i); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', '0'); + line.setAttribute('y1', this.getDotY(value).toString()); + line.setAttribute('x2', this.config.totalWidth.toString()); + line.setAttribute('y2', this.getDotY(value).toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', '10'); + text.setAttribute('y', (this.getDotY(value) + 4).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil(this.config.totalWidth / this.config.xUnitSize); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + line.setAttribute('x1', x.toString()); + line.setAttribute('y1', '0'); + line.setAttribute('x2', x.toString()); + line.setAttribute('y2', this.config.height.toString()); + line.setAttribute('stroke', 'rgba(219, 39, 119, 0.4)'); + line.setAttribute('stroke-width', '1'); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + text.setAttribute('x', x.toString()); + text.setAttribute('y', (this.config.height / 2 + 20).toString()); + text.setAttribute('fill', 'rgba(219, 39, 119, 0.8)'); + text.setAttribute('font-size', '12'); + text.setAttribute('text-anchor', 'middle'); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + tooltip.classList.add('dot-tooltip'); + tooltip.setAttribute('data-dot-id', dot.id.toString()); + + // Calculate tooltip position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + + // Calculate tooltip Y position, ensuring it stays within the container + let tooltipY = y - tooltipHeight - 20; // Position above the dot with some spacing + + // Ensure tooltip doesn't go above the container + tooltipY = Math.max(tooltipY, 10); // Keep at least 10px from the top + + // Background rectangle + // Create a rectangle for the tooltip with a 9:16 aspect ratio + const bg = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); + bg.setAttribute('x', tooltipX.toString()); + bg.setAttribute('y', tooltipY.toString()); + + // Calculate width and height based on ratio + const height = tooltipHeight; + const width = (9 / 16) * height; + + // Set the width and height for a 9:16 aspect ratio + bg.setAttribute('width', width.toString()); + bg.setAttribute('height', height.toString()); + + // Remove any background fill + bg.setAttribute('fill', 'none'); + + // Optional: Adjust corner rounding if needed + bg.setAttribute('rx', '5'); // You can set this to 0 for sharp corners + bg.setAttribute('ry', '5'); + + tooltip.appendChild(bg); + + + + // Tooltip arrow (pointing to the dot) + const arrow = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + arrow.setAttribute('d', `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${tooltipY + tooltipHeight - 10} L ${x + 10} ${tooltipY + tooltipHeight - 10} Z`); + arrow.setAttribute('fill', 'rgba(0, 0, 0, 0.8)'); + tooltip.appendChild(arrow); + + // Image (if provided) + if (dot.imageUrl) { + const imgContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + imgContainer.setAttribute('x', (tooltipX + 10).toString()); + imgContainer.setAttribute('y', (tooltipY + 10).toString()); + + // Set width and height to the same value for a square aspect ratio + const imageSize = Math.min((tooltipWidth - 20), (tooltipHeight / 2)); + imgContainer.setAttribute('width', imageSize.toString()); + imgContainer.setAttribute('height', imageSize.toString()); + + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.className = 'tooltip-img'; + img.style.width = 'calc(100% - 4px)'; + img.style.height = 'calc(100% - 4px)'; + img.style.objectFit = 'cover'; // Ensure the image covers the space while maintaining aspect ratio + + // Make the image circular and add a white border + img.style.borderRadius = '50%'; // Makes the image round + img.style.border = '2px solid white'; // Adds a 1px white border around the image + + imgContainer.appendChild(img); + tooltip.appendChild(imgContainer); + } + + + // Title (if provided) + if (dot.title) { + const title = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + title.setAttribute('x', (tooltipX + 10).toString()); + title.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 26).toString() + : (tooltipY + 25).toString()); + title.setAttribute('fill', 'white'); + title.setAttribute('font-size', '14'); + title.setAttribute('font-weight', 'bold'); + title.textContent = dot.title; + tooltip.appendChild(title); + } + + // Description (if provided) + if (dot.description) { + const descriptionFO = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + descriptionFO.setAttribute('x', (tooltipX + 10).toString()); + descriptionFO.setAttribute('y', dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 32).toString() + : dot.title + ? (tooltipY + 35).toString() + : (tooltipY + 15).toString()); + descriptionFO.setAttribute('width', (tooltipWidth - 20).toString()); + descriptionFO.setAttribute('height', (tooltipHeight / 2 - 10).toString()); + + const descriptionDiv = document.createElement('div'); + descriptionDiv.style.color = 'white'; + descriptionDiv.style.fontSize = '12px'; + descriptionDiv.style.overflow = 'hidden'; + descriptionDiv.textContent = dot.description; + + descriptionFO.appendChild(descriptionDiv); + tooltip.appendChild(descriptionFO); + } + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute('d', pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); + circle.setAttribute('cx', x.toString()); + circle.setAttribute('cy', y.toString()); + circle.setAttribute('r', this.config.dotRadius.toString()); + circle.setAttribute('fill', 'white'); + circle.setAttribute('data-dot-id', dot.id.toString()); + circle.classList.add('dot'); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener('click', () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error('Dot has no link'); + throw new Error('Dot has no link'); + } + }); + } + + this.dotsGroup.appendChild(circle); + }; + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute('width', `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map(dot => dot.x)); + const maxX = Math.max(...this.dots.map(dot => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute('height', `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522092303.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522092303.ts new file mode 100644 index 0000000..17e85ce --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522092303.ts @@ -0,0 +1,631 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + + // Calculate tooltip Y position, ensuring it stays within the container + let tooltipY = y - tooltipHeight - 20; // Position above the dot with some spacing + + // Ensure tooltip doesn't go above the container + tooltipY = Math.max(tooltipY, 10); // Keep at least 10px from the top + + // Background rectangle + // Create a rectangle for the tooltip with a 9:16 aspect ratio + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + + // Calculate width and height based on ratio + const height = tooltipHeight; + const width = (9 / 16) * height; + + // Set the width and height for a 9:16 aspect ratio + bg.setAttribute("width", width.toString()); + bg.setAttribute("height", height.toString()); + + // Remove any background fill + bg.setAttribute("fill", "none"); + + // Optional: Adjust corner rounding if needed + bg.setAttribute("rx", "5"); // You can set this to 0 for sharp corners + bg.setAttribute("ry", "5"); + + tooltip.appendChild(bg); + + // Tooltip arrow (pointing to the dot) + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.setAttribute("fill", "rgba(0, 0, 0, 0.8)"); + tooltip.appendChild(arrow); + + // Image (if provided) + if (dot.imageUrl) { + const imgContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + imgContainer.setAttribute("x", (tooltipX + 10).toString()); + imgContainer.setAttribute("y", (tooltipY + 10).toString()); + + // Set width and height to the same value for a square aspect ratio + const imageSize = Math.min(tooltipWidth - 20, tooltipHeight / 2); + imgContainer.setAttribute("width", imageSize.toString()); + imgContainer.setAttribute("height", imageSize.toString()); + + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.className = "tooltip-img"; + img.style.width = "calc(100% - 4px)"; + img.style.height = "calc(100% - 4px)"; + img.style.objectFit = "cover"; // Ensure the image covers the space while maintaining aspect ratio + + // Make the image circular and add a white border + img.style.borderRadius = "50%"; // Makes the image round + img.style.border = "2px solid white"; // Adds a 1px white border around the image + + imgContainer.appendChild(img); + tooltip.appendChild(imgContainer); + } + + // Title (if provided) + if (dot.title) { + const title = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + title.setAttribute("x", (tooltipX + 10).toString()); + title.setAttribute( + "y", + dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 26).toString() + : (tooltipY + 25).toString() + ); + title.setAttribute("fill", "white"); + title.setAttribute("font-size", "14"); + title.setAttribute("font-weight", "bold"); + title.textContent = dot.title; + tooltip.appendChild(title); + } + + // Description (if provided) + if (dot.description) { + const descriptionFO = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + descriptionFO.setAttribute("x", (tooltipX + 10).toString()); + descriptionFO.setAttribute( + "y", + dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 32).toString() + : dot.title + ? (tooltipY + 35).toString() + : (tooltipY + 15).toString() + ); + descriptionFO.setAttribute("width", (tooltipWidth - 20).toString()); + descriptionFO.setAttribute("height", (tooltipHeight / 2 - 10).toString()); + + const descriptionDiv = document.createElement("div"); + descriptionDiv.style.color = "white"; + descriptionDiv.style.fontSize = "12px"; + descriptionDiv.style.overflow = "hidden"; + descriptionDiv.textContent = dot.description; + + descriptionFO.appendChild(descriptionDiv); + tooltip.appendChild(descriptionFO); + } + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + + this.dotsGroup.appendChild(circle); + } + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522092543.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522092543.ts new file mode 100644 index 0000000..e5b8d73 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522092543.ts @@ -0,0 +1,632 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + + // Calculate tooltip Y position, ensuring it stays within the container + let tooltipY = y - tooltipHeight - 20; // Position above the dot with some spacing + + // Ensure tooltip doesn't go above the container + tooltipY = Math.max(tooltipY, 10); // Keep at least 10px from the top + + // Background rectangle + // Create a rectangle for the tooltip with a 9:16 aspect ratio + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + + // Calculate width and height based on ratio + const height = tooltipHeight; + const width = (9 / 16) * height; + + // Set the width and height for a 9:16 aspect ratio + bg.setAttribute("width", width.toString()); + bg.setAttribute("height", height.toString()); + + // Remove any background fill + bg.setAttribute("fill", "none"); + + // Optional: Adjust corner rounding if needed + bg.setAttribute("rx", "5"); // You can set this to 0 for sharp corners + bg.setAttribute("ry", "5"); + + tooltip.appendChild(bg); + + // Tooltip arrow (pointing to the dot) + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.setAttribute("fill", "rgba(0, 0, 0, 0.8)"); + tooltip.appendChild(arrow); + + // Image (if provided) + if (dot.imageUrl) { + const imgContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + imgContainer.setAttribute("x", (tooltipX + 10).toString()); + imgContainer.setAttribute("y", (tooltipY + 10).toString()); + + // Set width and height to the same value for a square aspect ratio + const imageSize = Math.min(tooltipWidth - 20, tooltipHeight / 2); + imgContainer.setAttribute("width", imageSize.toString()); + imgContainer.setAttribute("height", imageSize.toString()); + + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.className = "tooltip-img"; + img.style.width = "calc(100% - 4px)"; + img.style.height = "calc(100% - 4px)"; + img.style.objectFit = "cover"; // Ensure the image covers the space while maintaining aspect ratio + + // Make the image circular and add a white border + img.style.borderRadius = "50%"; // Makes the image round + img.style.border = "2px solid white"; // Adds a 1px white border around the image + + imgContainer.appendChild(img); + tooltip.appendChild(imgContainer); + } + + // Title (if provided) + if (dot.title) { + const title = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + title.setAttribute("x", (tooltipX + 10).toString()); + title.setAttribute( + "y", + dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 26).toString() + : (tooltipY + 25).toString() + ); + title.setAttribute("class", "title"); + title.setAttribute("fill", "white"); + title.setAttribute("font-size", "14"); + title.setAttribute("font-weight", "bold"); + title.textContent = dot.title; + tooltip.appendChild(title); + } + + // Description (if provided) + if (dot.description) { + const descriptionFO = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + descriptionFO.setAttribute("x", (tooltipX + 10).toString()); + descriptionFO.setAttribute( + "y", + dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 32).toString() + : dot.title + ? (tooltipY + 35).toString() + : (tooltipY + 15).toString() + ); + descriptionFO.setAttribute("width", (tooltipWidth - 20).toString()); + descriptionFO.setAttribute("height", (tooltipHeight / 2 - 10).toString()); + + const descriptionDiv = document.createElement("div"); + descriptionDiv.style.color = "white"; + descriptionDiv.style.fontSize = "12px"; + descriptionDiv.style.overflow = "hidden"; + descriptionDiv.textContent = dot.description; + + descriptionFO.appendChild(descriptionDiv); + tooltip.appendChild(descriptionFO); + } + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + + this.dotsGroup.appendChild(circle); + } + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522092725.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522092725.ts new file mode 100644 index 0000000..7030e16 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522092725.ts @@ -0,0 +1,641 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + + // Calculate tooltip Y position, ensuring it stays within the container + let tooltipY = y - tooltipHeight - 20; // Position above the dot with some spacing + + // Ensure tooltip doesn't go above the container + tooltipY = Math.max(tooltipY, 10); // Keep at least 10px from the top + + // Background rectangle + // Create a rectangle for the tooltip with a 9:16 aspect ratio + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + + // Calculate width and height based on ratio + const height = tooltipHeight; + const width = (9 / 16) * height; + + // Set the width and height for a 9:16 aspect ratio + bg.setAttribute("width", width.toString()); + bg.setAttribute("height", height.toString()); + + // Remove any background fill + bg.setAttribute("fill", "none"); + + // Optional: Adjust corner rounding if needed + bg.setAttribute("rx", "5"); // You can set this to 0 for sharp corners + bg.setAttribute("ry", "5"); + + tooltip.appendChild(bg); + + + // Create a div with flexbox for centering content +const div = document.createElement('div'); +div.style.display = 'flex'; +div.style.justifyContent = 'center'; // Center horizontally +div.style.alignItems = 'center'; // Center vertically +div.style.width = '100%'; +div.style.height = '100%'; + + // Tooltip arrow (pointing to the dot) + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.setAttribute("fill", "rgba(0, 0, 0, 0.8)"); + tooltip.appendChild(arrow); + + // Image (if provided) + if (dot.imageUrl) { + const imgContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + imgContainer.setAttribute("x", (tooltipX + 10).toString()); + imgContainer.setAttribute("y", (tooltipY + 10).toString()); + + // Set width and height to the same value for a square aspect ratio + const imageSize = Math.min(tooltipWidth - 20, tooltipHeight / 2); + imgContainer.setAttribute("width", imageSize.toString()); + imgContainer.setAttribute("height", imageSize.toString()); + + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.className = "tooltip-img"; + img.style.width = "calc(100% - 4px)"; + img.style.height = "calc(100% - 4px)"; + img.style.objectFit = "cover"; // Ensure the image covers the space while maintaining aspect ratio + + // Make the image circular and add a white border + img.style.borderRadius = "50%"; // Makes the image round + img.style.border = "2px solid white"; // Adds a 1px white border around the image + + imgContainer.appendChild(img); + tooltip.appendChild(imgContainer); + } + + // Title (if provided) + if (dot.title) { + const title = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + title.setAttribute("x", (tooltipX + 10).toString()); + title.setAttribute( + "y", + dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 26).toString() + : (tooltipY + 25).toString() + ); + title.setAttribute("class", "title"); + title.setAttribute("fill", "white"); + title.setAttribute("font-size", "14"); + title.setAttribute("font-weight", "bold"); + title.textContent = dot.title; + tooltip.appendChild(title); + } + + // Description (if provided) + if (dot.description) { + const descriptionFO = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + descriptionFO.setAttribute("x", (tooltipX + 10).toString()); + descriptionFO.setAttribute( + "y", + dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 32).toString() + : dot.title + ? (tooltipY + 35).toString() + : (tooltipY + 15).toString() + ); + descriptionFO.setAttribute("width", (tooltipWidth - 20).toString()); + descriptionFO.setAttribute("height", (tooltipHeight / 2 - 10).toString()); + + const descriptionDiv = document.createElement("div"); + descriptionDiv.style.color = "white"; + descriptionDiv.style.fontSize = "12px"; + descriptionDiv.style.overflow = "hidden"; + descriptionDiv.textContent = dot.description; + + descriptionFO.appendChild(descriptionDiv); + tooltip.appendChild(descriptionFO); + } + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + + this.dotsGroup.appendChild(circle); + } + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522092810.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522092810.ts new file mode 100644 index 0000000..9fdf164 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522092810.ts @@ -0,0 +1,647 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + + // Calculate tooltip Y position, ensuring it stays within the container + let tooltipY = y - tooltipHeight - 20; // Position above the dot with some spacing + + // Ensure tooltip doesn't go above the container + tooltipY = Math.max(tooltipY, 10); // Keep at least 10px from the top + + // Background rectangle + // Create a rectangle for the tooltip with a 9:16 aspect ratio + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + + // Calculate width and height based on ratio + const height = tooltipHeight; + const width = (9 / 16) * height; + + // Set the width and height for a 9:16 aspect ratio + bg.setAttribute("width", width.toString()); + bg.setAttribute("height", height.toString()); + + // Remove any background fill + bg.setAttribute("fill", "none"); + + // Optional: Adjust corner rounding if needed + bg.setAttribute("rx", "5"); // You can set this to 0 for sharp corners + bg.setAttribute("ry", "5"); + + tooltip.appendChild(bg); + +// Create a foreignObject for centering content +const container = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); +container.setAttribute('width', width.toString()); +container.setAttribute('height', height.toString()); +container.setAttribute('x', tooltipX.toString()); +container.setAttribute('y', tooltipY.toString()); + +// Create a div with flexbox for centering content +const div = document.createElement('div'); +div.style.display = 'flex'; +div.style.justifyContent = 'center'; // Center horizontally +div.style.alignItems = 'center'; // Center vertically +div.style.width = '100%'; +div.style.height = '100%';'; + + // Tooltip arrow (pointing to the dot) + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.setAttribute("fill", "rgba(0, 0, 0, 0.8)"); + tooltip.appendChild(arrow); + + // Image (if provided) + if (dot.imageUrl) { + const imgContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + imgContainer.setAttribute("x", (tooltipX + 10).toString()); + imgContainer.setAttribute("y", (tooltipY + 10).toString()); + + // Set width and height to the same value for a square aspect ratio + const imageSize = Math.min(tooltipWidth - 20, tooltipHeight / 2); + imgContainer.setAttribute("width", imageSize.toString()); + imgContainer.setAttribute("height", imageSize.toString()); + + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.className = "tooltip-img"; + img.style.width = "calc(100% - 4px)"; + img.style.height = "calc(100% - 4px)"; + img.style.objectFit = "cover"; // Ensure the image covers the space while maintaining aspect ratio + + // Make the image circular and add a white border + img.style.borderRadius = "50%"; // Makes the image round + img.style.border = "2px solid white"; // Adds a 1px white border around the image + + imgContainer.appendChild(img); + tooltip.appendChild(imgContainer); + } + + // Title (if provided) + if (dot.title) { + const title = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + title.setAttribute("x", (tooltipX + 10).toString()); + title.setAttribute( + "y", + dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 26).toString() + : (tooltipY + 25).toString() + ); + title.setAttribute("class", "title"); + title.setAttribute("fill", "white"); + title.setAttribute("font-size", "14"); + title.setAttribute("font-weight", "bold"); + title.textContent = dot.title; + tooltip.appendChild(title); + } + + // Description (if provided) + if (dot.description) { + const descriptionFO = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + descriptionFO.setAttribute("x", (tooltipX + 10).toString()); + descriptionFO.setAttribute( + "y", + dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 32).toString() + : dot.title + ? (tooltipY + 35).toString() + : (tooltipY + 15).toString() + ); + descriptionFO.setAttribute("width", (tooltipWidth - 20).toString()); + descriptionFO.setAttribute("height", (tooltipHeight / 2 - 10).toString()); + + const descriptionDiv = document.createElement("div"); + descriptionDiv.style.color = "white"; + descriptionDiv.style.fontSize = "12px"; + descriptionDiv.style.overflow = "hidden"; + descriptionDiv.textContent = dot.description; + + descriptionFO.appendChild(descriptionDiv); + tooltip.appendChild(descriptionFO); + } + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + + this.dotsGroup.appendChild(circle); + } + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522092817.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522092817.ts new file mode 100644 index 0000000..6022b32 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522092817.ts @@ -0,0 +1,648 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + + // Calculate tooltip Y position, ensuring it stays within the container + let tooltipY = y - tooltipHeight - 20; // Position above the dot with some spacing + + // Ensure tooltip doesn't go above the container + tooltipY = Math.max(tooltipY, 10); // Keep at least 10px from the top + + // Background rectangle + // Create a rectangle for the tooltip with a 9:16 aspect ratio + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + + // Calculate width and height based on ratio + const height = tooltipHeight; + const width = (9 / 16) * height; + + // Set the width and height for a 9:16 aspect ratio + bg.setAttribute("width", width.toString()); + bg.setAttribute("height", height.toString()); + + // Remove any background fill + bg.setAttribute("fill", "none"); + + // Optional: Adjust corner rounding if needed + bg.setAttribute("rx", "5"); // You can set this to 0 for sharp corners + bg.setAttribute("ry", "5"); + + tooltip.appendChild(bg); + + + // Create a foreignObject for centering content +const container = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); +container.setAttribute('width', width.toString()); +container.setAttribute('height', height.toString()); +container.setAttribute('x', tooltipX.toString()); +container.setAttribute('y', tooltipY.toString()); + +// Create a div with flexbox for centering content +const div = document.createElement('div'); +div.style.display = 'flex'; +div.style.justifyContent = 'center'; // Center horizontally +div.style.alignItems = 'center'; // Center vertically +div.style.width = '100%'; +div.style.height = '100%'; + + // Tooltip arrow (pointing to the dot) + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.setAttribute("fill", "rgba(0, 0, 0, 0.8)"); + tooltip.appendChild(arrow); + + // Image (if provided) + if (dot.imageUrl) { + const imgContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + imgContainer.setAttribute("x", (tooltipX + 10).toString()); + imgContainer.setAttribute("y", (tooltipY + 10).toString()); + + // Set width and height to the same value for a square aspect ratio + const imageSize = Math.min(tooltipWidth - 20, tooltipHeight / 2); + imgContainer.setAttribute("width", imageSize.toString()); + imgContainer.setAttribute("height", imageSize.toString()); + + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.className = "tooltip-img"; + img.style.width = "calc(100% - 4px)"; + img.style.height = "calc(100% - 4px)"; + img.style.objectFit = "cover"; // Ensure the image covers the space while maintaining aspect ratio + + // Make the image circular and add a white border + img.style.borderRadius = "50%"; // Makes the image round + img.style.border = "2px solid white"; // Adds a 1px white border around the image + + imgContainer.appendChild(img); + tooltip.appendChild(imgContainer); + } + + // Title (if provided) + if (dot.title) { + const title = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + title.setAttribute("x", (tooltipX + 10).toString()); + title.setAttribute( + "y", + dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 26).toString() + : (tooltipY + 25).toString() + ); + title.setAttribute("class", "title"); + title.setAttribute("fill", "white"); + title.setAttribute("font-size", "14"); + title.setAttribute("font-weight", "bold"); + title.textContent = dot.title; + tooltip.appendChild(title); + } + + // Description (if provided) + if (dot.description) { + const descriptionFO = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + descriptionFO.setAttribute("x", (tooltipX + 10).toString()); + descriptionFO.setAttribute( + "y", + dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 32).toString() + : dot.title + ? (tooltipY + 35).toString() + : (tooltipY + 15).toString() + ); + descriptionFO.setAttribute("width", (tooltipWidth - 20).toString()); + descriptionFO.setAttribute("height", (tooltipHeight / 2 - 10).toString()); + + const descriptionDiv = document.createElement("div"); + descriptionDiv.style.color = "white"; + descriptionDiv.style.fontSize = "12px"; + descriptionDiv.style.overflow = "hidden"; + descriptionDiv.textContent = dot.description; + + descriptionFO.appendChild(descriptionDiv); + tooltip.appendChild(descriptionFO); + } + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + + this.dotsGroup.appendChild(circle); + } + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522092936.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522092936.ts new file mode 100644 index 0000000..6022b32 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522092936.ts @@ -0,0 +1,648 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + + // Calculate tooltip Y position, ensuring it stays within the container + let tooltipY = y - tooltipHeight - 20; // Position above the dot with some spacing + + // Ensure tooltip doesn't go above the container + tooltipY = Math.max(tooltipY, 10); // Keep at least 10px from the top + + // Background rectangle + // Create a rectangle for the tooltip with a 9:16 aspect ratio + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + + // Calculate width and height based on ratio + const height = tooltipHeight; + const width = (9 / 16) * height; + + // Set the width and height for a 9:16 aspect ratio + bg.setAttribute("width", width.toString()); + bg.setAttribute("height", height.toString()); + + // Remove any background fill + bg.setAttribute("fill", "none"); + + // Optional: Adjust corner rounding if needed + bg.setAttribute("rx", "5"); // You can set this to 0 for sharp corners + bg.setAttribute("ry", "5"); + + tooltip.appendChild(bg); + + + // Create a foreignObject for centering content +const container = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); +container.setAttribute('width', width.toString()); +container.setAttribute('height', height.toString()); +container.setAttribute('x', tooltipX.toString()); +container.setAttribute('y', tooltipY.toString()); + +// Create a div with flexbox for centering content +const div = document.createElement('div'); +div.style.display = 'flex'; +div.style.justifyContent = 'center'; // Center horizontally +div.style.alignItems = 'center'; // Center vertically +div.style.width = '100%'; +div.style.height = '100%'; + + // Tooltip arrow (pointing to the dot) + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.setAttribute("fill", "rgba(0, 0, 0, 0.8)"); + tooltip.appendChild(arrow); + + // Image (if provided) + if (dot.imageUrl) { + const imgContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + imgContainer.setAttribute("x", (tooltipX + 10).toString()); + imgContainer.setAttribute("y", (tooltipY + 10).toString()); + + // Set width and height to the same value for a square aspect ratio + const imageSize = Math.min(tooltipWidth - 20, tooltipHeight / 2); + imgContainer.setAttribute("width", imageSize.toString()); + imgContainer.setAttribute("height", imageSize.toString()); + + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.className = "tooltip-img"; + img.style.width = "calc(100% - 4px)"; + img.style.height = "calc(100% - 4px)"; + img.style.objectFit = "cover"; // Ensure the image covers the space while maintaining aspect ratio + + // Make the image circular and add a white border + img.style.borderRadius = "50%"; // Makes the image round + img.style.border = "2px solid white"; // Adds a 1px white border around the image + + imgContainer.appendChild(img); + tooltip.appendChild(imgContainer); + } + + // Title (if provided) + if (dot.title) { + const title = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + title.setAttribute("x", (tooltipX + 10).toString()); + title.setAttribute( + "y", + dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 26).toString() + : (tooltipY + 25).toString() + ); + title.setAttribute("class", "title"); + title.setAttribute("fill", "white"); + title.setAttribute("font-size", "14"); + title.setAttribute("font-weight", "bold"); + title.textContent = dot.title; + tooltip.appendChild(title); + } + + // Description (if provided) + if (dot.description) { + const descriptionFO = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + descriptionFO.setAttribute("x", (tooltipX + 10).toString()); + descriptionFO.setAttribute( + "y", + dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 32).toString() + : dot.title + ? (tooltipY + 35).toString() + : (tooltipY + 15).toString() + ); + descriptionFO.setAttribute("width", (tooltipWidth - 20).toString()); + descriptionFO.setAttribute("height", (tooltipHeight / 2 - 10).toString()); + + const descriptionDiv = document.createElement("div"); + descriptionDiv.style.color = "white"; + descriptionDiv.style.fontSize = "12px"; + descriptionDiv.style.overflow = "hidden"; + descriptionDiv.textContent = dot.description; + + descriptionFO.appendChild(descriptionDiv); + tooltip.appendChild(descriptionFO); + } + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + + this.dotsGroup.appendChild(circle); + } + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522093038.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522093038.ts new file mode 100644 index 0000000..9759151 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522093038.ts @@ -0,0 +1,650 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + + // Calculate tooltip Y position, ensuring it stays within the container + let tooltipY = y - tooltipHeight - 20; // Position above the dot with some spacing + + // Ensure tooltip doesn't go above the container + tooltipY = Math.max(tooltipY, 10); // Keep at least 10px from the top + + // Background rectangle + // Create a rectangle for the tooltip with a 9:16 aspect ratio + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + + // Calculate width and height based on ratio + const height = tooltipHeight; + const width = (9 / 16) * height; + + // Set the width and height for a 9:16 aspect ratio + bg.setAttribute("width", width.toString()); + bg.setAttribute("height", height.toString()); + + // Remove any background fill + bg.setAttribute("fill", "none"); + + // Optional: Adjust corner rounding if needed + bg.setAttribute("rx", "5"); // You can set this to 0 for sharp corners + bg.setAttribute("ry", "5"); + + tooltip.appendChild(bg); + + // Create a foreignObject for centering content + const container = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + container.setAttribute("width", width.toString()); + container.setAttribute("height", height.toString()); + container.setAttribute("x", tooltipX.toString()); + container.setAttribute("y", tooltipY.toString()); + + // Create a div with flexbox for centering content + const div = document.createElement("div"); + div.style.display = "flex"; + div.style.justifyContent = "center"; // Center horizontally + div.style.alignItems = "center"; // Center vertically + div.style.width = "100%"; + div.style.height = "100%"; + + // Tooltip arrow (pointing to the dot) + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.setAttribute("fill", "rgba(0, 0, 0, 0.8)"); + tooltip.appendChild(arrow); + + // Image (if provided) + if (dot.imageUrl) { + const imgContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + imgContainer.setAttribute("x", (tooltipX + 10).toString()); + imgContainer.setAttribute("y", (tooltipY + 10).toString()); + + // Set width and height to the same value for a square aspect ratio + const imageSize = Math.min(tooltipWidth - 20, tooltipHeight / 2); + imgContainer.setAttribute("width", imageSize.toString()); + imgContainer.setAttribute("height", imageSize.toString()); + + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.className = "tooltip-img"; + img.style.width = "calc(100% - 4px)"; + img.style.height = "calc(100% - 4px)"; + img.style.objectFit = "cover"; // Ensure the image covers the space while maintaining aspect ratio + + // Make the image circular and add a white border + img.style.borderRadius = "50%"; // Makes the image round + img.style.border = "2px solid white"; // Adds a 1px white border around the image + + imgContainer.appendChild(img); + tooltip.appendChild(imgContainer); + } + + // Title (if provided) + if (dot.title) { + const title = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + title.setAttribute("x", (tooltipX + 10).toString()); + title.setAttribute( + "y", + dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 26).toString() + : (tooltipY + 25).toString() + ); + title.setAttribute("class", "title"); + title.setAttribute("fill", "white"); + title.setAttribute("font-size", "14"); + title.setAttribute("font-weight", "bold"); + title.textContent = dot.title; + tooltip.appendChild(title); + } + + // Description (if provided) + if (dot.description) { + const descriptionFO = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + descriptionFO.setAttribute("x", (tooltipX + 10).toString()); + descriptionFO.setAttribute( + "y", + dot.imageUrl + ? (tooltipY + tooltipHeight / 2 + 32).toString() + : dot.title + ? (tooltipY + 35).toString() + : (tooltipY + 15).toString() + ); + descriptionFO.setAttribute("width", (tooltipWidth - 20).toString()); + descriptionFO.setAttribute("height", (tooltipHeight / 2 - 10).toString()); + + const descriptionDiv = document.createElement("div"); + descriptionDiv.style.color = "white"; + descriptionDiv.style.fontSize = "12px"; + descriptionDiv.style.overflow = "hidden"; + descriptionDiv.textContent = dot.description; + + descriptionFO.appendChild(descriptionDiv); + tooltip.appendChild(descriptionFO); + } + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + + this.dotsGroup.appendChild(circle); + } + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522093141.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522093141.ts new file mode 100644 index 0000000..45ddb43 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522093141.ts @@ -0,0 +1,583 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("fill", "rgba(0, 0, 0, 0.8)"); + bg.setAttribute("rx", "5"); // Rounded corners + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + contentContainer.setAttribute('x', tooltipX.toString()); + contentContainer.setAttribute('y', tooltipY.toString()); + contentContainer.setAttribute('width', tooltipWidth.toString()); + contentContainer.setAttribute('height', tooltipHeight.toString()); + + // Create a div with flexbox for centering content + const div = document.createElement('div'); + div.style.display = 'flex'; + div.style.flexDirection = 'column'; + div.style.justifyContent = 'center'; // Center vertically + div.style.alignItems = 'center'; // Center horizontally + div.style.width = '100%'; + div.style.height = '100%'; + div.style.color = 'white'; // Set text color to white + + // Add image if available + if (dot.imageUrl) { + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.style.width = '50px'; + img.style.height = '50px'; + img.style.borderRadius = '50%'; // Circular image + img.style.border = '2px solid white'; + div.appendChild(img); + } + + // Add title if available + if (dot.title) { + const title = document.createElement('div'); + title.style.fontSize = '14px'; + title.style.fontWeight = 'bold'; + title.textContent = dot.title; + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement('div'); + desc.style.fontSize = '12px'; + desc.textContent = dot.description; + div.appendChild(desc); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS("http://www.w3.org/2000/svg", "path"); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.setAttribute("fill", "rgba(0, 0, 0, 0.8)"); + tooltip.appendChild(arrow); + + return tooltip; + } + + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + + this.dotsGroup.appendChild(circle); + } + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522093202.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522093202.ts new file mode 100644 index 0000000..45ddb43 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522093202.ts @@ -0,0 +1,583 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} + +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} + +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} + +interface TooltipEdges { + leftmost: number; + rightmost: number; +} + +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + + private preloadedImages: Map = new Map(); + + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + + // Active tooltip + private activeTooltip: SVGElement | null = null; + + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + + // Set src to start loading + img.src = url; + + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + + // Configure dots group + this.svg.appendChild(this.dotsGroup); + + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + + return { x1, y1, x2, y2 }; + } + + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + + return path; + } + + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + + if (!this.config.showGrid) return; + + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("fill", "rgba(0, 0, 0, 0.8)"); + bg.setAttribute("rx", "5"); // Rounded corners + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + contentContainer.setAttribute('x', tooltipX.toString()); + contentContainer.setAttribute('y', tooltipY.toString()); + contentContainer.setAttribute('width', tooltipWidth.toString()); + contentContainer.setAttribute('height', tooltipHeight.toString()); + + // Create a div with flexbox for centering content + const div = document.createElement('div'); + div.style.display = 'flex'; + div.style.flexDirection = 'column'; + div.style.justifyContent = 'center'; // Center vertically + div.style.alignItems = 'center'; // Center horizontally + div.style.width = '100%'; + div.style.height = '100%'; + div.style.color = 'white'; // Set text color to white + + // Add image if available + if (dot.imageUrl) { + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.style.width = '50px'; + img.style.height = '50px'; + img.style.borderRadius = '50%'; // Circular image + img.style.border = '2px solid white'; + div.appendChild(img); + } + + // Add title if available + if (dot.title) { + const title = document.createElement('div'); + title.style.fontSize = '14px'; + title.style.fontWeight = 'bold'; + title.textContent = dot.title; + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement('div'); + desc.style.fontSize = '12px'; + desc.textContent = dot.description; + div.appendChild(desc); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS("http://www.w3.org/2000/svg", "path"); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.setAttribute("fill", "rgba(0, 0, 0, 0.8)"); + tooltip.appendChild(arrow); + + return tooltip; + } + + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + + return { leftmost, rightmost }; + } + + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + + this.dotsGroup.appendChild(circle); + } + } + + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + + // Update grid width + this.drawGrid(); + } + } + + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522093316.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522093316.ts new file mode 100644 index 0000000..06180d3 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522093316.ts @@ -0,0 +1,500 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + // Calculate tooltip dimensions and position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("fill", "rgba(0, 0, 0, 0.8)"); + bg.setAttribute("rx", "5"); // Rounded corners + tooltip.appendChild(bg); + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + // Create a div with flexbox for centering content + const div = document.createElement("div"); + div.style.display = "flex"; + div.style.flexDirection = "column"; + div.style.justifyContent = "center"; // Center vertically + div.style.alignItems = "center"; // Center horizontally + div.style.width = "100%"; + div.style.height = "100%"; + div.style.color = "white"; // Set text color to white + // Add image if available + if (dot.imageUrl) { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.style.width = "50px"; + img.style.height = "50px"; + img.style.borderRadius = "50%"; // Circular image + img.style.border = "2px solid white"; + div.appendChild(img); + } + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.style.fontSize = "14px"; + title.style.fontWeight = "bold"; + title.textContent = dot.title; + div.appendChild(title); + } + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.style.fontSize = "12px"; + desc.textContent = dot.description; + div.appendChild(desc); + } + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.setAttribute("fill", "rgba(0, 0, 0, 0.8)"); + tooltip.appendChild(arrow); + return tooltip; + } + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522093434.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522093434.ts new file mode 100644 index 0000000..b1ea08f --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522093434.ts @@ -0,0 +1,507 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + // Calculate tooltip dimensions and position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + + // Calculate width and height based on ratio + const height = tooltipHeight; + const width = (9 / 16) * height; + + // Set the width and height for a 9:16 aspect ratio + bg.setAttribute("width", width.toString()); + bg.setAttribute("height", height.toString()); + + bg.setAttribute("fill", "rgba(0, 0, 0, 0.8)"); + bg.setAttribute("rx", "5"); // Rounded corners + tooltip.appendChild(bg); + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + // Create a div with flexbox for centering content + const div = document.createElement("div"); + div.style.display = "flex"; + div.style.flexDirection = "column"; + div.style.justifyContent = "center"; // Center vertically + div.style.alignItems = "center"; // Center horizontally + div.style.width = "100%"; + div.style.height = "100%"; + div.style.color = "white"; // Set text color to white + // Add image if available + if (dot.imageUrl) { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.style.width = "50px"; + img.style.height = "50px"; + img.style.borderRadius = "50%"; // Circular image + img.style.border = "2px solid white"; + div.appendChild(img); + } + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.style.fontSize = "14px"; + title.style.fontWeight = "bold"; + title.textContent = dot.title; + div.appendChild(title); + } + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.style.fontSize = "12px"; + desc.textContent = dot.description; + div.appendChild(desc); + } + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.setAttribute("fill", "rgba(0, 0, 0, 0.8)"); + tooltip.appendChild(arrow); + return tooltip; + } + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522093501.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522093501.ts new file mode 100644 index 0000000..f31146f --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522093501.ts @@ -0,0 +1,504 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + // Calculate tooltip dimensions and position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + + // Calculate width and height based on ratio + const height = tooltipHeight; + const width = (9 / 16) * height; + + // Set the width and height for a 9:16 aspect ratio + bg.setAttribute("width", width.toString()); + bg.setAttribute("height", height.toString()); + + bg.setAttribute("fill", "rgba(0, 0, 0, 0.8)"); + bg.setAttribute("rx", "5"); // Rounded corners + tooltip.appendChild(bg); + // Create a foreignObject for centering content +const container = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); +container.setAttribute('width', width.toString()); +container.setAttribute('height', height.toString()); +container.setAttribute('x', tooltipX.toString()); +container.setAttribute('y', tooltipY.toString()); + // Create a div with flexbox for centering content + const div = document.createElement("div"); + div.style.display = "flex"; + div.style.flexDirection = "column"; + div.style.justifyContent = "center"; // Center vertically + div.style.alignItems = "center"; // Center horizontally + div.style.width = "100%"; + div.style.height = "100%"; + div.style.color = "white"; // Set text color to white + // Add image if available + if (dot.imageUrl) { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.style.width = "50px"; + img.style.height = "50px"; + img.style.borderRadius = "50%"; // Circular image + img.style.border = "2px solid white"; + div.appendChild(img); + } + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.style.fontSize = "14px"; + title.style.fontWeight = "bold"; + title.textContent = dot.title; + div.appendChild(title); + } + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.style.fontSize = "12px"; + desc.textContent = dot.description; + div.appendChild(desc); + } + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.setAttribute("fill", "rgba(0, 0, 0, 0.8)"); + tooltip.appendChild(arrow); + return tooltip; + } + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522093509.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522093509.ts new file mode 100644 index 0000000..753c922 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522093509.ts @@ -0,0 +1,509 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + // Calculate tooltip dimensions and position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + + // Calculate width and height based on ratio + const height = tooltipHeight; + const width = (9 / 16) * height; + + // Set the width and height for a 9:16 aspect ratio + bg.setAttribute("width", width.toString()); + bg.setAttribute("height", height.toString()); + + bg.setAttribute("fill", "rgba(0, 0, 0, 0.8)"); + bg.setAttribute("rx", "5"); // Rounded corners + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div with flexbox for centering content + const div = document.createElement("div"); + div.style.display = "flex"; + div.style.flexDirection = "column"; + div.style.justifyContent = "center"; // Center vertically + div.style.alignItems = "center"; // Center horizontally + div.style.width = "100%"; + div.style.height = "100%"; + div.style.color = "white"; // Set text color to white + // Add image if available + if (dot.imageUrl) { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.style.width = "50px"; + img.style.height = "50px"; + img.style.borderRadius = "50%"; // Circular image + img.style.border = "2px solid white"; + div.appendChild(img); + } + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.style.fontSize = "14px"; + title.style.fontWeight = "bold"; + title.textContent = dot.title; + div.appendChild(title); + } + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.style.fontSize = "12px"; + desc.textContent = dot.description; + div.appendChild(desc); + } + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.setAttribute("fill", "rgba(0, 0, 0, 0.8)"); + tooltip.appendChild(arrow); + return tooltip; + } + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522093827.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522093827.ts new file mode 100644 index 0000000..bf2b1db --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522093827.ts @@ -0,0 +1,498 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + +private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + contentContainer.setAttribute('x', tooltipX.toString()); + contentContainer.setAttribute('y', tooltipY.toString()); + contentContainer.setAttribute('width', tooltipWidth.toString()); + contentContainer.setAttribute('height', tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement('div'); + div.classList.add("tooltip-content"); + + // Add image if available + if (dot.imageUrl) { + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + div.appendChild(img); + } + + // Add title if available + if (dot.title) { + const title = document.createElement('div'); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement('div'); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS("http://www.w3.org/2000/svg", "path"); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; +} + + + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094341.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094341.ts new file mode 100644 index 0000000..32ca3df --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094341.ts @@ -0,0 +1,502 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + +private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + +// const tooltipWidth = 200; // or any other desired width +// const tooltipHeight = (16 / 9) * tooltipWidth; + + // Calculate tooltip dimensions and position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + contentContainer.setAttribute('x', tooltipX.toString()); + contentContainer.setAttribute('y', tooltipY.toString()); + contentContainer.setAttribute('width', tooltipWidth.toString()); + contentContainer.setAttribute('height', tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement('div'); + div.classList.add("tooltip-content"); + + // Add image if available + if (dot.imageUrl) { + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + div.appendChild(img); + } + + // Add title if available + if (dot.title) { + const title = document.createElement('div'); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement('div'); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS("http://www.w3.org/2000/svg", "path"); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; +} + + + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094352.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094352.ts new file mode 100644 index 0000000..2b23558 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094352.ts @@ -0,0 +1,502 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + +private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + +// const tooltipWidth = 200; // or any other desired width +const tooltipHeight = (16 / 9) * tooltipWidth; + + // Calculate tooltip dimensions and position + const tooltipWidth = this.config.tooltipWidth; +// const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + contentContainer.setAttribute('x', tooltipX.toString()); + contentContainer.setAttribute('y', tooltipY.toString()); + contentContainer.setAttribute('width', tooltipWidth.toString()); + contentContainer.setAttribute('height', tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement('div'); + div.classList.add("tooltip-content"); + + // Add image if available + if (dot.imageUrl) { + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + div.appendChild(img); + } + + // Add title if available + if (dot.title) { + const title = document.createElement('div'); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement('div'); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS("http://www.w3.org/2000/svg", "path"); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; +} + + + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094405.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094405.ts new file mode 100644 index 0000000..4cd7fcf --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094405.ts @@ -0,0 +1,502 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + +private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + +// const tooltipWidth = 200; // or any other desired width +const tooltipHeight = (16 / 9) * tooltipWidth; + + // Calculate tooltip dimensions and position +// const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + contentContainer.setAttribute('x', tooltipX.toString()); + contentContainer.setAttribute('y', tooltipY.toString()); + contentContainer.setAttribute('width', tooltipWidth.toString()); + contentContainer.setAttribute('height', tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement('div'); + div.classList.add("tooltip-content"); + + // Add image if available + if (dot.imageUrl) { + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + div.appendChild(img); + } + + // Add title if available + if (dot.title) { + const title = document.createElement('div'); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement('div'); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS("http://www.w3.org/2000/svg", "path"); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; +} + + + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094427.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094427.ts new file mode 100644 index 0000000..32ca3df --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094427.ts @@ -0,0 +1,502 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + +private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + +// const tooltipWidth = 200; // or any other desired width +// const tooltipHeight = (16 / 9) * tooltipWidth; + + // Calculate tooltip dimensions and position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + contentContainer.setAttribute('x', tooltipX.toString()); + contentContainer.setAttribute('y', tooltipY.toString()); + contentContainer.setAttribute('width', tooltipWidth.toString()); + contentContainer.setAttribute('height', tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement('div'); + div.classList.add("tooltip-content"); + + // Add image if available + if (dot.imageUrl) { + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + div.appendChild(img); + } + + // Add title if available + if (dot.title) { + const title = document.createElement('div'); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement('div'); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS("http://www.w3.org/2000/svg", "path"); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; +} + + + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094438.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094438.ts new file mode 100644 index 0000000..3c582aa --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094438.ts @@ -0,0 +1,499 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + +private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 4; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + contentContainer.setAttribute('x', tooltipX.toString()); + contentContainer.setAttribute('y', tooltipY.toString()); + contentContainer.setAttribute('width', tooltipWidth.toString()); + contentContainer.setAttribute('height', tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement('div'); + div.classList.add("tooltip-content"); + + // Add image if available + if (dot.imageUrl) { + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + div.appendChild(img); + } + + // Add title if available + if (dot.title) { + const title = document.createElement('div'); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement('div'); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS("http://www.w3.org/2000/svg", "path"); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; +} + + + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094441.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094441.ts new file mode 100644 index 0000000..c5265a2 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094441.ts @@ -0,0 +1,499 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + +private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); + contentContainer.setAttribute('x', tooltipX.toString()); + contentContainer.setAttribute('y', tooltipY.toString()); + contentContainer.setAttribute('width', tooltipWidth.toString()); + contentContainer.setAttribute('height', tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement('div'); + div.classList.add("tooltip-content"); + + // Add image if available + if (dot.imageUrl) { + const img = document.createElement('img'); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + div.appendChild(img); + } + + // Add title if available + if (dot.title) { + const title = document.createElement('div'); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement('div'); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS("http://www.w3.org/2000/svg", "path"); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; +} + + + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094711.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094711.ts new file mode 100644 index 0000000..30e1c6f --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094711.ts @@ -0,0 +1,503 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 80, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add image if available + if (dot.imageUrl) { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + div.appendChild(img); + } + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094716.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094716.ts new file mode 100644 index 0000000..e47ca10 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094716.ts @@ -0,0 +1,503 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 256, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add image if available + if (dot.imageUrl) { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + div.appendChild(img); + } + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094721.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094721.ts new file mode 100644 index 0000000..2af5013 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094721.ts @@ -0,0 +1,503 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = this.config.tooltipWidth; + const tooltipHeight = this.config.tooltipHeight; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add image if available + if (dot.imageUrl) { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + div.appendChild(img); + } + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094758.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094758.ts new file mode 100644 index 0000000..8617fec --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094758.ts @@ -0,0 +1,504 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = this.config.tooltipWidth; + // const tooltipHeight = this.config.tooltipHeight; + const tooltipHeight = (16 / 9) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add image if available + if (dot.imageUrl) { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + div.appendChild(img); + } + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094923.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094923.ts new file mode 100644 index 0000000..32f7715 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094923.ts @@ -0,0 +1,504 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 2000, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = this.config.tooltipWidth; + // const tooltipHeight = this.config.tooltipHeight; + const tooltipHeight = (16 / 9) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add image if available + if (dot.imageUrl) { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + div.appendChild(img); + } + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094927.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094927.ts new file mode 100644 index 0000000..8617fec --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094927.ts @@ -0,0 +1,504 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = this.config.tooltipWidth; + // const tooltipHeight = this.config.tooltipHeight; + const tooltipHeight = (16 / 9) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add image if available + if (dot.imageUrl) { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + div.appendChild(img); + } + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094944.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094944.ts new file mode 100644 index 0000000..b59444b --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522094944.ts @@ -0,0 +1,505 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + // const tooltipWidth = this.config.tooltipWidth; + const tooltipWidth = 128; // Base width for your tooltip + // const tooltipHeight = this.config.tooltipHeight; + const tooltipHeight = (16 / 9) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add image if available + if (dot.imageUrl) { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + div.appendChild(img); + } + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522095334.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522095334.ts new file mode 100644 index 0000000..39b6cfa --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522095334.ts @@ -0,0 +1,503 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (16 / 9) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add image if available + if (dot.imageUrl) { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + div.appendChild(img); + } + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522095400.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522095400.ts new file mode 100644 index 0000000..909803b --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522095400.ts @@ -0,0 +1,505 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (16 / 9) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + + // Add image if available + if (dot.imageUrl) { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + div.appendChild(img); + } + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522095543.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522095543.ts new file mode 100644 index 0000000..17a9f48 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522095543.ts @@ -0,0 +1,505 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (3 / 2) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + + // Add image if available + if (dot.imageUrl) { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + div.appendChild(img); + } + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522101227.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522101227.ts new file mode 100644 index 0000000..c6917bc --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522101227.ts @@ -0,0 +1,516 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (3 / 2) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + +// Add image if available +if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); +} + + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522102503.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522102503.ts new file mode 100644 index 0000000..b7cb7fa --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522102503.ts @@ -0,0 +1,513 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (2 / 1) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522102521.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522102521.ts new file mode 100644 index 0000000..4da8300 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522102521.ts @@ -0,0 +1,513 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522102742.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522102742.ts new file mode 100644 index 0000000..aa55f93 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522102742.ts @@ -0,0 +1,515 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522103253.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522103253.ts new file mode 100644 index 0000000..50be4e1 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522103253.ts @@ -0,0 +1,513 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522104846.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522104846.ts new file mode 100644 index 0000000..49a13c9 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522104846.ts @@ -0,0 +1,514 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x} ${ + tooltipY + tooltipHeight - 10 + }` + ); + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522104938.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522104938.ts new file mode 100644 index 0000000..50be4e1 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522104938.ts @@ -0,0 +1,513 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + tooltipY + tooltipHeight - 10 + } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + ); + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105020.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105020.ts new file mode 100644 index 0000000..1d00c27 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105020.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x} ${ + tooltipY + tooltipHeight - 10 + }` +); + // arrow.setAttribute( + // "d", + // `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + // tooltipY + tooltipHeight - 10 + // } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + // ); + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105023.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105023.ts new file mode 100644 index 0000000..7e730c0 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105023.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x} ${ + tooltipY + tooltipHeight - 100 + }` +); + // arrow.setAttribute( + // "d", + // `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + // tooltipY + tooltipHeight - 10 + // } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + // ); + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105055.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105055.ts new file mode 100644 index 0000000..afceca6 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105055.ts @@ -0,0 +1,522 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x} ${ + tooltipY + tooltipHeight - 100 + }` +); + // arrow.setAttribute( + // "d", + // `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + // tooltipY + tooltipHeight - 10 + // } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + // ); + + arrow.setAttribute("stroke", "black"); // Set the color of the line +arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105115.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105115.ts new file mode 100644 index 0000000..86a13eb --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105115.ts @@ -0,0 +1,522 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x} ${ + tooltipY + tooltipHeight - 10 + }` + ); + // arrow.setAttribute( + // "d", + // `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + // tooltipY + tooltipHeight - 10 + // } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + // ); + + arrow.setAttribute("stroke", "black"); // Set the color of the line + arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105129.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105129.ts new file mode 100644 index 0000000..39a5153 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105129.ts @@ -0,0 +1,522 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x} ${ + tooltipY + tooltipHeight - 10 + }` + ); + // arrow.setAttribute( + // "d", + // `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + // tooltipY + tooltipHeight - 10 + // } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + // ); + + arrow.setAttribute("stroke", "white"); // Set the color of the line + arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105224.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105224.ts new file mode 100644 index 0000000..39a5153 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105224.ts @@ -0,0 +1,522 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x} ${ + tooltipY + tooltipHeight - 10 + }` + ); + // arrow.setAttribute( + // "d", + // `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + // tooltipY + tooltipHeight - 10 + // } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + // ); + + arrow.setAttribute("stroke", "white"); // Set the color of the line + arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105229.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105229.ts new file mode 100644 index 0000000..1222aed --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105229.ts @@ -0,0 +1,522 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x} ${ + tooltipY + tooltipHeight - 20 + }` + ); + // arrow.setAttribute( + // "d", + // `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + // tooltipY + tooltipHeight - 10 + // } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + // ); + + arrow.setAttribute("stroke", "white"); // Set the color of the line + arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105242.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105242.ts new file mode 100644 index 0000000..17ac986 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105242.ts @@ -0,0 +1,522 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x} ${ + tooltipY + tooltipHeight - 16 + }` + ); + // arrow.setAttribute( + // "d", + // `M ${x} ${tooltipY + tooltipHeight} L ${x - 10} ${ + // tooltipY + tooltipHeight - 10 + // } L ${x + 10} ${tooltipY + tooltipHeight - 10} Z` + // ); + + arrow.setAttribute("stroke", "white"); // Set the color of the line + arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105702.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105702.ts new file mode 100644 index 0000000..8ac83b7 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105702.ts @@ -0,0 +1,518 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + +// Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x} ${ + tooltipY + tooltipHeight - 16 + }` + ); + + arrow.setAttribute("stroke", "white"); // Set the color of the line + arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105928.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105928.ts new file mode 100644 index 0000000..86baa3a --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522105928.ts @@ -0,0 +1,518 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + contentContainer.appendChild(div); + + + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x} ${ + tooltipY + tooltipHeight - 16 + }` + ); + + arrow.setAttribute("stroke", "white"); // Set the color of the line + arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522110035.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522110035.ts new file mode 100644 index 0000000..6937c4e --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522110035.ts @@ -0,0 +1,518 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + // Add arrow path if needed + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x} ${ + tooltipY + tooltipHeight - 16 + }` + ); + + arrow.setAttribute("stroke", "white"); // Set the color of the line + arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522110335.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522110335.ts new file mode 100644 index 0000000..438af12 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522110335.ts @@ -0,0 +1,520 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + // Add arrow path if needed + const arrowContainer = document.createElement("div"); + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x} ${ + tooltipY + tooltipHeight - 16 + }` + ); + + arrow.setAttribute("stroke", "white"); // Set the color of the line + arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + arrowContainer.classList.add("arrow-container"); + div.appendChild(arrowContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522110431.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522110431.ts new file mode 100644 index 0000000..438af12 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522110431.ts @@ -0,0 +1,520 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + // Add arrow path if needed + const arrowContainer = document.createElement("div"); + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x} ${ + tooltipY + tooltipHeight - 16 + }` + ); + + arrow.setAttribute("stroke", "white"); // Set the color of the line + arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + arrowContainer.classList.add("arrow-container"); + div.appendChild(arrowContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522110437.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522110437.ts new file mode 100644 index 0000000..438af12 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522110437.ts @@ -0,0 +1,520 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + // Add arrow path if needed + const arrowContainer = document.createElement("div"); + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x} ${ + tooltipY + tooltipHeight - 16 + }` + ); + + arrow.setAttribute("stroke", "white"); // Set the color of the line + arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + arrowContainer.classList.add("arrow-container"); + div.appendChild(arrowContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522110859.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522110859.ts new file mode 100644 index 0000000..68cb2dd --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522110859.ts @@ -0,0 +1,520 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + // Add arrow path if needed + const arrowContainer = document.createElement("div"); + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x} ${ + tooltipY + tooltipHeight - 16 + }` + ); + + arrow.setAttribute("stroke", "white"); // Set the color of the line + arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + arrowContainer.classList.add("arrow-container"); + div.appendChild(arrowContainer); + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522110953.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522110953.ts new file mode 100644 index 0000000..91bc4d5 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522110953.ts @@ -0,0 +1,520 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + // Add arrow path if needed + // const arrowContainer = document.createElement("div"); + // const arrow = document.createElementNS( + // "http://www.w3.org/2000/svg", + // "path" + // ); + // arrow.setAttribute( + // "d", + // `M ${x} ${tooltipY + tooltipHeight} L ${x} ${ + // tooltipY + tooltipHeight - 16 + // }` + // ); + + // arrow.setAttribute("stroke", "white"); // Set the color of the line + // arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + // arrow.classList.add("tooltip-arrow"); + // tooltip.appendChild(arrow); + + // arrowContainer.classList.add("arrow-container"); + // div.appendChild(arrowContainer); + + // contentContainer.appendChild(div); + // tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111000.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111000.ts new file mode 100644 index 0000000..8c121c1 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111000.ts @@ -0,0 +1,520 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + // Add arrow path if needed + // const arrowContainer = document.createElement("div"); + // const arrow = document.createElementNS( + // "http://www.w3.org/2000/svg", + // "path" + // ); + // arrow.setAttribute( + // "d", + // `M ${x} ${tooltipY + tooltipHeight} L ${x} ${ + // tooltipY + tooltipHeight - 16 + // }` + // ); + + // arrow.setAttribute("stroke", "white"); // Set the color of the line + // arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + // arrow.classList.add("tooltip-arrow"); + // tooltip.appendChild(arrow); + + // arrowContainer.classList.add("arrow-container"); + // div.appendChild(arrowContainer); + + contentContainer.appendChild(div); + // tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111003.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111003.ts new file mode 100644 index 0000000..e9552ed --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111003.ts @@ -0,0 +1,520 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + // Add arrow path if needed + // const arrowContainer = document.createElement("div"); + // const arrow = document.createElementNS( + // "http://www.w3.org/2000/svg", + // "path" + // ); + // arrow.setAttribute( + // "d", + // `M ${x} ${tooltipY + tooltipHeight} L ${x} ${ + // tooltipY + tooltipHeight - 16 + // }` + // ); + + // arrow.setAttribute("stroke", "white"); // Set the color of the line + // arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + // arrow.classList.add("tooltip-arrow"); + // tooltip.appendChild(arrow); + + // arrowContainer.classList.add("arrow-container"); + // div.appendChild(arrowContainer); + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111016.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111016.ts new file mode 100644 index 0000000..5da3526 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111016.ts @@ -0,0 +1,520 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + // Add arrow path if needed + const arrowContainer = document.createElement("div"); + // const arrow = document.createElementNS( + // "http://www.w3.org/2000/svg", + // "path" + // ); + // arrow.setAttribute( + // "d", + // `M ${x} ${tooltipY + tooltipHeight} L ${x} ${ + // tooltipY + tooltipHeight - 16 + // }` + // ); + + // arrow.setAttribute("stroke", "white"); // Set the color of the line + // arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + // arrow.classList.add("tooltip-arrow"); + // tooltip.appendChild(arrow); + + // arrowContainer.classList.add("arrow-container"); + // div.appendChild(arrowContainer); + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111039.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111039.ts new file mode 100644 index 0000000..d55288c --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111039.ts @@ -0,0 +1,520 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + // Add arrow path if needed + const arrowContainer = document.createElement("div"); + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x} ${ + tooltipY + tooltipHeight - 16 + }` + ); + + // arrow.setAttribute("stroke", "white"); // Set the color of the line + // arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + // arrow.classList.add("tooltip-arrow"); + // tooltip.appendChild(arrow); + + // arrowContainer.classList.add("arrow-container"); + // div.appendChild(arrowContainer); + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111311.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111311.ts new file mode 100644 index 0000000..dd913cb --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111311.ts @@ -0,0 +1,520 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + // Add arrow path if needed + const arrowContainer = document.createElement("div"); + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x} ${ + tooltipY + tooltipHeight - 16 + }` + ); + + arrow.setAttribute("stroke", "white"); // Set the color of the line + arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + // arrow.classList.add("tooltip-arrow"); + // tooltip.appendChild(arrow); + + // arrowContainer.classList.add("arrow-container"); + // div.appendChild(arrowContainer); + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111404.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111404.ts new file mode 100644 index 0000000..e292a55 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111404.ts @@ -0,0 +1,520 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + // Add arrow path if needed + const arrowContainer = document.createElement("div"); + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x} ${ + tooltipY + tooltipHeight - 16 + }` + ); + + arrow.setAttribute("stroke", "white"); // Set the color of the line + arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + arrow.classList.add("tooltip-arrow"); + tooltip.appendChild(arrow); + + // arrowContainer.classList.add("arrow-container"); + // div.appendChild(arrowContainer); + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111448.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111448.ts new file mode 100644 index 0000000..9fc82a8 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111448.ts @@ -0,0 +1,521 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + // Add arrow path if needed + const arrowContainer = document.createElement("div"); + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x} ${ + tooltipY + tooltipHeight - 16 + }` + ); + + arrow.setAttribute("stroke", "white"); // Set the color of the line + arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + arrow.classList.add("tooltip-arrow"); + + // tooltip.appendChild(arrow); + + arrowContainer.classList.add("arrow-container"); + div.appendChild(arrowContainer); + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111457.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111457.ts new file mode 100644 index 0000000..3774628 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111457.ts @@ -0,0 +1,521 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + // Add arrow path if needed + const arrowContainer = document.createElement("div"); + const arrow = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x} ${ + tooltipY + tooltipHeight - 16 + }` + ); + + arrow.setAttribute("stroke", "white"); // Set the color of the line + arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + arrow.classList.add("tooltip-arrow"); + + tooltip.appendChild(arrow); + + arrowContainer.classList.add("arrow-container"); + div.appendChild(arrowContainer); + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111743.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111743.ts new file mode 100644 index 0000000..7d44994 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111743.ts @@ -0,0 +1,510 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + // Create arrow path and add it inside tooltip-content + const arrow = document.createElementNS("http://www.w3.org/2000/svg", "path"); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x} ${tooltipY + tooltipHeight - 16}` + ); + arrow.setAttribute("stroke", "white"); // Set the color of the line + arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; +} + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111904.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111904.ts new file mode 100644 index 0000000..50d9cb1 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111904.ts @@ -0,0 +1,510 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + // Create arrow path and add it inside tooltip-content + const arrow = document.createElementNS("http://www.w3.org/2000/svg", "path"); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x} ${tooltipY + tooltipHeight - 16}` + ); + arrow.setAttribute("stroke", "white"); // Set the color of the line + arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + arrow.classList.add("tooltip-arrow"); + + // div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; +} + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111911.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111911.ts new file mode 100644 index 0000000..fe01e2e --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111911.ts @@ -0,0 +1,510 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + // Create arrow path and add it inside tooltip-content + const arrow = document.createElementNS("http://www.w3.org/2000/svg", "path"); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x} ${tooltipY + tooltipHeight - 16}` + ); + arrow.setAttribute("stroke", "white"); // Set the color of the line + arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + // contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; +} + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111915.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111915.ts new file mode 100644 index 0000000..50d9cb1 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111915.ts @@ -0,0 +1,510 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + // Create arrow path and add it inside tooltip-content + const arrow = document.createElementNS("http://www.w3.org/2000/svg", "path"); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x} ${tooltipY + tooltipHeight - 16}` + ); + arrow.setAttribute("stroke", "white"); // Set the color of the line + arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + arrow.classList.add("tooltip-arrow"); + + // div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; +} + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111956.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111956.ts new file mode 100644 index 0000000..7d44994 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522111956.ts @@ -0,0 +1,510 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + // Create arrow path and add it inside tooltip-content + const arrow = document.createElementNS("http://www.w3.org/2000/svg", "path"); + arrow.setAttribute( + "d", + `M ${x} ${tooltipY + tooltipHeight} L ${x} ${tooltipY + tooltipHeight - 16}` + ); + arrow.setAttribute("stroke", "white"); // Set the color of the line + arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; +} + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522112131.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522112131.ts new file mode 100644 index 0000000..a91b304 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522112131.ts @@ -0,0 +1,514 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + // Create an empty div for the arrow + const arrowDiv = document.createElement('div'); + + // Optionally set styles directly or via CSS class + arrowDiv.style.width = '0'; + arrowDiv.style.height = '0'; + + // Apply styling through a CSS class if needed + arrowDiv.classList.add('tooltip-arrow'); + + // Append this div to the tooltip content + tooltip.appendChild(arrowDiv); + + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; +} + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522112202.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522112202.ts new file mode 100644 index 0000000..4b18c27 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522112202.ts @@ -0,0 +1,512 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + // Create arrow path and add it inside tooltip-content + // const arrow = document.createElementNS("http://www.w3.org/2000/svg", "path"); + // arrow.setAttribute( + // "d", + // `M ${x} ${tooltipY + tooltipHeight} L ${x} ${tooltipY + tooltipHeight - 16}` + // ); + // arrow.setAttribute("stroke", "white"); // Set the color of the line + // arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + const arrowDiv = document.createElement('div'); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; +} + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522112233.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522112233.ts new file mode 100644 index 0000000..3d40c1a --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522112233.ts @@ -0,0 +1,513 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "5"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + // Create arrow path and add it inside tooltip-content + // const arrow = document.createElementNS("http://www.w3.org/2000/svg", "path"); + // arrow.setAttribute( + // "d", + // `M ${x} ${tooltipY + tooltipHeight} L ${x} ${tooltipY + tooltipHeight - 16}` + // ); + // arrow.setAttribute("stroke", "white"); // Set the color of the line + // arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + + const arrow = document.createElement('div'); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; +} + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522112657.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522112657.ts new file mode 100644 index 0000000..d6f1677 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522112657.ts @@ -0,0 +1,513 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 20; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + // Create arrow path and add it inside tooltip-content + // const arrow = document.createElementNS("http://www.w3.org/2000/svg", "path"); + // arrow.setAttribute( + // "d", + // `M ${x} ${tooltipY + tooltipHeight} L ${x} ${tooltipY + tooltipHeight - 16}` + // ); + // arrow.setAttribute("stroke", "white"); // Set the color of the line + // arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + + const arrow = document.createElement('div'); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; +} + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522112705.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522112705.ts new file mode 100644 index 0000000..2f0cc48 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522112705.ts @@ -0,0 +1,513 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + // Create arrow path and add it inside tooltip-content + // const arrow = document.createElementNS("http://www.w3.org/2000/svg", "path"); + // arrow.setAttribute( + // "d", + // `M ${x} ${tooltipY + tooltipHeight} L ${x} ${tooltipY + tooltipHeight - 16}` + // ); + // arrow.setAttribute("stroke", "white"); // Set the color of the line + // arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + + const arrow = document.createElement('div'); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; +} + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522113133.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522113133.ts new file mode 100644 index 0000000..2414b46 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522113133.ts @@ -0,0 +1,534 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + if (dot.imageUrl) { + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Create the image element + const img = document.createElement("img"); + + // Check if link is available for the image + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_blank"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + img = link; // Use the link as the image container + } else { + img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + } + + + // img.src = dot.imageUrl; + // img.classList.add("tooltip-image"); + + // Append image to the container + imageContainer.appendChild(img); + + // Append the image container to the main div + div.appendChild(imageContainer); + } + + // Create arrow path and add it inside tooltip-content + // const arrow = document.createElementNS("http://www.w3.org/2000/svg", "path"); + // arrow.setAttribute( + // "d", + // `M ${x} ${tooltipY + tooltipHeight} L ${x} ${tooltipY + tooltipHeight - 16}` + // ); + // arrow.setAttribute("stroke", "white"); // Set the color of the line + // arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + + const arrow = document.createElement('div'); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; +} + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522113224.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522113224.ts new file mode 100644 index 0000000..7c23506 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522113224.ts @@ -0,0 +1,529 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_blank"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + + // Create arrow path and add it inside tooltip-content + // const arrow = document.createElementNS("http://www.w3.org/2000/svg", "path"); + // arrow.setAttribute( + // "d", + // `M ${x} ${tooltipY + tooltipHeight} L ${x} ${tooltipY + tooltipHeight - 16}` + // ); + // arrow.setAttribute("stroke", "white"); // Set the color of the line + // arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522113610.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522113610.ts new file mode 100644 index 0000000..9675052 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522113610.ts @@ -0,0 +1,556 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + +// Create a container div +const imageContainer = document.createElement("div"); +imageContainer.classList.add("image_container"); // Add image_container class + +// Define a variable for handling case with or without link +let imgWrapper: HTMLElement; + +if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_blank"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + +} else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper +} + +// Append imgWrapper to the container +imageContainer.appendChild(imgWrapper); + +// Append the image container to the main div +div.appendChild(imageContainer); + + + + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + + // Create arrow path and add it inside tooltip-content + // const arrow = document.createElementNS("http://www.w3.org/2000/svg", "path"); + // arrow.setAttribute( + // "d", + // `M ${x} ${tooltipY + tooltipHeight} L ${x} ${tooltipY + tooltipHeight - 16}` + // ); + // arrow.setAttribute("stroke", "white"); // Set the color of the line + // arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522113613.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522113613.ts new file mode 100644 index 0000000..47cb999 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522113613.ts @@ -0,0 +1,531 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_blank"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + + // Create arrow path and add it inside tooltip-content + // const arrow = document.createElementNS("http://www.w3.org/2000/svg", "path"); + // arrow.setAttribute( + // "d", + // `M ${x} ${tooltipY + tooltipHeight} L ${x} ${tooltipY + tooltipHeight - 16}` + // ); + // arrow.setAttribute("stroke", "white"); // Set the color of the line + // arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522113628.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522113628.ts new file mode 100644 index 0000000..c369897 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522113628.ts @@ -0,0 +1,540 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_blank"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + +} else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper +} + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + + // Create arrow path and add it inside tooltip-content + // const arrow = document.createElementNS("http://www.w3.org/2000/svg", "path"); + // arrow.setAttribute( + // "d", + // `M ${x} ${tooltipY + tooltipHeight} L ${x} ${tooltipY + tooltipHeight - 16}` + // ); + // arrow.setAttribute("stroke", "white"); // Set the color of the line + // arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522113832.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522113832.ts new file mode 100644 index 0000000..711322c --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522113832.ts @@ -0,0 +1,538 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_blank"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + // Create arrow path and add it inside tooltip-content + // const arrow = document.createElementNS("http://www.w3.org/2000/svg", "path"); + // arrow.setAttribute( + // "d", + // `M ${x} ${tooltipY + tooltipHeight} L ${x} ${tooltipY + tooltipHeight - 16}` + // ); + // arrow.setAttribute("stroke", "white"); // Set the color of the line + // arrow.setAttribute("stroke-width", "1"); // Set the line width to 1px + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522113857.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522113857.ts new file mode 100644 index 0000000..349001c --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522113857.ts @@ -0,0 +1,529 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_blank"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522130644.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522130644.ts new file mode 100644 index 0000000..cd217f8 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522130644.ts @@ -0,0 +1,529 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + style.textContent = ` + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } + `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131005.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131005.ts new file mode 100644 index 0000000..53911b5 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131005.ts @@ -0,0 +1,512 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 120; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131150.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131150.ts new file mode 100644 index 0000000..8b15f8f --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131150.ts @@ -0,0 +1,512 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131159.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131159.ts new file mode 100644 index 0000000..9a81055 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131159.ts @@ -0,0 +1,512 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 4 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131202.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131202.ts new file mode 100644 index 0000000..8b15f8f --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131202.ts @@ -0,0 +1,512 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131206.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131206.ts new file mode 100644 index 0000000..444b740 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131206.ts @@ -0,0 +1,512 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 8, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131208.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131208.ts new file mode 100644 index 0000000..2424805 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131208.ts @@ -0,0 +1,512 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 2, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131212.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131212.ts new file mode 100644 index 0000000..8b15f8f --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131212.ts @@ -0,0 +1,512 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131413.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131413.ts new file mode 100644 index 0000000..c0407b0 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131413.ts @@ -0,0 +1,512 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 4) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131415.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131415.ts new file mode 100644 index 0000000..8b15f8f --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131415.ts @@ -0,0 +1,512 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131457.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131457.ts new file mode 100644 index 0000000..77047be --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131457.ts @@ -0,0 +1,512 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "1"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131501.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131501.ts new file mode 100644 index 0000000..8b15f8f --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131501.ts @@ -0,0 +1,512 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131509.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131509.ts new file mode 100644 index 0000000..fc75b2e --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131509.ts @@ -0,0 +1,512 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.6); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131516.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131516.ts new file mode 100644 index 0000000..83711f3 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131516.ts @@ -0,0 +1,512 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 1); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131534.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131534.ts new file mode 100644 index 0000000..8b15f8f --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131534.ts @@ -0,0 +1,512 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131713.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131713.ts new file mode 100644 index 0000000..e1f37a9 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131713.ts @@ -0,0 +1,513 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 260; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131724.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131724.ts new file mode 100644 index 0000000..7103267 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131724.ts @@ -0,0 +1,513 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 160; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131749.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131749.ts new file mode 100644 index 0000000..2ed8e19 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131749.ts @@ -0,0 +1,513 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 130; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131803.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131803.ts new file mode 100644 index 0000000..006961b --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131803.ts @@ -0,0 +1,513 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 140; // Scale tension for Bezier curve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131811.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131811.ts new file mode 100644 index 0000000..eed179f --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131811.ts @@ -0,0 +1,513 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.8); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 140; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131917.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131917.ts new file mode 100644 index 0000000..0ddd0fd --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131917.ts @@ -0,0 +1,513 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.6); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 140; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131950.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131950.ts new file mode 100644 index 0000000..4b71306 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131950.ts @@ -0,0 +1,513 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.5); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 140; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131954.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131954.ts new file mode 100644 index 0000000..cb6ec9c --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131954.ts @@ -0,0 +1,513 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.4); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 140; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131959.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131959.ts new file mode 100644 index 0000000..5fd0bec --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522131959.ts @@ -0,0 +1,513 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.3); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 140; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522132013.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522132013.ts new file mode 100644 index 0000000..4b71306 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522132013.ts @@ -0,0 +1,513 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.5); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 140; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522132035.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522132035.ts new file mode 100644 index 0000000..112735f --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522132035.ts @@ -0,0 +1,513 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 2.5; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.5); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 140; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522132039.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522132039.ts new file mode 100644 index 0000000..8a01ad6 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522132039.ts @@ -0,0 +1,513 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.5; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.5); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 140; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522132042.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522132042.ts new file mode 100644 index 0000000..8f12e05 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522132042.ts @@ -0,0 +1,513 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.75; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.5); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 140; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522132047.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522132047.ts new file mode 100644 index 0000000..8a01ad6 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522132047.ts @@ -0,0 +1,513 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.5; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.5); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 140; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522132050.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522132050.ts new file mode 100644 index 0000000..226ae2e --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522132050.ts @@ -0,0 +1,513 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.5); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 140; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in a new tab + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522132342.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522132342.ts new file mode 100644 index 0000000..d0bc631 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522132342.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.5); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 140; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + } else { + console.error("Dot has no image URL"); + throw new Error("Dot has no image URL"); + } + + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522132517.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522132517.ts new file mode 100644 index 0000000..4b624e8 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522132517.ts @@ -0,0 +1,520 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.5); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 140; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + } else { + console.error("Dot has no image URL"); + throw new Error("Dot has no image URL"); + } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + if (dot.imageUrl) { + // Append the image container to the main div + div.appendChild(imageContainer); + } + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522132606.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522132606.ts new file mode 100644 index 0000000..b7ad570 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522132606.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.5); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 140; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522133122.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522133122.ts new file mode 100644 index 0000000..44396a6 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522133122.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.75); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 140; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522133129.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522133129.ts new file mode 100644 index 0000000..f8653dd --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522133129.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 140; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151345.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151345.ts new file mode 100644 index 0000000..2a466f5 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151345.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 100; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151350.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151350.ts new file mode 100644 index 0000000..dd0a30f --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151350.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 200; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151359.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151359.ts new file mode 100644 index 0000000..490f84c --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151359.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 300; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151406.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151406.ts new file mode 100644 index 0000000..2a466f5 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151406.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 100; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151421.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151421.ts new file mode 100644 index 0000000..dd0a30f --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151421.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 200; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151436.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151436.ts new file mode 100644 index 0000000..0a4e875 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151436.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * -200; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151449.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151449.ts new file mode 100644 index 0000000..1f21eae --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151449.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 1; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151453.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151453.ts new file mode 100644 index 0000000..090a043 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151453.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 500; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151603.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151603.ts new file mode 100644 index 0000000..1f21eae --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151603.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 1; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151629.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151629.ts new file mode 100644 index 0000000..090a043 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522151629.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 500; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153324.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153324.ts new file mode 100644 index 0000000..3347189 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153324.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 5) * ((this.config.height / 2) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 500; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153329.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153329.ts new file mode 100644 index 0000000..090a043 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153329.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 500; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153337.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153337.ts new file mode 100644 index 0000000..169ec98 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153337.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 1) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 500; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153342.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153342.ts new file mode 100644 index 0000000..74fdb33 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153342.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 3) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 500; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153345.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153345.ts new file mode 100644 index 0000000..090a043 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153345.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 500; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153407.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153407.ts new file mode 100644 index 0000000..23b08b1 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153407.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 1000; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153429.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153429.ts new file mode 100644 index 0000000..5c09ff4 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153429.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 2000; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153437.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153437.ts new file mode 100644 index 0000000..50cacbb --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153437.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 600; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153447.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153447.ts new file mode 100644 index 0000000..090a043 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153447.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 500; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153457.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153457.ts new file mode 100644 index 0000000..090a043 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153457.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 500; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153502.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153502.ts new file mode 100644 index 0000000..e04360f --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153502.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 400; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153506.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153506.ts new file mode 100644 index 0000000..090a043 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522153506.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 500; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522222207.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522222207.ts new file mode 100644 index 0000000..090a043 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522222207.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 500; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522222913.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522222913.ts new file mode 100644 index 0000000..efab24d --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522222913.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 250; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522222945.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522222945.ts new file mode 100644 index 0000000..090a043 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522222945.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 500; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522222952.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522222952.ts new file mode 100644 index 0000000..e04360f --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522222952.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 400; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522231943.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522231943.ts new file mode 100644 index 0000000..dd0a30f --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522231943.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 200; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/ConnectedDotsVisualization_20250522232002.ts b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522232002.ts new file mode 100644 index 0000000..090a043 --- /dev/null +++ b/dot-line-system/.history/src/ConnectedDotsVisualization_20250522232002.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 500; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/.history/src/main_20250515080205.ts b/dot-line-system/.history/src/main_20250515080205.ts new file mode 100644 index 0000000..8a942d7 --- /dev/null +++ b/dot-line-system/.history/src/main_20250515080205.ts @@ -0,0 +1,120 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -6, + imageUrl: 'https://picsum.photos/200/150?random=1', + title: 'First Point', + description: 'This is the starting point of our journey.', + link: '/page1' + }, + { + id: 2, + value: 1.2, + x: -4, + imageUrl: 'https://picsum.photos/200/150?random=2', + title: 'Rising Up', + description: 'We begin to see an upward trend here.' + }, + { + id: 3, + value: -0.6, + x: -2, + imageUrl: 'https://picsum.photos/200/150?random=3', + title: 'Minor Dip', + description: 'A small setback before the major growth.', + link: '/page3' + }, + { + id: 4, + value: 2.7, + x: 0, + imageUrl: 'https://picsum.photos/200/150?random=4', + title: 'Peak Performance', + description: 'This is our highest point so far!', + link: '/page4' + }, + { + id: 5, + value: 0.8, + x: 2, + imageUrl: 'https://picsum.photos/200/150?random=5', + title: 'Normalization', + description: 'Returning to more sustainable levels.' + }, + { + id: 6, + value: -2.9, + x: 4, + imageUrl: 'https://picsum.photos/200/150?random=6', + title: 'Major Decline', + description: 'A significant drop in our metrics.', + link: '/page6' + }, + { + id: 7, + value: 1.5, + x: 6, + imageUrl: 'https://picsum.photos/200/150?random=7', + title: 'Recovery', + description: 'Bouncing back strongly from the previous low.' + }, + { + id: 8, + value: -0.5, + x: 8, + imageUrl: 'https://picsum.photos/200/150?random=8', + title: 'Slight Dip', + description: 'A minor correction in our upward trend.', + link: '/page8' + }, + { + id: 9, + value: 2.1, + x: 10, + imageUrl: 'https://picsum.photos/200/150?random=9', + title: 'Second Peak', + description: 'Another high point in our journey.' + } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ +}); diff --git a/dot-line-system/.history/src/main_20250515093647.ts b/dot-line-system/.history/src/main_20250515093647.ts new file mode 100644 index 0000000..5e9fbe2 --- /dev/null +++ b/dot-line-system/.history/src/main_20250515093647.ts @@ -0,0 +1,120 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -6, + imageUrl: 'https://picsum.photos/200/150?random=1', + title: 'First Point', + description: 'This is the starting point of our journey.', + link: '/page1' + }, + { + id: 2, + value: 1.5, + x: -4, + imageUrl: 'https://picsum.photos/200/150?random=2', + title: 'Rising Up', + description: 'We begin to see an upward trend here.' + }, + { + id: 3, + value: -0.6, + x: -2, + imageUrl: 'https://picsum.photos/200/150?random=3', + title: 'Minor Dip', + description: 'A small setback before the major growth.', + link: '/page3' + }, + { + id: 4, + value: 2.7, + x: 0, + imageUrl: 'https://picsum.photos/200/150?random=4', + title: 'Peak Performance', + description: 'This is our highest point so far!', + link: '/page4' + }, + { + id: 5, + value: 0.8, + x: 2, + imageUrl: 'https://picsum.photos/200/150?random=5', + title: 'Normalization', + description: 'Returning to more sustainable levels.' + }, + { + id: 6, + value: -2.9, + x: 4, + imageUrl: 'https://picsum.photos/200/150?random=6', + title: 'Major Decline', + description: 'A significant drop in our metrics.', + link: '/page6' + }, + { + id: 7, + value: 1.5, + x: 6, + imageUrl: 'https://picsum.photos/200/150?random=7', + title: 'Recovery', + description: 'Bouncing back strongly from the previous low.' + }, + { + id: 8, + value: -0.5, + x: 8, + imageUrl: 'https://picsum.photos/200/150?random=8', + title: 'Slight Dip', + description: 'A minor correction in our upward trend.', + link: '/page8' + }, + { + id: 9, + value: 2.1, + x: 10, + imageUrl: 'https://picsum.photos/200/150?random=9', + title: 'Second Peak', + description: 'Another high point in our journey.' + } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ +}); diff --git a/dot-line-system/.history/src/main_20250515093655.ts b/dot-line-system/.history/src/main_20250515093655.ts new file mode 100644 index 0000000..676a346 --- /dev/null +++ b/dot-line-system/.history/src/main_20250515093655.ts @@ -0,0 +1,120 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -6, + imageUrl: 'https://picsum.photos/200/150?random=1', + title: 'First Point', + description: 'This is the starting point of our journey.', + link: '/page1' + }, + { + id: 2, + value: 1.0, + x: -4, + imageUrl: 'https://picsum.photos/200/150?random=2', + title: 'Rising Up', + description: 'We begin to see an upward trend here.' + }, + { + id: 3, + value: -0.6, + x: -2, + imageUrl: 'https://picsum.photos/200/150?random=3', + title: 'Minor Dip', + description: 'A small setback before the major growth.', + link: '/page3' + }, + { + id: 4, + value: 2.7, + x: 0, + imageUrl: 'https://picsum.photos/200/150?random=4', + title: 'Peak Performance', + description: 'This is our highest point so far!', + link: '/page4' + }, + { + id: 5, + value: 0.8, + x: 2, + imageUrl: 'https://picsum.photos/200/150?random=5', + title: 'Normalization', + description: 'Returning to more sustainable levels.' + }, + { + id: 6, + value: -2.9, + x: 4, + imageUrl: 'https://picsum.photos/200/150?random=6', + title: 'Major Decline', + description: 'A significant drop in our metrics.', + link: '/page6' + }, + { + id: 7, + value: 1.5, + x: 6, + imageUrl: 'https://picsum.photos/200/150?random=7', + title: 'Recovery', + description: 'Bouncing back strongly from the previous low.' + }, + { + id: 8, + value: -0.5, + x: 8, + imageUrl: 'https://picsum.photos/200/150?random=8', + title: 'Slight Dip', + description: 'A minor correction in our upward trend.', + link: '/page8' + }, + { + id: 9, + value: 2.1, + x: 10, + imageUrl: 'https://picsum.photos/200/150?random=9', + title: 'Second Peak', + description: 'Another high point in our journey.' + } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ +}); diff --git a/dot-line-system/.history/src/main_20250515093704.ts b/dot-line-system/.history/src/main_20250515093704.ts new file mode 100644 index 0000000..8a942d7 --- /dev/null +++ b/dot-line-system/.history/src/main_20250515093704.ts @@ -0,0 +1,120 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -6, + imageUrl: 'https://picsum.photos/200/150?random=1', + title: 'First Point', + description: 'This is the starting point of our journey.', + link: '/page1' + }, + { + id: 2, + value: 1.2, + x: -4, + imageUrl: 'https://picsum.photos/200/150?random=2', + title: 'Rising Up', + description: 'We begin to see an upward trend here.' + }, + { + id: 3, + value: -0.6, + x: -2, + imageUrl: 'https://picsum.photos/200/150?random=3', + title: 'Minor Dip', + description: 'A small setback before the major growth.', + link: '/page3' + }, + { + id: 4, + value: 2.7, + x: 0, + imageUrl: 'https://picsum.photos/200/150?random=4', + title: 'Peak Performance', + description: 'This is our highest point so far!', + link: '/page4' + }, + { + id: 5, + value: 0.8, + x: 2, + imageUrl: 'https://picsum.photos/200/150?random=5', + title: 'Normalization', + description: 'Returning to more sustainable levels.' + }, + { + id: 6, + value: -2.9, + x: 4, + imageUrl: 'https://picsum.photos/200/150?random=6', + title: 'Major Decline', + description: 'A significant drop in our metrics.', + link: '/page6' + }, + { + id: 7, + value: 1.5, + x: 6, + imageUrl: 'https://picsum.photos/200/150?random=7', + title: 'Recovery', + description: 'Bouncing back strongly from the previous low.' + }, + { + id: 8, + value: -0.5, + x: 8, + imageUrl: 'https://picsum.photos/200/150?random=8', + title: 'Slight Dip', + description: 'A minor correction in our upward trend.', + link: '/page8' + }, + { + id: 9, + value: 2.1, + x: 10, + imageUrl: 'https://picsum.photos/200/150?random=9', + title: 'Second Peak', + description: 'Another high point in our journey.' + } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ +}); diff --git a/dot-line-system/.history/src/main_20250515093739.ts b/dot-line-system/.history/src/main_20250515093739.ts new file mode 100644 index 0000000..a19b572 --- /dev/null +++ b/dot-line-system/.history/src/main_20250515093739.ts @@ -0,0 +1,121 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -6, + imageUrl: 'https://picsum.photos/200/150?random=1', + title: 'First Point', + description: 'This is the starting point of our journey.', + link: '/page1' + }, + { + id: 2, + value: 1.2, + x: -4, + imageUrl: 'https://picsum.photos/200/150?random=2', + title: 'Rising Up', + description: 'We begin to see an upward trend here.' + }, + { + id: 3, + value: -0.6, + x: -2, + imageUrl: 'https://picsum.photos/200/150?random=3', + title: 'Minor Dip', + description: 'A small setback before the major growth.', + link: '/page3' + }, + { + id: 4, + value: 2.7, + x: 0, + imageUrl: 'https://picsum.photos/200/150?random=4', + title: 'Peak Performance', + description: 'This is our highest point so far!', + link: '/page4' + }, + { + id: 5, + value: 0.8, + x: 2, + imageUrl: 'https://picsum.photos/200/150?random=5', + title: 'Normalization', + description: 'Returning to more sustainable levels.' + }, + { + id: 6, + value: -2.9, + x: 4, + imageUrl: 'https://picsum.photos/200/150?random=6', + title: 'Major Decline', + description: 'A significant drop in our metrics.', + link: '/page6' + }, + { + id: 7, + value: 1.5, + x: 6, + imageUrl: 'https://picsum.photos/200/150?random=7', + title: 'Recovery', + description: 'Bouncing back strongly from the previous low.' + }, + { + id: 8, + //value: -0.5, + value: 1, + x: 8, + imageUrl: 'https://picsum.photos/200/150?random=8', + title: 'Slight Dip', + description: 'A minor correction in our upward trend.', + link: '/page8' + }, + { + id: 9, + value: 2.1, + x: 10, + imageUrl: 'https://picsum.photos/200/150?random=9', + title: 'Second Peak', + description: 'Another high point in our journey.' + } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ +}); diff --git a/dot-line-system/.history/src/main_20250515093749.ts b/dot-line-system/.history/src/main_20250515093749.ts new file mode 100644 index 0000000..bf12248 --- /dev/null +++ b/dot-line-system/.history/src/main_20250515093749.ts @@ -0,0 +1,121 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -6, + imageUrl: 'https://picsum.photos/200/150?random=1', + title: 'First Point', + description: 'This is the starting point of our journey.', + link: '/page1' + }, + { + id: 2, + value: 1.2, + x: -4, + imageUrl: 'https://picsum.photos/200/150?random=2', + title: 'Rising Up', + description: 'We begin to see an upward trend here.' + }, + { + id: 3, + value: -0.6, + x: -2, + imageUrl: 'https://picsum.photos/200/150?random=3', + title: 'Minor Dip', + description: 'A small setback before the major growth.', + link: '/page3' + }, + { + id: 4, + value: 2.7, + x: 0, + imageUrl: 'https://picsum.photos/200/150?random=4', + title: 'Peak Performance', + description: 'This is our highest point so far!', + link: '/page4' + }, + { + id: 5, + value: 0.8, + x: 2, + imageUrl: 'https://picsum.photos/200/150?random=5', + title: 'Normalization', + description: 'Returning to more sustainable levels.' + }, + { + id: 6, + value: -2.9, + x: 4, + imageUrl: 'https://picsum.photos/200/150?random=6', + title: 'Major Decline', + description: 'A significant drop in our metrics.', + link: '/page6' + }, + { + id: 7, + value: 1.5, + x: 6, + imageUrl: 'https://picsum.photos/200/150?random=7', + title: 'Recovery', + description: 'Bouncing back strongly from the previous low.' + }, + { + id: 8, + //value: -0.5, + value: 0.25, + x: 8, + imageUrl: 'https://picsum.photos/200/150?random=8', + title: 'Slight Dip', + description: 'A minor correction in our upward trend.', + link: '/page8' + }, + { + id: 9, + value: 2.1, + x: 10, + imageUrl: 'https://picsum.photos/200/150?random=9', + title: 'Second Peak', + description: 'Another high point in our journey.' + } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ +}); diff --git a/dot-line-system/.history/src/main_20250515093755.ts b/dot-line-system/.history/src/main_20250515093755.ts new file mode 100644 index 0000000..65a2ee2 --- /dev/null +++ b/dot-line-system/.history/src/main_20250515093755.ts @@ -0,0 +1,121 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -6, + imageUrl: 'https://picsum.photos/200/150?random=1', + title: 'First Point', + description: 'This is the starting point of our journey.', + link: '/page1' + }, + { + id: 2, + value: 1.2, + x: -4, + imageUrl: 'https://picsum.photos/200/150?random=2', + title: 'Rising Up', + description: 'We begin to see an upward trend here.' + }, + { + id: 3, + value: -0.6, + x: -2, + imageUrl: 'https://picsum.photos/200/150?random=3', + title: 'Minor Dip', + description: 'A small setback before the major growth.', + link: '/page3' + }, + { + id: 4, + value: 2.7, + x: 0, + imageUrl: 'https://picsum.photos/200/150?random=4', + title: 'Peak Performance', + description: 'This is our highest point so far!', + link: '/page4' + }, + { + id: 5, + value: 0.8, + x: 2, + imageUrl: 'https://picsum.photos/200/150?random=5', + title: 'Normalization', + description: 'Returning to more sustainable levels.' + }, + { + id: 6, + value: -2.9, + x: 4, + imageUrl: 'https://picsum.photos/200/150?random=6', + title: 'Major Decline', + description: 'A significant drop in our metrics.', + link: '/page6' + }, + { + id: 7, + value: 1.5, + x: 6, + imageUrl: 'https://picsum.photos/200/150?random=7', + title: 'Recovery', + description: 'Bouncing back strongly from the previous low.' + }, + { + id: 8, + //value: -0.5, + value: -2, + x: 8, + imageUrl: 'https://picsum.photos/200/150?random=8', + title: 'Slight Dip', + description: 'A minor correction in our upward trend.', + link: '/page8' + }, + { + id: 9, + value: 2.1, + x: 10, + imageUrl: 'https://picsum.photos/200/150?random=9', + title: 'Second Peak', + description: 'Another high point in our journey.' + } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ +}); diff --git a/dot-line-system/.history/src/main_20250515093801.ts b/dot-line-system/.history/src/main_20250515093801.ts new file mode 100644 index 0000000..ef4c9df --- /dev/null +++ b/dot-line-system/.history/src/main_20250515093801.ts @@ -0,0 +1,121 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -6, + imageUrl: 'https://picsum.photos/200/150?random=1', + title: 'First Point', + description: 'This is the starting point of our journey.', + link: '/page1' + }, + { + id: 2, + value: 1.2, + x: -4, + imageUrl: 'https://picsum.photos/200/150?random=2', + title: 'Rising Up', + description: 'We begin to see an upward trend here.' + }, + { + id: 3, + value: -0.6, + x: -2, + imageUrl: 'https://picsum.photos/200/150?random=3', + title: 'Minor Dip', + description: 'A small setback before the major growth.', + link: '/page3' + }, + { + id: 4, + value: 2.7, + x: 0, + imageUrl: 'https://picsum.photos/200/150?random=4', + title: 'Peak Performance', + description: 'This is our highest point so far!', + link: '/page4' + }, + { + id: 5, + value: 0.8, + x: 2, + imageUrl: 'https://picsum.photos/200/150?random=5', + title: 'Normalization', + description: 'Returning to more sustainable levels.' + }, + { + id: 6, + value: -2.9, + x: 4, + imageUrl: 'https://picsum.photos/200/150?random=6', + title: 'Major Decline', + description: 'A significant drop in our metrics.', + link: '/page6' + }, + { + id: 7, + value: 1.5, + x: 6, + imageUrl: 'https://picsum.photos/200/150?random=7', + title: 'Recovery', + description: 'Bouncing back strongly from the previous low.' + }, + { + id: 8, + //value: -0.5, + value: -1, + x: 8, + imageUrl: 'https://picsum.photos/200/150?random=8', + title: 'Slight Dip', + description: 'A minor correction in our upward trend.', + link: '/page8' + }, + { + id: 9, + value: 2.1, + x: 10, + imageUrl: 'https://picsum.photos/200/150?random=9', + title: 'Second Peak', + description: 'Another high point in our journey.' + } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ +}); diff --git a/dot-line-system/.history/src/main_20250515093807.ts b/dot-line-system/.history/src/main_20250515093807.ts new file mode 100644 index 0000000..3723c3a --- /dev/null +++ b/dot-line-system/.history/src/main_20250515093807.ts @@ -0,0 +1,121 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -6, + imageUrl: 'https://picsum.photos/200/150?random=1', + title: 'First Point', + description: 'This is the starting point of our journey.', + link: '/page1' + }, + { + id: 2, + value: 1.2, + x: -4, + imageUrl: 'https://picsum.photos/200/150?random=2', + title: 'Rising Up', + description: 'We begin to see an upward trend here.' + }, + { + id: 3, + value: -0.6, + x: -2, + imageUrl: 'https://picsum.photos/200/150?random=3', + title: 'Minor Dip', + description: 'A small setback before the major growth.', + link: '/page3' + }, + { + id: 4, + value: 2.7, + x: 0, + imageUrl: 'https://picsum.photos/200/150?random=4', + title: 'Peak Performance', + description: 'This is our highest point so far!', + link: '/page4' + }, + { + id: 5, + value: 0.8, + x: 2, + imageUrl: 'https://picsum.photos/200/150?random=5', + title: 'Normalization', + description: 'Returning to more sustainable levels.' + }, + { + id: 6, + value: -2.9, + x: 4, + imageUrl: 'https://picsum.photos/200/150?random=6', + title: 'Major Decline', + description: 'A significant drop in our metrics.', + link: '/page6' + }, + { + id: 7, + value: 1.5, + x: 6, + imageUrl: 'https://picsum.photos/200/150?random=7', + title: 'Recovery', + description: 'Bouncing back strongly from the previous low.' + }, + { + id: 8, + //value: -0.5, + value: 0, + x: 8, + imageUrl: 'https://picsum.photos/200/150?random=8', + title: 'Slight Dip', + description: 'A minor correction in our upward trend.', + link: '/page8' + }, + { + id: 9, + value: 2.1, + x: 10, + imageUrl: 'https://picsum.photos/200/150?random=9', + title: 'Second Peak', + description: 'Another high point in our journey.' + } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ +}); diff --git a/dot-line-system/.history/src/main_20250522082517.ts b/dot-line-system/.history/src/main_20250522082517.ts new file mode 100644 index 0000000..0282657 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522082517.ts @@ -0,0 +1,198 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -6, + imageUrl: 'https://picsum.photos/200/150?random=1', + title: 'First Point', + description: 'This is the starting point of our journey.', + link: '/page1' + }, + { + id: 2, + value: 1.2, + x: -4, + imageUrl: 'https://picsum.photos/200/150?random=2', + title: 'Rising Up', + description: 'We begin to see an upward trend here.' + }, + { + id: 3, + value: -0.6, + x: -2, + imageUrl: 'https://picsum.photos/200/150?random=3', + title: 'Minor Dip', + description: 'A small setback before the major growth.', + link: '/page3' + }, + { + id: 4, + value: 2.7, + x: 0, + imageUrl: 'https://picsum.photos/200/150?random=4', + title: 'Peak Performance', + description: 'This is our highest point so far!', + link: '/page4' + }, + { + id: 5, + value: 0.8, + x: 2, + imageUrl: 'https://picsum.photos/200/150?random=5', + title: 'Normalization', + description: 'Returning to more sustainable levels.' + }, + { + id: 6, + value: -2.9, + x: 4, + imageUrl: 'https://picsum.photos/200/150?random=6', + title: 'Major Decline', + description: 'A significant drop in our metrics.', + link: '/page6' + }, + { + id: 7, + value: 1.5, + x: 6, + imageUrl: 'https://picsum.photos/200/150?random=7', + title: 'Recovery', + description: 'Bouncing back strongly from the previous low.' + }, + { + id: 8, + //value: -0.5, + value: 0, + x: 8, + imageUrl: 'https://picsum.photos/200/150?random=8', + title: 'Slight Dip', + description: 'A minor correction in our upward trend.', + link: '/page8' + }, + { + id: 9, + value: 2.1, + x: 10, + imageUrl: 'https://picsum.photos/200/150?random=9', + title: 'Second Peak', + description: 'Another high point in our journey.' + },{ + id: 1, + value: -1.8, + x: -6, + imageUrl: 'https://picsum.photos/200/150?random=1', + title: 'First Point', + description: 'This is the starting point of our journey.', + link: '/page1' + }, + { + id: 2, + value: 1.2, + x: -4, + imageUrl: 'https://picsum.photos/200/150?random=2', + title: 'Rising Up', + description: 'We begin to see an upward trend here.' + }, + { + id: 3, + value: -0.6, + x: -2, + imageUrl: 'https://picsum.photos/200/150?random=3', + title: 'Minor Dip', + description: 'A small setback before the major growth.', + link: '/page3' + }, + { + id: 4, + value: 2.7, + x: 0, + imageUrl: 'https://picsum.photos/200/150?random=4', + title: 'Peak Performance', + description: 'This is our highest point so far!', + link: '/page4' + }, + { + id: 5, + value: 0.8, + x: 2, + imageUrl: 'https://picsum.photos/200/150?random=5', + title: 'Normalization', + description: 'Returning to more sustainable levels.' + }, + { + id: 6, + value: -2.9, + x: 4, + imageUrl: 'https://picsum.photos/200/150?random=6', + title: 'Major Decline', + description: 'A significant drop in our metrics.', + link: '/page6' + }, + { + id: 7, + value: 1.5, + x: 6, + imageUrl: 'https://picsum.photos/200/150?random=7', + title: 'Recovery', + description: 'Bouncing back strongly from the previous low.' + }, + { + id: 8, + //value: -0.5, + value: 0, + x: 8, + imageUrl: 'https://picsum.photos/200/150?random=8', + title: 'Slight Dip', + description: 'A minor correction in our upward trend.', + link: '/page8' + }, + { + id: 9, + value: 2.1, + x: 10, + imageUrl: 'https://picsum.photos/200/150?random=9', + title: 'Second Peak', + description: 'Another high point in our journey.' + } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ +}); diff --git a/dot-line-system/.history/src/main_20250522082653.ts b/dot-line-system/.history/src/main_20250522082653.ts new file mode 100644 index 0000000..2f08cdd --- /dev/null +++ b/dot-line-system/.history/src/main_20250522082653.ts @@ -0,0 +1,66 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + const data = [ + { id: 1, value: -1.8, x: -6, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'First Point', description: 'This is the starting point of our journey.', link: '/page1' }, + { id: 2, value: 1.2, x: -4, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Rising Up', description: 'We begin to see an upward trend here.' }, + { id: 3, value: -0.6, x: -2, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Minor Dip', description: 'A small setback before the major growth.', link: '/page3' }, + { id: 4, value: 2.7, x: 0, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Peak Performance', description: 'This is our highest point so far!', link: '/page4' }, + { id: 5, value: 0.8, x: 2, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Normalization', description: 'Returning to more sustainable levels.' }, + { id: 6, value: -2.9, x: 4, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Major Decline', description: 'A significant drop in our metrics.', link: '/page6' }, + { id: 7, value: 1.5, x: 6, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Recovery', description: 'Bouncing back strongly from the previous low.' }, + { id: 8, value: 0, x: 8, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Slight Dip', description: 'A minor correction in our upward trend.', link: '/page8' }, + { id: 9, value: 2.1, x: 10, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Second Peak', description: 'Another high point in our journey.' }, + { id: 10, value: -1.8, x: -6, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'First Point Duplicate', description: 'This is a duplicate entry of our starting point.', link: '/page1' }, + { id: 11, value: 1.2, x: -4, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Rising Up Duplicate', description: 'Duplicate entry of the upward trend.' }, + { id: 12, value: -0.6, x: -2, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Minor Dip Duplicate', description: 'Duplicate entry of the minor dip.', link: '/page3' }, + { id: 13, value: 2.7, x: 0, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Peak Performance Duplicate', description: 'Duplicate entry of our highest point.', link: '/page4' }, + { id: 14, value: 0.8, x: 2, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Normalization Duplicate', description: 'Duplicate entry of the normalization stage.' }, + { id: 15, value: -2.9, x: 4, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Major Decline Duplicate', description: 'Duplicate entry of the major decline.', link: '/page6' }, + { id: 16, value: 1.5, x: 6, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Recovery Duplicate', description: 'Duplicate entry of the recovery phase.' }, + { id: 17, value: 0, x: 8, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Slight Dip Duplicate', description: 'Duplicate entry of the slight dip.', link: '/page8' }, + { id: 18, value: 2.1, x: 10, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Second Peak Duplicate', description: 'Duplicate entry of the second peak.' } + ]; + + console.log(data); + +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ +}); diff --git a/dot-line-system/.history/src/main_20250522082725.ts b/dot-line-system/.history/src/main_20250522082725.ts new file mode 100644 index 0000000..5b875d4 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522082725.ts @@ -0,0 +1,61 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -6, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'First Point', description: 'This is the starting point of our journey.', link: '/page1' }, + { id: 2, value: 1.2, x: -4, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Rising Up', description: 'We begin to see an upward trend here.' }, + { id: 3, value: -0.6, x: -2, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Minor Dip', description: 'A small setback before the major growth.', link: '/page3' }, + { id: 4, value: 2.7, x: 0, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Peak Performance', description: 'This is our highest point so far!', link: '/page4' }, + { id: 5, value: 0.8, x: 2, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Normalization', description: 'Returning to more sustainable levels.' }, + { id: 6, value: -2.9, x: 4, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Major Decline', description: 'A significant drop in our metrics.', link: '/page6' }, + { id: 7, value: 1.5, x: 6, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Recovery', description: 'Bouncing back strongly from the previous low.' }, + { id: 8, value: 0, x: 8, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Slight Dip', description: 'A minor correction in our upward trend.', link: '/page8' }, + { id: 9, value: 2.1, x: 10, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Second Peak', description: 'Another high point in our journey.' }, + { id: 10, value: -1.8, x: -6, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'First Point Duplicate', description: 'This is a duplicate entry of our starting point.', link: '/page1' }, + { id: 11, value: 1.2, x: -4, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Rising Up Duplicate', description: 'Duplicate entry of the upward trend.' }, + { id: 12, value: -0.6, x: -2, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Minor Dip Duplicate', description: 'Duplicate entry of the minor dip.', link: '/page3' }, + { id: 13, value: 2.7, x: 0, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Peak Performance Duplicate', description: 'Duplicate entry of our highest point.', link: '/page4' }, + { id: 14, value: 0.8, x: 2, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Normalization Duplicate', description: 'Duplicate entry of the normalization stage.' }, + { id: 15, value: -2.9, x: 4, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Major Decline Duplicate', description: 'Duplicate entry of the major decline.', link: '/page6' }, + { id: 16, value: 1.5, x: 6, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Recovery Duplicate', description: 'Duplicate entry of the recovery phase.' }, + { id: 17, value: 0, x: 8, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Slight Dip Duplicate', description: 'Duplicate entry of the slight dip.', link: '/page8' }, + { id: 18, value: 2.1, x: 10, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Second Peak Duplicate', description: 'Duplicate entry of the second peak.' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ +}); diff --git a/dot-line-system/.history/src/main_20250522082823.ts b/dot-line-system/.history/src/main_20250522082823.ts new file mode 100644 index 0000000..4d51cfd --- /dev/null +++ b/dot-line-system/.history/src/main_20250522082823.ts @@ -0,0 +1,61 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -10, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'First Point', description: 'This is the starting point of our journey.', link: '/page1' }, + { id: 2, value: 1.2, x: -8, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Rising Up', description: 'We begin to see an upward trend here.' }, + { id: 3, value: -0.6, x: -6, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Minor Dip', description: 'A small setback before the major growth.', link: '/page3' }, + { id: 4, value: 2.7, x: -4, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Peak Performance', description: 'This is our highest point so far!', link: '/page4' }, + { id: 5, value: 0.8, x: -2, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Normalization', description: 'Returning to more sustainable levels.' }, + { id: 6, value: -2.9, x: 0, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Major Decline', description: 'A significant drop in our metrics.', link: '/page6' }, + { id: 7, value: 1.5, x: 2, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Recovery', description: 'Bouncing back strongly from the previous low.' }, + { id: 8, value: 0, x: 4, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Slight Dip', description: 'A minor correction in our upward trend.', link: '/page8' }, + { id: 9, value: 2.1, x: 6, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Second Peak', description: 'Another high point in our journey.' }, + { id: 10, value: -1.8, x: 8, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'First Point Duplicate', description: 'This is a duplicate entry of our starting point.', link: '/page1' }, + { id: 11, value: 1.2, x: 10, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Rising Up Duplicate', description: 'Duplicate entry of the upward trend.' }, + { id: 12, value: -0.6, x: 12, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Minor Dip Duplicate', description: 'Duplicate entry of the minor dip.', link: '/page3' }, + { id: 13, value: 2.7, x: 14, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Peak Performance Duplicate', description: 'Duplicate entry of our highest point.', link: '/page4' }, + { id: 14, value: 0.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Normalization Duplicate', description: 'Duplicate entry of the normalization stage.' }, + { id: 15, value: -2.9, x: 18, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Major Decline Duplicate', description: 'Duplicate entry of the major decline.', link: '/page6' }, + { id: 16, value: 1.5, x: 20, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Recovery Duplicate', description: 'Duplicate entry of the recovery phase.' }, + { id: 17, value: 0, x: 22, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Slight Dip Duplicate', description: 'Duplicate entry of the slight dip.', link: '/page8' }, + { id: 18, value: 2.1, x: 24, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Second Peak Duplicate', description: 'Duplicate entry of the second peak.' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ +}); diff --git a/dot-line-system/.history/src/main_20250522083059.ts b/dot-line-system/.history/src/main_20250522083059.ts new file mode 100644 index 0000000..5dc1e7e --- /dev/null +++ b/dot-line-system/.history/src/main_20250522083059.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -10, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'First Point', description: 'This is the starting point of our journey.', link: '/page1' }, + { id: 2, value: 1.2, x: -8, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Rising Up', description: 'We begin to see an upward trend here.' }, + { id: 3, value: -0.6, x: -6, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Minor Dip', description: 'A small setback before the major growth.', link: '/page3' }, + { id: 4, value: 2.7, x: -4, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Peak Performance', description: 'This is our highest point so far!', link: '/page4' }, + { id: 5, value: 0.8, x: -2, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Normalization', description: 'Returning to more sustainable levels.' }, + { id: 6, value: -2.9, x: 0, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Major Decline', description: 'A significant drop in our metrics.', link: '/page6' }, + { id: 7, value: 1.5, x: 2, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Recovery', description: 'Bouncing back strongly from the previous low.' }, + { id: 8, value: 0, x: 4, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Slight Dip', description: 'A minor correction in our upward trend.', link: '/page8' }, + { id: 9, value: 2.1, x: 6, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Second Peak', description: 'Another high point in our journey.' }, + { id: 10, value: -1.8, x: 8, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'First Point Duplicate', description: 'This is a duplicate entry of our starting point.', link: '/page1' }, + { id: 11, value: 1.2, x: 10, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Rising Up Duplicate', description: 'Duplicate entry of the upward trend.' }, + { id: 12, value: -0.6, x: 12, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Minor Dip Duplicate', description: 'Duplicate entry of the minor dip.', link: '/page3' }, + { id: 13, value: 2.7, x: 14, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Peak Performance Duplicate', description: 'Duplicate entry of our highest point.', link: '/page4' }, + { id: 14, value: 0.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Normalization Duplicate', description: 'Duplicate entry of the normalization stage.' }, + { id: 15, value: -2.9, x: 18, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Major Decline Duplicate', description: 'Duplicate entry of the major decline.', link: '/page6' }, + { id: 16, value: 1.5, x: 20, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Recovery Duplicate', description: 'Duplicate entry of the recovery phase.' }, + { id: 17, value: 0, x: 22, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Slight Dip Duplicate', description: 'Duplicate entry of the slight dip.', link: '/page8' }, + { id: 18, value: 2.1, x: 24, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Second Peak Duplicate', description: 'Duplicate entry of the second peak.' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522084926.ts b/dot-line-system/.history/src/main_20250522084926.ts new file mode 100644 index 0000000..f4c63cb --- /dev/null +++ b/dot-line-system/.history/src/main_20250522084926.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -10, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Beginn des Abenteuers', description: '01.10.2024', link: '/page1' }, +{ id: 2, value: 1.2, x: -8, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Neuanfang', description: '02.10.2024' }, +{ id: 3, value: -0.6, x: -6, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Kleiner Rückschlag', description: '03.10.2024', link: '/page3' }, +{ id: 4, value: 2.7, x: -4, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Höhepunkt', description: '04.10.2024', link: '/page4' }, +{ id: 5, value: 0.8, x: -2, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Rückkehr zur Normalität', description: '05.10.2024' }, +{ id: 6, value: -2.9, x: 0, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Großer Rückgang', description: '06.10.2024', link: '/page6' }, +{ id: 7, value: 1.5, x: 2, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Erholung', description: '07.10.2024' }, +{ id: 8, value: 0, x: 4, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Leichter Rückgang', description: '08.10.2024', link: '/page8' }, +{ id: 9, value: 2.1, x: 6, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Zweiter Höhepunkt', description: '09.10.2024' }, +{ id: 10, value: -1.8, x: 8, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Beginn des Abenteuers (Wiederholung)', description: '10.10.2024', link: '/page1' }, +{ id: 11, value: 1.2, x: 10, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Neuanfang (Wiederholung)', description: '11.10.2024' }, +{ id: 12, value: -0.6, x: 12, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Kleiner Rückschlag (Wiederholung)', description: '12.10.2024', link: '/page3' }, +{ id: 13, value: 2.7, x: 14, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Höhepunkt (Wiederholung)', description: '13.10.2024', link: '/page4' }, +{ id: 14, value: 0.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Rückkehr zur Normalität (Wiederholung)', description: '14.10.2024' }, +{ id: 15, value: -2.9, x: 18, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Großer Rückgang (Wiederholung)', description: '15.10.2024', link: '/page6' }, +{ id: 16, value: 1.5, x: 20, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Erholung (Wiederholung)', description: '16.10.2024' }, +{ id: 17, value: 0, x: 22, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Leichter Rückgang (Wiederholung)', description: '17.10.2024', link: '/page8' }, +{ id: 18, value: 2.1, x: 24, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Zweiter Höhepunkt (Wiederholung)', description: '18.10.2024' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522085045.ts b/dot-line-system/.history/src/main_20250522085045.ts new file mode 100644 index 0000000..094e55e --- /dev/null +++ b/dot-line-system/.history/src/main_20250522085045.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -10, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, +{ id: 2, value: 1.2, x: -8, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Omas Geburtstag', description: '02.10.2024' }, +{ id: 3, value: -0.6, x: -6, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, +{ id: 4, value: 2.7, x: -4, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Wanderung in den Bergen', description: '04.10.2024', link: '/page4' }, +{ id: 5, value: 0.8, x: -2, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Ruhiger Tag zu Hause', description: '05.10.2024' }, +{ id: 6, value: -2.9, x: 0, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Unverhoffter Krankentag', description: '06.10.2024', link: '/page6' }, +{ id: 7, value: 1.5, x: 2, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Erholungsausflug zum See', description: '07.10.2024' }, +{ id: 8, value: 0, x: 4, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, +{ id: 9, value: 2.1, x: 6, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024' }, +{ id: 10, value: -1.8, x: 8, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page1' }, +{ id: 11, value: 1.2, x: 10, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024' }, +{ id: 12, value: -0.6, x: 12, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page3' }, +{ id: 13, value: 2.7, x: 14, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page4' }, +{ id: 14, value: 0.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung bei einem Buch', description: '14.10.2024' }, +{ id: 15, value: -2.9, x: 18, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page6' }, +{ id: 16, value: 1.5, x: 20, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Shoppingtag in der Stadt', description: '16.10.2024' }, +{ id: 17, value: 0, x: 22, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Spaziergang im Park', description: '17.10.2024', link: '/page8' }, +{ id: 18, value: 2.1, x: 24, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522085108.ts b/dot-line-system/.history/src/main_20250522085108.ts new file mode 100644 index 0000000..967f927 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522085108.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -10, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, +{ id: 2, value: 1.2, x: -8, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Omas Geburtstag', description: '02.10.2024' }, +{ id: 3, value: -0.6, x: -6, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, +{ id: 4, value: 2.7, x: -4, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Wanderung in den Bergen', description: '04.10.2024', link: '/page4' }, +{ id: 5, value: 0.8, x: -2, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Ruhiger Tag zu Hause', description: '05.10.2024' }, +{ id: 6, value: -2.9, x: 0, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Unverhoffter Krankentag', description: '06.10.2024', link: '/page6' }, +{ id: 7, value: 1.5, x: 2, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Erholungsausflug zum See', description: '07.10.2024' }, +{ id: 8, value: 0, x: 4, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, +{ id: 9, value: 2.1, x: 6, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024' }, +{ id: 10, value: -1.8, x: 8, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page1' }, +{ id: 11, value: 1.2, x: 10, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024' }, +{ id: 12, value: -0.6, x: 12, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page3' }, +{ id: 13, value: 2.7, x: 14, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page4' }, +{ id: 14, value: 0.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024' }, +{ id: 15, value: -2.9, x: 18, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page6' }, +{ id: 16, value: 1.5, x: 20, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Shoppingtag in der Stadt', description: '16.10.2024' }, +{ id: 17, value: 0, x: 22, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Spaziergang im Park', description: '17.10.2024', link: '/page8' }, +{ id: 18, value: 2.1, x: 24, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522085117.ts b/dot-line-system/.history/src/main_20250522085117.ts new file mode 100644 index 0000000..cb2f5c9 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522085117.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -10, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, +{ id: 2, value: 1.2, x: -8, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Omas Geburtstag', description: '02.10.2024' }, +{ id: 3, value: -0.6, x: -6, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, +{ id: 4, value: 2.7, x: -4, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Wanderung in den Bergen', description: '04.10.2024', link: '/page4' }, +{ id: 5, value: 0.8, x: -2, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Ruhiger Tag zu Hause', description: '05.10.2024' }, +{ id: 6, value: -2.9, x: 0, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Unverhoffter Krankentag', description: '06.10.2024', link: '/page6' }, +{ id: 7, value: 1.5, x: 2, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Erholungsausflug zum See', description: '07.10.2024' }, +{ id: 8, value: 0, x: 4, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, +{ id: 9, value: 2.1, x: 6, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024' }, +{ id: 10, value: -1.8, x: 8, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page1' }, +{ id: 11, value: 1.2, x: 10, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024' }, +{ id: 12, value: -0.6, x: 12, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page3' }, +{ id: 13, value: 2.7, x: 14, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page4' }, +{ id: 14, value: 0.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024' }, +{ id: 15, value: -2.9, x: 18, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page6' }, +{ id: 16, value: 1.5, x: 20, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Shoppingtag in der Stadt', description: '16.10.2024' }, +{ id: 17, value: 0, x: 22, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page8' }, +{ id: 18, value: 2.1, x: 24, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522085138.ts b/dot-line-system/.history/src/main_20250522085138.ts new file mode 100644 index 0000000..1c17c30 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522085138.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -10, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: -8, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Omas Geburtstag', description: '02.10.2024' }, + { id: 3, value: -0.6, x: -6, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.7, x: -4, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Wanderung in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: -2, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Ruhiger Tag zu Hause', description: '05.10.2024' }, + { id: 6, value: -2.9, x: 0, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Unverhoffter Krankentag', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 2, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Erholungsausflug zum See', description: '07.10.2024' }, + { id: 8, value: 0, x: 4, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 2.1, x: 6, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024' }, + { id: 10, value: -1.8, x: 8, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page1' }, + { id: 11, value: 1.2, x: 10, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024' }, + { id: 12, value: -0.6, x: 12, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page3' }, + { id: 13, value: 2.7, x: 14, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page4' }, + { id: 14, value: 0.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024' }, + { id: 15, value: -2.9, x: 18, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page6' }, + { id: 16, value: 1.5, x: 20, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Shoppingtag in der Stadt', description: '16.10.2024' }, + { id: 17, value: 0, x: 22, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page8' }, + { id: 18, value: 2.1, x: 24, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522085307.ts b/dot-line-system/.history/src/main_20250522085307.ts new file mode 100644 index 0000000..4703cc4 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522085307.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -10, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: -8, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Omas Geburtstag', description: '02.10.2024' }, + { id: 3, value: -0.6, x: -6, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.7, x: -4, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Wanderung in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: -2, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Ruhiger Tag zu Hause', description: '05.10.2024' }, + { id: 6, value: -2.9, x: 0, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Unverhoffter Krankentag', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 2, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Erholungsausflug zum See', description: '07.10.2024' }, + { id: 8, value: 0, x: 4, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 2.1, x: 6, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024' }, + { id: 10, value: -1.8, x: 8, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page1' }, + { id: 11, value: 1.2, x: 10, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024' }, + { id: 12, value: -0.6, x: 12, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page3' }, + { id: 13, value: 2.7, x: 14, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page4' }, + { id: 14, value: 0.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024' }, + { id: 15, value: -2.9, x: 18, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page6' }, + { id: 16, value: 1.5, x: 20, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Shoppingtag in der Stadt', description: '16.10.2024' }, + { id: 17, value: 0, x: 22, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page8' }, + { id: 18, value: 2.1, x: 24, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522085525.ts b/dot-line-system/.history/src/main_20250522085525.ts new file mode 100644 index 0000000..9598b8a --- /dev/null +++ b/dot-line-system/.history/src/main_20250522085525.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -10, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: -8, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Omas Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: -6, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.7, x: -4, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Wanderung in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: -2, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 0, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Unverhoffter Krankentag', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 2, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 4, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 2.1, x: 6, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 8, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 10, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 12, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 14, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 18, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 20, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Shoppingtag in der Stadt', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 22, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 24, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522085554.ts b/dot-line-system/.history/src/main_20250522085554.ts new file mode 100644 index 0000000..2e857a9 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522085554.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -12, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: -8, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Omas Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: -6, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.7, x: -4, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Wanderung in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: -2, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 0, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Unverhoffter Krankentag', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 2, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 4, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 2.1, x: 6, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 8, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 10, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 12, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 14, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 18, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 20, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Shoppingtag in der Stadt', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 22, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 24, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522085614.ts b/dot-line-system/.history/src/main_20250522085614.ts new file mode 100644 index 0000000..2be28dd --- /dev/null +++ b/dot-line-system/.history/src/main_20250522085614.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -12, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: -8, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Omas Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: -6, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.7, x: -4, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Wanderung in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: -1, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 0, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Unverhoffter Krankentag', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 2, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 4, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 2.1, x: 6, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 8, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 10, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 12, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 14, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 18, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 20, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Shoppingtag in der Stadt', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 22, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 24, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522085624.ts b/dot-line-system/.history/src/main_20250522085624.ts new file mode 100644 index 0000000..e97e1e5 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522085624.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -5, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: -4, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Omas Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: -3, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.7, x: -2, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Wanderung in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: -1, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 0, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Unverhoffter Krankentag', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 2, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 4, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 2.1, x: 6, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 8, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 10, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 12, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 14, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 18, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 20, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Shoppingtag in der Stadt', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 22, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 24, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522085712.ts b/dot-line-system/.history/src/main_20250522085712.ts new file mode 100644 index 0000000..c0d2d99 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522085712.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: 0, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: -4, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Omas Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: -3, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.7, x: -2, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Wanderung in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: -1, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 0, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Unverhoffter Krankentag', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 2, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 4, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 2.1, x: 6, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 8, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 10, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 12, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 14, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 18, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 20, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Shoppingtag in der Stadt', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 22, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 24, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522085720.ts b/dot-line-system/.history/src/main_20250522085720.ts new file mode 100644 index 0000000..e3838d3 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522085720.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -2, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: -4, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Omas Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: -3, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.7, x: -2, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Wanderung in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: -1, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 0, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Unverhoffter Krankentag', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 2, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 4, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 2.1, x: 6, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 8, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 10, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 12, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 14, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 18, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 20, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Shoppingtag in der Stadt', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 22, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 24, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522085742.ts b/dot-line-system/.history/src/main_20250522085742.ts new file mode 100644 index 0000000..687ac9f --- /dev/null +++ b/dot-line-system/.history/src/main_20250522085742.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -2, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Omas Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.7, x: 4, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Wanderung in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Unverhoffter Krankentag', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 2.1, x: 14, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 8, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 10, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 12, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 14, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 18, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 20, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Shoppingtag in der Stadt', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 22, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 24, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522085804.ts b/dot-line-system/.history/src/main_20250522085804.ts new file mode 100644 index 0000000..54555de --- /dev/null +++ b/dot-line-system/.history/src/main_20250522085804.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -2, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Omas Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.7, x: 4, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Wanderung in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Unverhoffter Krankentag', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 2.1, x: 14, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 18, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 20, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Shoppingtag in der Stadt', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 22, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 24, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522085818.ts b/dot-line-system/.history/src/main_20250522085818.ts new file mode 100644 index 0000000..a535060 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522085818.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -2, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Omas Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.7, x: 4, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Wanderung in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Unverhoffter Krankentag', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 2.1, x: 14, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 26, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 28, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Shoppingtag in der Stadt', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 30, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 32, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522085841.ts b/dot-line-system/.history/src/main_20250522085841.ts new file mode 100644 index 0000000..64a3999 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522085841.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -4, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Omas Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.7, x: 4, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Wanderung in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Unverhoffter Krankentag', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 2.1, x: 14, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 26, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 28, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Shoppingtag in der Stadt', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 30, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 32, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522085845.ts b/dot-line-system/.history/src/main_20250522085845.ts new file mode 100644 index 0000000..68f1fd8 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522085845.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -3, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Omas Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.7, x: 4, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Wanderung in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Unverhoffter Krankentag', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 2.1, x: 14, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 26, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 28, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Shoppingtag in der Stadt', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 30, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 32, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522085849.ts b/dot-line-system/.history/src/main_20250522085849.ts new file mode 100644 index 0000000..6dc5b28 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522085849.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: 0, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Omas Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.7, x: 4, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Wanderung in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Unverhoffter Krankentag', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 2.1, x: 14, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 26, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 28, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Shoppingtag in der Stadt', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 30, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 32, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522085852.ts b/dot-line-system/.history/src/main_20250522085852.ts new file mode 100644 index 0000000..a535060 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522085852.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -2, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Omas Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.7, x: 4, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Wanderung in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Unverhoffter Krankentag', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 2.1, x: 14, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 26, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 28, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Shoppingtag in der Stadt', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 30, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 32, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522090305.ts b/dot-line-system/.history/src/main_20250522090305.ts new file mode 100644 index 0000000..b1e2bbf --- /dev/null +++ b/dot-line-system/.history/src/main_20250522090305.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -2, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Omas Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.7, x: 4, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Wanderung in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Unverhoffter Krankentag', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 2.1, x: 14, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 26, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 28, imageUrl: 'https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png', title: 'Kindergeburtstag', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 30, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 32, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522090350.ts b/dot-line-system/.history/src/main_20250522090350.ts new file mode 100644 index 0000000..7f9f988 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522090350.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -2, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Omas Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.7, x: 4, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Wanderung in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png', title: 'Oma Erna verstorben', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 2.1, x: 14, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 26, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 28, imageUrl: 'https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png', title: 'Kindergeburtstag', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 30, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 32, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522090417.ts b/dot-line-system/.history/src/main_20250522090417.ts new file mode 100644 index 0000000..f0504a8 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522090417.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -2, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Omas Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.7, x: 4, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Wanderung in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png', title: 'Oma Erna verstorben', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 2.1, x: 14, imageUrl: 'https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 26, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 28, imageUrl: 'https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png', title: 'Kindergeburtstag', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 30, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 32, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522090431.ts b/dot-line-system/.history/src/main_20250522090431.ts new file mode 100644 index 0000000..66d2197 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522090431.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -2, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Omas Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.7, x: 4, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Wanderung in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png', title: 'Oma Erna verstorben', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 3.1, x: 14, imageUrl: 'https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 26, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 28, imageUrl: 'https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png', title: 'Kindergeburtstag', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 30, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 32, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522090436.ts b/dot-line-system/.history/src/main_20250522090436.ts new file mode 100644 index 0000000..a2aeb04 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522090436.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -2, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Omas Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.0, x: 4, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Wanderung in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png', title: 'Oma Erna verstorben', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 3.1, x: 14, imageUrl: 'https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 26, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 28, imageUrl: 'https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png', title: 'Kindergeburtstag', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 30, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 32, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522091026.ts b/dot-line-system/.history/src/main_20250522091026.ts new file mode 100644 index 0000000..b8c5d3d --- /dev/null +++ b/dot-line-system/.history/src/main_20250522091026.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -2, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Omas Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.0, x: 4, imageUrl: 'https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png', title: 'Wanderreiten in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png', title: 'Oma Erna verstorben', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 3.1, x: 14, imageUrl: 'https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 26, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 28, imageUrl: 'https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png', title: 'Kindergeburtstag', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 30, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 32, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522091044.ts b/dot-line-system/.history/src/main_20250522091044.ts new file mode 100644 index 0000000..c171fec --- /dev/null +++ b/dot-line-system/.history/src/main_20250522091044.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -2, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Omas Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.0, x: 4, imageUrl: 'https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png', title: 'Wanderreiten in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png', title: 'Oma Erna verstorben', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://picsum.photos/200/150?random=7', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 3.1, x: 14, imageUrl: 'https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 26, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 28, imageUrl: 'https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png', title: 'Kindergeburtstag', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 30, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 32, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522091103.ts b/dot-line-system/.history/src/main_20250522091103.ts new file mode 100644 index 0000000..6272538 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522091103.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -2, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Omas Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.0, x: 4, imageUrl: 'https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png', title: 'Wanderreiten in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png', title: 'Oma Erna verstorben', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 3.1, x: 14, imageUrl: 'https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 26, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 28, imageUrl: 'https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png', title: 'Kindergeburtstag', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 30, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 32, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522091117.ts b/dot-line-system/.history/src/main_20250522091117.ts new file mode 100644 index 0000000..5d700d5 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522091117.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -2, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Omas Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.0, x: 4, imageUrl: 'https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png', title: 'Wanderreiten in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png', title: 'Oma Erna verstorben', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 3.1, x: 14, imageUrl: 'https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 26, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 28, imageUrl: 'https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png', title: 'Kindergeburtstag', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 30, imageUrl: 'https://picsum.photos/200/150?random=8', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 32, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522091134.ts b/dot-line-system/.history/src/main_20250522091134.ts new file mode 100644 index 0000000..89a05ac --- /dev/null +++ b/dot-line-system/.history/src/main_20250522091134.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -2, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://picsum.photos/200/150?random=2', title: 'Omas Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.0, x: 4, imageUrl: 'https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png', title: 'Wanderreiten in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png', title: 'Oma Erna verstorben', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 3.1, x: 14, imageUrl: 'https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 26, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 28, imageUrl: 'https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png', title: 'Kindergeburtstag', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 30, imageUrl: 'https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 32, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522091203.ts b/dot-line-system/.history/src/main_20250522091203.ts new file mode 100644 index 0000000..40e6325 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522091203.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -2, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png', title: 'Omas Annis Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.0, x: 4, imageUrl: 'https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png', title: 'Wanderreiten in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png', title: 'Oma Erna verstorben', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 3.1, x: 14, imageUrl: 'https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 26, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 28, imageUrl: 'https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png', title: 'Kindergeburtstag', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 30, imageUrl: 'https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 32, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522091258.ts b/dot-line-system/.history/src/main_20250522091258.ts new file mode 100644 index 0000000..eb5aeca --- /dev/null +++ b/dot-line-system/.history/src/main_20250522091258.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -2, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png', title: 'Omas Annis Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.0, x: 4, imageUrl: 'https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png', title: 'Wanderreiten in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png', title: 'Oma Erna verstorben', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 3.1, x: 14, imageUrl: 'https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 26, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 28, imageUrl: 'https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png', title: 'Kindergeburtstag', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 30, imageUrl: 'https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 32, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522102605.ts b/dot-line-system/.history/src/main_20250522102605.ts new file mode 100644 index 0000000..327b59b --- /dev/null +++ b/dot-line-system/.history/src/main_20250522102605.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -2, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png', title: 'Omas Annis Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.0, x: 4, imageUrl: 'https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png', title: 'Wanderreiten in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png', title: 'Oma Erna verstorben', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 3.1, x: 14, imageUrl: 'https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessensdfdsfs', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 26, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 28, imageUrl: 'https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png', title: 'Kindergeburtstag', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 30, imageUrl: 'https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 32, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522102612.ts b/dot-line-system/.history/src/main_20250522102612.ts new file mode 100644 index 0000000..eb5aeca --- /dev/null +++ b/dot-line-system/.history/src/main_20250522102612.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -2, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png', title: 'Omas Annis Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.0, x: 4, imageUrl: 'https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png', title: 'Wanderreiten in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png', title: 'Oma Erna verstorben', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 3.1, x: 14, imageUrl: 'https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 26, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 28, imageUrl: 'https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png', title: 'Kindergeburtstag', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 30, imageUrl: 'https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 32, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522102630.ts b/dot-line-system/.history/src/main_20250522102630.ts new file mode 100644 index 0000000..14be066 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522102630.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -2, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png', title: 'Omas Annis Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.0, x: 4, imageUrl: 'https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png', title: 'Wanderreiten in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png', title: 'Oma Erna verstorben', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 3.1, x: 14, imageUrl: 'https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessensdfdfs', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 26, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 28, imageUrl: 'https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png', title: 'Kindergeburtstag', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 30, imageUrl: 'https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 32, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522102634.ts b/dot-line-system/.history/src/main_20250522102634.ts new file mode 100644 index 0000000..eb5aeca --- /dev/null +++ b/dot-line-system/.history/src/main_20250522102634.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -2, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png', title: 'Omas Annis Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.0, x: 4, imageUrl: 'https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png', title: 'Wanderreiten in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png', title: 'Oma Erna verstorben', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 3.1, x: 14, imageUrl: 'https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 26, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 28, imageUrl: 'https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png', title: 'Kindergeburtstag', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 30, imageUrl: 'https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 32, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522102637.ts b/dot-line-system/.history/src/main_20250522102637.ts new file mode 100644 index 0000000..eb5aeca --- /dev/null +++ b/dot-line-system/.history/src/main_20250522102637.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -2, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png', title: 'Omas Annis Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.0, x: 4, imageUrl: 'https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png', title: 'Wanderreiten in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png', title: 'Oma Erna verstorben', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 3.1, x: 14, imageUrl: 'https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 26, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 28, imageUrl: 'https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png', title: 'Kindergeburtstag', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 30, imageUrl: 'https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 32, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522103603.ts b/dot-line-system/.history/src/main_20250522103603.ts new file mode 100644 index 0000000..e38932a --- /dev/null +++ b/dot-line-system/.history/src/main_20250522103603.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -2, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png', title: 'Omas Annis Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.0, x: 4, imageUrl: 'https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png', title: 'Wanderreiten in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png', title: 'Oma Erna verstorben', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 3.1, x: 14, imageUrl: 'https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://picsum.photos/200/150?random=5', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 26, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 28, imageUrl: 'https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png', title: 'Kindergeburtstag', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 30, imageUrl: 'https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 32, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522103730.ts b/dot-line-system/.history/src/main_20250522103730.ts new file mode 100644 index 0000000..6e527f7 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522103730.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -2, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png', title: 'Omas Annis Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.0, x: 4, imageUrl: 'https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png', title: 'Wanderreiten in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png', title: 'Oma Erna verstorben', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 3.1, x: 14, imageUrl: 'https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://picsum.photos/200/150?random=3', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 26, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 28, imageUrl: 'https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png', title: 'Kindergeburtstag', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 30, imageUrl: 'https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 32, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522103753.ts b/dot-line-system/.history/src/main_20250522103753.ts new file mode 100644 index 0000000..427c257 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522103753.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -2, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png', title: 'Omas Annis Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.0, x: 4, imageUrl: 'https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png', title: 'Wanderreiten in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png', title: 'Oma Erna verstorben', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 3.1, x: 14, imageUrl: 'https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://picsum.photos/200/150?random=1', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 26, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 28, imageUrl: 'https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png', title: 'Kindergeburtstag', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 30, imageUrl: 'https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 32, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522104008.ts b/dot-line-system/.history/src/main_20250522104008.ts new file mode 100644 index 0000000..622dfcc --- /dev/null +++ b/dot-line-system/.history/src/main_20250522104008.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -2, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png', title: 'Omas Annis Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.0, x: 4, imageUrl: 'https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png', title: 'Wanderreiten in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png', title: 'Oma Erna verstorben', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 3.1, x: 14, imageUrl: 'https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://picsum.photos/200/150?random=4', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 26, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 28, imageUrl: 'https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png', title: 'Kindergeburtstag', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 30, imageUrl: 'https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 32, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522104033.ts b/dot-line-system/.history/src/main_20250522104033.ts new file mode 100644 index 0000000..f924c87 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522104033.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -2, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png', title: 'Omas Annis Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.0, x: 4, imageUrl: 'https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png', title: 'Wanderreiten in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png', title: 'Oma Erna verstorben', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 3.1, x: 14, imageUrl: 'https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 26, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 28, imageUrl: 'https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png', title: 'Kindergeburtstag', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 30, imageUrl: 'https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 32, imageUrl: 'https://picsum.photos/200/150?random=9', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522104601.ts b/dot-line-system/.history/src/main_20250522104601.ts new file mode 100644 index 0000000..2803a2d --- /dev/null +++ b/dot-line-system/.history/src/main_20250522104601.ts @@ -0,0 +1,93 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -2, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png', title: 'Omas Annis Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.0, x: 4, imageUrl: 'https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png', title: 'Wanderreiten in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png', title: 'Oma Erna verstorben', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 3.1, x: 14, imageUrl: 'https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 26, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 28, imageUrl: 'https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png', title: 'Kindergeburtstag', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 30, imageUrl: 'https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 32, imageUrl: 'https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if(!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + +}); diff --git a/dot-line-system/.history/src/main_20250522130745.ts b/dot-line-system/.history/src/main_20250522130745.ts new file mode 100644 index 0000000..3197851 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522130745.ts @@ -0,0 +1,118 @@ +import { ConnectedDotsVisualization, type DotConfig } from './ConnectedDotsVisualization'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { id: 1, value: -1.8, x: -2, imageUrl: 'https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png', title: 'Beginn des neuen Abenteuers', description: '01.10.2024', link: '/page1' }, + { id: 2, value: 1.2, x: 0, imageUrl: 'https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png', title: 'Omas Annis Geburtstag', description: '02.10.2024', link: '/page2' }, + { id: 3, value: -0.6, x: 2, imageUrl: 'https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png', title: 'Konzertbesuch mit Freunden', description: '03.10.2024', link: '/page3' }, + { id: 4, value: 2.0, x: 4, imageUrl: 'https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png', title: 'Wanderreiten in den Bergen', description: '04.10.2024', link: '/page4' }, + { id: 5, value: 0.8, x: 6, imageUrl: 'https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png', title: 'Ruhiger Tag zu Hause', description: '05.10.2024', link: '/page5' }, + { id: 6, value: -2.9, x: 8, imageUrl: 'https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png', title: 'Oma Erna verstorben', description: '06.10.2024', link: '/page6' }, + { id: 7, value: 1.5, x: 10, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png', title: 'Erholungsausflug zum See', description: '07.10.2024', link: '/page7' }, + { id: 8, value: 0, x: 12, imageUrl: 'https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png', title: 'Kleine Wochenendsfeier', description: '08.10.2024', link: '/page8' }, + { id: 9, value: 3.1, x: 14, imageUrl: 'https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png', title: 'Hochzeit von Cousine Tatjana', description: '09.10.2024', link: '/page9' }, + { id: 10, value: -1.8, x: 16, imageUrl: 'https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png', title: 'Erster Tag im neuen Job', description: '10.10.2024', link: '/page10' }, + { id: 11, value: 1.2, x: 18, imageUrl: 'https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png', title: 'Klassentreffen nach vielen Jahren', description: '11.10.2024', link: '/page11' }, + { id: 12, value: -0.6, x: 20, imageUrl: 'https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png', title: 'Familienabendessen', description: '12.10.2024', link: '/page12' }, + { id: 13, value: 2.7, x: 22, imageUrl: 'https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png', title: 'Kinobesuch mit der ganzen Familie', description: '13.10.2024', link: '/page13' }, + { id: 14, value: 0.8, x: 24, imageUrl: 'https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png', title: 'Entspannung', description: '14.10.2024', link: '/page14' }, + { id: 15, value: -2.9, x: 26, imageUrl: 'https://picsum.photos/200/150?random=6', title: 'Geruhsamer Sonntag', description: '15.10.2024', link: '/page15' }, + { id: 16, value: 1.5, x: 28, imageUrl: 'https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png', title: 'Kindergeburtstag', description: '16.10.2024', link: '/page16' }, + { id: 17, value: 0, x: 30, imageUrl: 'https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png', title: 'Spaziergang mit der Familie', description: '17.10.2024', link: '/page17' }, + { id: 18, value: 2.1, x: 32, imageUrl: 'https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png', title: 'Familienfeier bei den Großeltern', description: '18.10.2024', link: '/page18' } +]; + +// Wait for DOM to be fully loaded +document.addEventListener('DOMContentLoaded', () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization('scroll-container', sampleDots, { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150 + }); + + // Handle window resize + window.addEventListener('resize', () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector('.scroll-container'); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener('mousedown', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('mouseleave', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mouseup', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('mousemove', (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener('touchstart', (e) => { + isDown = true; + scrollContainer.classList.add('active'); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener('touchend', () => { + isDown = false; + scrollContainer.classList.remove('active'); + }); + + scrollContainer.addEventListener('touchmove', (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + +}); diff --git a/dot-line-system/.history/src/main_20250522131101.ts b/dot-line-system/.history/src/main_20250522131101.ts new file mode 100644 index 0000000..270f968 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522131101.ts @@ -0,0 +1,284 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value: 2.0, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 0.8, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -2.9, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3.1, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: -1.8, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: 1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0.8, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 200, + tooltipHeight: 150, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522131108.ts b/dot-line-system/.history/src/main_20250522131108.ts new file mode 100644 index 0000000..f078f8f --- /dev/null +++ b/dot-line-system/.history/src/main_20250522131108.ts @@ -0,0 +1,284 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value: 2.0, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 0.8, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -2.9, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3.1, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: -1.8, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: 1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0.8, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 150, + tooltipHeight: 150, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522131112.ts b/dot-line-system/.history/src/main_20250522131112.ts new file mode 100644 index 0000000..61965c2 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522131112.ts @@ -0,0 +1,284 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value: 2.0, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 0.8, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -2.9, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3.1, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: -1.8, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: 1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0.8, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 100, + tooltipHeight: 150, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522131119.ts b/dot-line-system/.history/src/main_20250522131119.ts new file mode 100644 index 0000000..e27abb7 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522131119.ts @@ -0,0 +1,284 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value: 2.0, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 0.8, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -2.9, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3.1, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: -1.8, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: 1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0.8, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + tooltipWidth: 100, + tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522131131.ts b/dot-line-system/.history/src/main_20250522131131.ts new file mode 100644 index 0000000..aeadf5e --- /dev/null +++ b/dot-line-system/.history/src/main_20250522131131.ts @@ -0,0 +1,284 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value: 2.0, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 0.8, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -2.9, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3.1, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: -1.8, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: 1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0.8, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522131843.ts b/dot-line-system/.history/src/main_20250522131843.ts new file mode 100644 index 0000000..f90a07a --- /dev/null +++ b/dot-line-system/.history/src/main_20250522131843.ts @@ -0,0 +1,284 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value: 3.0, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 0.8, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -2.9, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3.1, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: -1.8, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: 1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0.8, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522131848.ts b/dot-line-system/.history/src/main_20250522131848.ts new file mode 100644 index 0000000..63a29af --- /dev/null +++ b/dot-line-system/.history/src/main_20250522131848.ts @@ -0,0 +1,284 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value: 1.0, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 0.8, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -2.9, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3.1, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: -1.8, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: 1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0.8, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522131851.ts b/dot-line-system/.history/src/main_20250522131851.ts new file mode 100644 index 0000000..0298937 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522131851.ts @@ -0,0 +1,284 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value: 1.5, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 0.8, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -2.9, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3.1, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: -1.8, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: 1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0.8, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522131901.ts b/dot-line-system/.history/src/main_20250522131901.ts new file mode 100644 index 0000000..871a5d2 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522131901.ts @@ -0,0 +1,284 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value: 1.5, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 0.8, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3.1, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: -1.8, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: 1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0.8, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522131929.ts b/dot-line-system/.history/src/main_20250522131929.ts new file mode 100644 index 0000000..4af2f9a --- /dev/null +++ b/dot-line-system/.history/src/main_20250522131929.ts @@ -0,0 +1,284 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 0.8, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3.1, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: -1.8, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: 1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0.8, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522131937.ts b/dot-line-system/.history/src/main_20250522131937.ts new file mode 100644 index 0000000..4ae58e1 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522131937.ts @@ -0,0 +1,284 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:2.5, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 0.8, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3.1, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: -1.8, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: 1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0.8, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522131944.ts b/dot-line-system/.history/src/main_20250522131944.ts new file mode 100644 index 0000000..4af2f9a --- /dev/null +++ b/dot-line-system/.history/src/main_20250522131944.ts @@ -0,0 +1,284 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 0.8, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3.1, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: -1.8, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: 1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0.8, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522132110.ts b/dot-line-system/.history/src/main_20250522132110.ts new file mode 100644 index 0000000..dfe864b --- /dev/null +++ b/dot-line-system/.history/src/main_20250522132110.ts @@ -0,0 +1,284 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 3, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3.1, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: -1.8, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: 1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0.8, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522132123.ts b/dot-line-system/.history/src/main_20250522132123.ts new file mode 100644 index 0000000..6f68913 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522132123.ts @@ -0,0 +1,284 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:0, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 3, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3.1, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: -1.8, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: 1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0.8, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522132137.ts b/dot-line-system/.history/src/main_20250522132137.ts new file mode 100644 index 0000000..d85f61d --- /dev/null +++ b/dot-line-system/.history/src/main_20250522132137.ts @@ -0,0 +1,284 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3.1, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: -1.8, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: 1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0.8, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522132218.ts b/dot-line-system/.history/src/main_20250522132218.ts new file mode 100644 index 0000000..1bde57f --- /dev/null +++ b/dot-line-system/.history/src/main_20250522132218.ts @@ -0,0 +1,283 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3.1, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: -1.8, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: 1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0.8, + x: 24, + + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522132225.ts b/dot-line-system/.history/src/main_20250522132225.ts new file mode 100644 index 0000000..d85f61d --- /dev/null +++ b/dot-line-system/.history/src/main_20250522132225.ts @@ -0,0 +1,284 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3.1, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: -1.8, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: 1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0.8, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522132350.ts b/dot-line-system/.history/src/main_20250522132350.ts new file mode 100644 index 0000000..9b3867a --- /dev/null +++ b/dot-line-system/.history/src/main_20250522132350.ts @@ -0,0 +1,284 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3.1, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: -1.8, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: 1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0.8, + x: 24, + // imageUrl: + // "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522132401.ts b/dot-line-system/.history/src/main_20250522132401.ts new file mode 100644 index 0000000..d85f61d --- /dev/null +++ b/dot-line-system/.history/src/main_20250522132401.ts @@ -0,0 +1,284 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3.1, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: -1.8, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: 1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0.8, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522132525.ts b/dot-line-system/.history/src/main_20250522132525.ts new file mode 100644 index 0000000..9b3867a --- /dev/null +++ b/dot-line-system/.history/src/main_20250522132525.ts @@ -0,0 +1,284 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3.1, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: -1.8, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: 1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0.8, + x: 24, + // imageUrl: + // "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522132532.ts b/dot-line-system/.history/src/main_20250522132532.ts new file mode 100644 index 0000000..d85f61d --- /dev/null +++ b/dot-line-system/.history/src/main_20250522132532.ts @@ -0,0 +1,284 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3.1, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: -1.8, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: 1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0.8, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522133155.ts b/dot-line-system/.history/src/main_20250522133155.ts new file mode 100644 index 0000000..3d3060e --- /dev/null +++ b/dot-line-system/.history/src/main_20250522133155.ts @@ -0,0 +1,284 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3.1, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0.8, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522133219.ts b/dot-line-system/.history/src/main_20250522133219.ts new file mode 100644 index 0000000..7f3b729 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522133219.ts @@ -0,0 +1,284 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3.1, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0.5, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522133230.ts b/dot-line-system/.history/src/main_20250522133230.ts new file mode 100644 index 0000000..62d08a6 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522133230.ts @@ -0,0 +1,284 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3.1, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522150734.ts b/dot-line-system/.history/src/main_20250522150734.ts new file mode 100644 index 0000000..b5569bc --- /dev/null +++ b/dot-line-system/.history/src/main_20250522150734.ts @@ -0,0 +1,284 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 2, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522150803.ts b/dot-line-system/.history/src/main_20250522150803.ts new file mode 100644 index 0000000..79e4936 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522150803.ts @@ -0,0 +1,284 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 1, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522150809.ts b/dot-line-system/.history/src/main_20250522150809.ts new file mode 100644 index 0000000..9cb0d02 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522150809.ts @@ -0,0 +1,284 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522222205.ts b/dot-line-system/.history/src/main_20250522222205.ts new file mode 100644 index 0000000..9cb0d02 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522222205.ts @@ -0,0 +1,284 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522222757.ts b/dot-line-system/.history/src/main_20250522222757.ts new file mode 100644 index 0000000..116a6f9 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522222757.ts @@ -0,0 +1,286 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +import '../src/style.css'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "https://cdn.midjourney.com/07911cec-cc5a-478a-b580-ac1bb80bad94/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "https://cdn.midjourney.com/57370e4b-e0c3-4271-bf8f-69adbdb416cc/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522223705.ts b/dot-line-system/.history/src/main_20250522223705.ts new file mode 100644 index 0000000..e89cece --- /dev/null +++ b/dot-line-system/.history/src/main_20250522223705.ts @@ -0,0 +1,286 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +import '../src/style.css'; + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "src/images/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "src/images/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522224138.ts b/dot-line-system/.history/src/main_20250522224138.ts new file mode 100644 index 0000000..7c16f57 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522224138.ts @@ -0,0 +1,303 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +import '../src/style.css'; + +/* + * If you are using a bundler like Vite, Webpack, or similar, you need to ensure that the `src/images` folder is included in your build output. + * + * For Vite: + * - Place your images in the `public/images` directory instead of `src/images`. + * - Reference them as `/images/filename.png` in your code. + * + * For Webpack: + * - Use `require` or `import` for images, or configure `copy-webpack-plugin` to copy the `src/images` folder to your output directory. + * + * For static hosting (e.g., GitHub Pages, Netlify): + * - Make sure the images are in the output directory (e.g., `dist/images`) after build. + * + * Example for Vite: + * Move images to `public/images` and update imageUrl paths to `/images/filename.png`. + */ + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "/images/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "/images/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522224154.ts b/dot-line-system/.history/src/main_20250522224154.ts new file mode 100644 index 0000000..7c16f57 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522224154.ts @@ -0,0 +1,303 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +import '../src/style.css'; + +/* + * If you are using a bundler like Vite, Webpack, or similar, you need to ensure that the `src/images` folder is included in your build output. + * + * For Vite: + * - Place your images in the `public/images` directory instead of `src/images`. + * - Reference them as `/images/filename.png` in your code. + * + * For Webpack: + * - Use `require` or `import` for images, or configure `copy-webpack-plugin` to copy the `src/images` folder to your output directory. + * + * For static hosting (e.g., GitHub Pages, Netlify): + * - Make sure the images are in the output directory (e.g., `dist/images`) after build. + * + * Example for Vite: + * Move images to `public/images` and update imageUrl paths to `/images/filename.png`. + */ + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "/images/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "/images/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "https://cdn.midjourney.com/876aa1b2-48c5-4d19-9c2b-297271d17a51/0_3.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "https://cdn.midjourney.com/8b61487f-bdc6-4550-99b8-52802fa55fe8/0_1.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522224417.ts b/dot-line-system/.history/src/main_20250522224417.ts new file mode 100644 index 0000000..50bdd2f --- /dev/null +++ b/dot-line-system/.history/src/main_20250522224417.ts @@ -0,0 +1,303 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +import '../src/style.css'; + +/* + * If you are using a bundler like Vite, Webpack, or similar, you need to ensure that the `src/images` folder is included in your build output. + * + * For Vite: + * - Place your images in the `public/images` directory instead of `src/images`. + * - Reference them as `/images/filename.png` in your code. + * + * For Webpack: + * - Use `require` or `import` for images, or configure `copy-webpack-plugin` to copy the `src/images` folder to your output directory. + * + * For static hosting (e.g., GitHub Pages, Netlify): + * - Make sure the images are in the output directory (e.g., `dist/images`) after build. + * + * Example for Vite: + * Move images to `public/images` and update imageUrl paths to `/images/filename.png`. + */ + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "/images/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "/images/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "/images/discopferd.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "/images/pferd.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522224419.ts b/dot-line-system/.history/src/main_20250522224419.ts new file mode 100644 index 0000000..25f33ad --- /dev/null +++ b/dot-line-system/.history/src/main_20250522224419.ts @@ -0,0 +1,303 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +import '../src/style.css'; + +/* + * If you are using a bundler like Vite, Webpack, or similar, you need to ensure that the `src/images` folder is included in your build output. + * + * For Vite: + * - Place your images in the `public/images` directory instead of `src/images`. + * - Reference them as `/images/filename.png` in your code. + * + * For Webpack: + * - Use `require` or `import` for images, or configure `copy-webpack-plugin` to copy the `src/images` folder to your output directory. + * + * For static hosting (e.g., GitHub Pages, Netlify): + * - Make sure the images are in the output directory (e.g., `dist/images`) after build. + * + * Example for Vite: + * Move images to `public/images` and update imageUrl paths to `/images/filename.png`. + */ + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "/images/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "/images/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "/images/disco.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "/images/pferd.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "https://cdn.midjourney.com/8eafbeb0-35c8-4139-97b4-26b0298c64f6/0_2.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522224450.ts b/dot-line-system/.history/src/main_20250522224450.ts new file mode 100644 index 0000000..9606a8e --- /dev/null +++ b/dot-line-system/.history/src/main_20250522224450.ts @@ -0,0 +1,303 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +import '../src/style.css'; + +/* + * If you are using a bundler like Vite, Webpack, or similar, you need to ensure that the `src/images` folder is included in your build output. + * + * For Vite: + * - Place your images in the `public/images` directory instead of `src/images`. + * - Reference them as `/images/filename.png` in your code. + * + * For Webpack: + * - Use `require` or `import` for images, or configure `copy-webpack-plugin` to copy the `src/images` folder to your output directory. + * + * For static hosting (e.g., GitHub Pages, Netlify): + * - Make sure the images are in the output directory (e.g., `dist/images`) after build. + * + * Example for Vite: + * Move images to `public/images` and update imageUrl paths to `/images/filename.png`. + */ + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "/images/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "/images/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "/images/disco.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "/images/pferd.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "/images/gpt.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "https://cdn.midjourney.com/5419f43d-2d7e-474c-b672-82f671f410d9/0_3.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522224516.ts b/dot-line-system/.history/src/main_20250522224516.ts new file mode 100644 index 0000000..34b0304 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522224516.ts @@ -0,0 +1,303 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +import '../src/style.css'; + +/* + * If you are using a bundler like Vite, Webpack, or similar, you need to ensure that the `src/images` folder is included in your build output. + * + * For Vite: + * - Place your images in the `public/images` directory instead of `src/images`. + * - Reference them as `/images/filename.png` in your code. + * + * For Webpack: + * - Use `require` or `import` for images, or configure `copy-webpack-plugin` to copy the `src/images` folder to your output directory. + * + * For static hosting (e.g., GitHub Pages, Netlify): + * - Make sure the images are in the output directory (e.g., `dist/images`) after build. + * + * Example for Vite: + * Move images to `public/images` and update imageUrl paths to `/images/filename.png`. + */ + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "/images/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "/images/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "/images/disco.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "/images/pferd.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "/images/gpt.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "/images/oma.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_0.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522224540.ts b/dot-line-system/.history/src/main_20250522224540.ts new file mode 100644 index 0000000..6ef77a8 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522224540.ts @@ -0,0 +1,303 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +import '../src/style.css'; + +/* + * If you are using a bundler like Vite, Webpack, or similar, you need to ensure that the `src/images` folder is included in your build output. + * + * For Vite: + * - Place your images in the `public/images` directory instead of `src/images`. + * - Reference them as `/images/filename.png` in your code. + * + * For Webpack: + * - Use `require` or `import` for images, or configure `copy-webpack-plugin` to copy the `src/images` folder to your output directory. + * + * For static hosting (e.g., GitHub Pages, Netlify): + * - Make sure the images are in the output directory (e.g., `dist/images`) after build. + * + * Example for Vite: + * Move images to `public/images` and update imageUrl paths to `/images/filename.png`. + */ + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "/images/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "/images/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "/images/disco.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "/images/pferd.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "/images/gpt.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "/images/oma.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "/images/see.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "https://cdn.midjourney.com/a30dd9b5-beae-4d2d-8ba8-e58b474b69f1/0_1.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522224607.ts b/dot-line-system/.history/src/main_20250522224607.ts new file mode 100644 index 0000000..7b03f12 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522224607.ts @@ -0,0 +1,303 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +import '../src/style.css'; + +/* + * If you are using a bundler like Vite, Webpack, or similar, you need to ensure that the `src/images` folder is included in your build output. + * + * For Vite: + * - Place your images in the `public/images` directory instead of `src/images`. + * - Reference them as `/images/filename.png` in your code. + * + * For Webpack: + * - Use `require` or `import` for images, or configure `copy-webpack-plugin` to copy the `src/images` folder to your output directory. + * + * For static hosting (e.g., GitHub Pages, Netlify): + * - Make sure the images are in the output directory (e.g., `dist/images`) after build. + * + * Example for Vite: + * Move images to `public/images` and update imageUrl paths to `/images/filename.png`. + */ + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "/images/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "/images/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "/images/disco.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "/images/pferd.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "/images/gpt.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "/images/oma.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "/images/see.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "/images/feier.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3, + x: 14, + imageUrl: + "https://cdn.midjourney.com/2683889b-38af-49bd-954e-defe3c4ca659/0_0.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522224641.ts b/dot-line-system/.history/src/main_20250522224641.ts new file mode 100644 index 0000000..e20d6b5 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522224641.ts @@ -0,0 +1,303 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +import '../src/style.css'; + +/* + * If you are using a bundler like Vite, Webpack, or similar, you need to ensure that the `src/images` folder is included in your build output. + * + * For Vite: + * - Place your images in the `public/images` directory instead of `src/images`. + * - Reference them as `/images/filename.png` in your code. + * + * For Webpack: + * - Use `require` or `import` for images, or configure `copy-webpack-plugin` to copy the `src/images` folder to your output directory. + * + * For static hosting (e.g., GitHub Pages, Netlify): + * - Make sure the images are in the output directory (e.g., `dist/images`) after build. + * + * Example for Vite: + * Move images to `public/images` and update imageUrl paths to `/images/filename.png`. + */ + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "/images/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "/images/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "/images/disco.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "/images/pferd.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "/images/gpt.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "/images/oma.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "/images/see.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "/images/feier.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3, + x: 14, + imageUrl: + "/images/hochzeit.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "https://cdn.midjourney.com/92b34bda-d03c-4ec6-9e9f-b23f27f454d6/0_3.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522224710.ts b/dot-line-system/.history/src/main_20250522224710.ts new file mode 100644 index 0000000..2b7c777 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522224710.ts @@ -0,0 +1,303 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +import '../src/style.css'; + +/* + * If you are using a bundler like Vite, Webpack, or similar, you need to ensure that the `src/images` folder is included in your build output. + * + * For Vite: + * - Place your images in the `public/images` directory instead of `src/images`. + * - Reference them as `/images/filename.png` in your code. + * + * For Webpack: + * - Use `require` or `import` for images, or configure `copy-webpack-plugin` to copy the `src/images` folder to your output directory. + * + * For static hosting (e.g., GitHub Pages, Netlify): + * - Make sure the images are in the output directory (e.g., `dist/images`) after build. + * + * Example for Vite: + * Move images to `public/images` and update imageUrl paths to `/images/filename.png`. + */ + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "/images/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "/images/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "/images/disco.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "/images/pferd.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "/images/gpt.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "/images/oma.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "/images/see.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "/images/feier.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3, + x: 14, + imageUrl: + "/images/hochzeit.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "/images/work.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "https://cdn.midjourney.com/83e928f3-27c2-4a74-8553-ce767be2d1d9/0_3.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522224733.ts b/dot-line-system/.history/src/main_20250522224733.ts new file mode 100644 index 0000000..aca3d92 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522224733.ts @@ -0,0 +1,303 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +import '../src/style.css'; + +/* + * If you are using a bundler like Vite, Webpack, or similar, you need to ensure that the `src/images` folder is included in your build output. + * + * For Vite: + * - Place your images in the `public/images` directory instead of `src/images`. + * - Reference them as `/images/filename.png` in your code. + * + * For Webpack: + * - Use `require` or `import` for images, or configure `copy-webpack-plugin` to copy the `src/images` folder to your output directory. + * + * For static hosting (e.g., GitHub Pages, Netlify): + * - Make sure the images are in the output directory (e.g., `dist/images`) after build. + * + * Example for Vite: + * Move images to `public/images` and update imageUrl paths to `/images/filename.png`. + */ + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "/images/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "/images/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "/images/disco.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "/images/pferd.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "/images/gpt.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "/images/oma.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "/images/see.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "/images/feier.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3, + x: 14, + imageUrl: + "/images/hochzeit.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "/images/work.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "/images/klasse.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "https://cdn.midjourney.com/4588970f-748f-4c1e-89aa-f3a34c4ef73d/0_1.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522224743.ts b/dot-line-system/.history/src/main_20250522224743.ts new file mode 100644 index 0000000..e45726a --- /dev/null +++ b/dot-line-system/.history/src/main_20250522224743.ts @@ -0,0 +1,303 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +import '../src/style.css'; + +/* + * If you are using a bundler like Vite, Webpack, or similar, you need to ensure that the `src/images` folder is included in your build output. + * + * For Vite: + * - Place your images in the `public/images` directory instead of `src/images`. + * - Reference them as `/images/filename.png` in your code. + * + * For Webpack: + * - Use `require` or `import` for images, or configure `copy-webpack-plugin` to copy the `src/images` folder to your output directory. + * + * For static hosting (e.g., GitHub Pages, Netlify): + * - Make sure the images are in the output directory (e.g., `dist/images`) after build. + * + * Example for Vite: + * Move images to `public/images` and update imageUrl paths to `/images/filename.png`. + */ + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "/images/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "/images/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "/images/disco.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "/images/pferd.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "/images/gpt.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "/images/oma.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "/images/see.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "/images/feier.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3, + x: 14, + imageUrl: + "/images/hochzeit.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "/images/work.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "/images/klasse.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "/images/familie.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "https://cdn.midjourney.com/2ca30890-cf87-4a0c-9a13-0fc4ec6a6b1c/0_2.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522224813.ts b/dot-line-system/.history/src/main_20250522224813.ts new file mode 100644 index 0000000..59b3222 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522224813.ts @@ -0,0 +1,303 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +import '../src/style.css'; + +/* + * If you are using a bundler like Vite, Webpack, or similar, you need to ensure that the `src/images` folder is included in your build output. + * + * For Vite: + * - Place your images in the `public/images` directory instead of `src/images`. + * - Reference them as `/images/filename.png` in your code. + * + * For Webpack: + * - Use `require` or `import` for images, or configure `copy-webpack-plugin` to copy the `src/images` folder to your output directory. + * + * For static hosting (e.g., GitHub Pages, Netlify): + * - Make sure the images are in the output directory (e.g., `dist/images`) after build. + * + * Example for Vite: + * Move images to `public/images` and update imageUrl paths to `/images/filename.png`. + */ + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "/images/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "/images/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "/images/disco.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "/images/pferd.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "/images/gpt.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "/images/oma.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "/images/see.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "/images/feier.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3, + x: 14, + imageUrl: + "/images/hochzeit.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "/images/work.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "/images/klasse.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "/images/familie.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "/images/kinobesuch.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522224826.ts b/dot-line-system/.history/src/main_20250522224826.ts new file mode 100644 index 0000000..971d1d4 --- /dev/null +++ b/dot-line-system/.history/src/main_20250522224826.ts @@ -0,0 +1,303 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +import '../src/style.css'; + +/* + * If you are using a bundler like Vite, Webpack, or similar, you need to ensure that the `src/images` folder is included in your build output. + * + * For Vite: + * - Place your images in the `public/images` directory instead of `src/images`. + * - Reference them as `/images/filename.png` in your code. + * + * For Webpack: + * - Use `require` or `import` for images, or configure `copy-webpack-plugin` to copy the `src/images` folder to your output directory. + * + * For static hosting (e.g., GitHub Pages, Netlify): + * - Make sure the images are in the output directory (e.g., `dist/images`) after build. + * + * Example for Vite: + * Move images to `public/images` and update imageUrl paths to `/images/filename.png`. + */ + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "/images/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "/images/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "/images/disco.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "/images/pferd.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "/images/gpt.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "/images/oma.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "/images/see.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "/images/feier.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3, + x: 14, + imageUrl: + "/images/hochzeit.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "/images/work.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "/images/klasse.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "/images/familie.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "/images/kinobesuch.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "https://cdn.midjourney.com/9ebf9d61-8ede-46de-9336-10211aebaef7/0_0.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522224845.ts b/dot-line-system/.history/src/main_20250522224845.ts new file mode 100644 index 0000000..b548ebd --- /dev/null +++ b/dot-line-system/.history/src/main_20250522224845.ts @@ -0,0 +1,303 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +import '../src/style.css'; + +/* + * If you are using a bundler like Vite, Webpack, or similar, you need to ensure that the `src/images` folder is included in your build output. + * + * For Vite: + * - Place your images in the `public/images` directory instead of `src/images`. + * - Reference them as `/images/filename.png` in your code. + * + * For Webpack: + * - Use `require` or `import` for images, or configure `copy-webpack-plugin` to copy the `src/images` folder to your output directory. + * + * For static hosting (e.g., GitHub Pages, Netlify): + * - Make sure the images are in the output directory (e.g., `dist/images`) after build. + * + * Example for Vite: + * Move images to `public/images` and update imageUrl paths to `/images/filename.png`. + */ + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "/images/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "/images/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "/images/disco.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "/images/pferd.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "/images/gpt.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "/images/oma.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "/images/see.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "/images/feier.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3, + x: 14, + imageUrl: + "/images/hochzeit.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "/images/work.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "/images/klasse.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "/images/familie.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "/images/kinobesuch.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "/images/entspannung.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "https://cdn.midjourney.com/86652ad5-d67c-4ddb-bb50-a651387a4e5b/0_3.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "https://cdn.midjourney.com/ac154c04-7cc9-4926-ae8d-4f21c18bcf8d/0_2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "https://cdn.midjourney.com/0782c375-5ea9-4de5-b174-0046a65ce8ce/0_3.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522225100.ts b/dot-line-system/.history/src/main_20250522225100.ts new file mode 100644 index 0000000..7f42ebe --- /dev/null +++ b/dot-line-system/.history/src/main_20250522225100.ts @@ -0,0 +1,303 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +import '../src/style.css'; + +/* + * If you are using a bundler like Vite, Webpack, or similar, you need to ensure that the `src/images` folder is included in your build output. + * + * For Vite: + * - Place your images in the `public/images` directory instead of `src/images`. + * - Reference them as `/images/filename.png` in your code. + * + * For Webpack: + * - Use `require` or `import` for images, or configure `copy-webpack-plugin` to copy the `src/images` folder to your output directory. + * + * For static hosting (e.g., GitHub Pages, Netlify): + * - Make sure the images are in the output directory (e.g., `dist/images`) after build. + * + * Example for Vite: + * Move images to `public/images` and update imageUrl paths to `/images/filename.png`. + */ + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "/images/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "/images/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "/images/disco.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "/images/pferd.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "/images/gpt.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "/images/oma.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "/images/see.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "/images/feier.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3, + x: 14, + imageUrl: + "/images/hochzeit.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "/images/work.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "/images/klasse.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "/images/familie.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "/images/kinobesuch.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "/images/entspannung.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "/images/kindergeburtstag.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "/images/familie2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "/images/grosseltern.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522225110.ts b/dot-line-system/.history/src/main_20250522225110.ts new file mode 100644 index 0000000..7f42ebe --- /dev/null +++ b/dot-line-system/.history/src/main_20250522225110.ts @@ -0,0 +1,303 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +import '../src/style.css'; + +/* + * If you are using a bundler like Vite, Webpack, or similar, you need to ensure that the `src/images` folder is included in your build output. + * + * For Vite: + * - Place your images in the `public/images` directory instead of `src/images`. + * - Reference them as `/images/filename.png` in your code. + * + * For Webpack: + * - Use `require` or `import` for images, or configure `copy-webpack-plugin` to copy the `src/images` folder to your output directory. + * + * For static hosting (e.g., GitHub Pages, Netlify): + * - Make sure the images are in the output directory (e.g., `dist/images`) after build. + * + * Example for Vite: + * Move images to `public/images` and update imageUrl paths to `/images/filename.png`. + */ + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "/images/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "/images/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "/images/disco.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "/images/pferd.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "/images/gpt.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "/images/oma.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "/images/see.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "/images/feier.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3, + x: 14, + imageUrl: + "/images/hochzeit.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "/images/work.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "/images/klasse.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "/images/familie.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "/images/kinobesuch.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "/images/entspannung.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "https://picsum.photos/200/150?random=6", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "/images/kindergeburtstag.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "/images/familie2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "/images/grosseltern.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522225139.ts b/dot-line-system/.history/src/main_20250522225139.ts new file mode 100644 index 0000000..43c9e6d --- /dev/null +++ b/dot-line-system/.history/src/main_20250522225139.ts @@ -0,0 +1,303 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +import '../src/style.css'; + +/* + * If you are using a bundler like Vite, Webpack, or similar, you need to ensure that the `src/images` folder is included in your build output. + * + * For Vite: + * - Place your images in the `public/images` directory instead of `src/images`. + * - Reference them as `/images/filename.png` in your code. + * + * For Webpack: + * - Use `require` or `import` for images, or configure `copy-webpack-plugin` to copy the `src/images` folder to your output directory. + * + * For static hosting (e.g., GitHub Pages, Netlify): + * - Make sure the images are in the output directory (e.g., `dist/images`) after build. + * + * Example for Vite: + * Move images to `public/images` and update imageUrl paths to `/images/filename.png`. + */ + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "/images/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "/images/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "/images/disco.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "/images/pferd.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "/images/gpt.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "/images/oma.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "/images/see.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "/images/feier.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3, + x: 14, + imageUrl: + "/images/hochzeit.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "/images/work.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "/images/klasse.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "/images/familie.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "/images/kinobesuch.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "/images/entspannung.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "/images/sonntag.png", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "/images/kindergeburtstag.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "/images/familie2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "/images/grosseltern.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250522231822.ts b/dot-line-system/.history/src/main_20250522231822.ts new file mode 100644 index 0000000..43c9e6d --- /dev/null +++ b/dot-line-system/.history/src/main_20250522231822.ts @@ -0,0 +1,303 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +import '../src/style.css'; + +/* + * If you are using a bundler like Vite, Webpack, or similar, you need to ensure that the `src/images` folder is included in your build output. + * + * For Vite: + * - Place your images in the `public/images` directory instead of `src/images`. + * - Reference them as `/images/filename.png` in your code. + * + * For Webpack: + * - Use `require` or `import` for images, or configure `copy-webpack-plugin` to copy the `src/images` folder to your output directory. + * + * For static hosting (e.g., GitHub Pages, Netlify): + * - Make sure the images are in the output directory (e.g., `dist/images`) after build. + * + * Example for Vite: + * Move images to `public/images` and update imageUrl paths to `/images/filename.png`. + */ + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "/images/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "/images/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "/images/disco.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "/images/pferd.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "/images/gpt.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "/images/oma.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "/images/see.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "/images/feier.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3, + x: 14, + imageUrl: + "/images/hochzeit.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "/images/work.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "/images/klasse.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "/images/familie.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "/images/kinobesuch.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "/images/entspannung.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "/images/sonntag.png", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "/images/kindergeburtstag.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "/images/familie2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "/images/grosseltern.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + let scrollLeft; + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250523080429.ts b/dot-line-system/.history/src/main_20250523080429.ts new file mode 100644 index 0000000..bcc5dfe --- /dev/null +++ b/dot-line-system/.history/src/main_20250523080429.ts @@ -0,0 +1,305 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +import '../src/style.css'; + +/* + * If you are using a bundler like Vite, Webpack, or similar, you need to ensure that the `src/images` folder is included in your build output. + * + * For Vite: + * - Place your images in the `public/images` directory instead of `src/images`. + * - Reference them as `/images/filename.png` in your code. + * + * For Webpack: + * - Use `require` or `import` for images, or configure `copy-webpack-plugin` to copy the `src/images` folder to your output directory. + * + * For static hosting (e.g., GitHub Pages, Netlify): + * - Make sure the images are in the output directory (e.g., `dist/images`) after build. + * + * Example for Vite: + * Move images to `public/images` and update imageUrl paths to `/images/filename.png`. + */ + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "/images/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "/images/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "/images/disco.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "/images/pferd.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "/images/gpt.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "/images/oma.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "/images/see.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "/images/feier.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3, + x: 14, + imageUrl: + "/images/hochzeit.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "/images/work.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "/images/klasse.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "/images/familie.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "/images/kinobesuch.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "/images/entspannung.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "/images/sonntag.png", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "/images/kindergeburtstag.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "/images/familie2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "/images/grosseltern.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX; + // let scrollLeft; + let scrollLeft: number = scrollContainer.scrollLeft; // Initialize and type scrollLeft + + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250523080510.ts b/dot-line-system/.history/src/main_20250523080510.ts new file mode 100644 index 0000000..8fc9dd2 --- /dev/null +++ b/dot-line-system/.history/src/main_20250523080510.ts @@ -0,0 +1,321 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +import '../src/style.css'; + +/* + * If you are using a bundler like Vite, Webpack, or similar, you need to ensure that the `src/images` folder is included in your build output. + * + * For Vite: + * - Place your images in the `public/images` directory instead of `src/images`. + * - Reference them as `/images/filename.png` in your code. + * + * For Webpack: + * - Use `require` or `import` for images, or configure `copy-webpack-plugin` to copy the `src/images` folder to your output directory. + * + * For static hosting (e.g., GitHub Pages, Netlify): + * - Make sure the images are in the output directory (e.g., `dist/images`) after build. + * + * Example for Vite: + * Move images to `public/images` and update imageUrl paths to `/images/filename.png`. + */ + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "/images/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "/images/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "/images/disco.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "/images/pferd.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "/images/gpt.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "/images/oma.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "/images/see.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "/images/feier.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3, + x: 14, + imageUrl: + "/images/hochzeit.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "/images/work.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "/images/klasse.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "/images/familie.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "/images/kinobesuch.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "/images/entspannung.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "/images/sonntag.png", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "/images/kindergeburtstag.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "/images/familie2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "/images/grosseltern.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + +// Add a null check to ensure scrollContainer is not null +if (scrollContainer) { + // Cast scrollContainer as HTMLElement if necessary + const container = scrollContainer as HTMLElement; + + // Your event listener logic here + container.addEventListener('mousemove', (e: MouseEvent) => { + // It's safe to use offsetLeft and scrollLeft because we've checked for null + const x = e.pageX - container.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + container.scrollLeft -= walk; + }); +} else { + console.error("Scroll container not found. Please check the element ID."); +} + + let isDown = false; + let startX; + // let scrollLeft; + let scrollLeft: number = scrollContainer.scrollLeft; // Initialize and type scrollLeft + + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250523080542.ts b/dot-line-system/.history/src/main_20250523080542.ts new file mode 100644 index 0000000..8dd1ba0 --- /dev/null +++ b/dot-line-system/.history/src/main_20250523080542.ts @@ -0,0 +1,321 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +import '../src/style.css'; + +/* + * If you are using a bundler like Vite, Webpack, or similar, you need to ensure that the `src/images` folder is included in your build output. + * + * For Vite: + * - Place your images in the `public/images` directory instead of `src/images`. + * - Reference them as `/images/filename.png` in your code. + * + * For Webpack: + * - Use `require` or `import` for images, or configure `copy-webpack-plugin` to copy the `src/images` folder to your output directory. + * + * For static hosting (e.g., GitHub Pages, Netlify): + * - Make sure the images are in the output directory (e.g., `dist/images`) after build. + * + * Example for Vite: + * Move images to `public/images` and update imageUrl paths to `/images/filename.png`. + */ + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "/images/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "/images/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "/images/disco.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "/images/pferd.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "/images/gpt.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "/images/oma.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "/images/see.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "/images/feier.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3, + x: 14, + imageUrl: + "/images/hochzeit.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "/images/work.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "/images/klasse.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "/images/familie.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "/images/kinobesuch.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "/images/entspannung.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "/images/sonntag.png", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "/images/kindergeburtstag.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "/images/familie2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "/images/grosseltern.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + +// Add a null check to ensure scrollContainer is not null +if (scrollContainer) { + // Cast scrollContainer as HTMLElement if necessary + const container = scrollContainer as HTMLElement; + + // Your event listener logic here + container.addEventListener('mousemove', (e: MouseEvent) => { + // It's safe to use offsetLeft and scrollLeft because we've checked for null + const x = e.pageX - container.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + container.scrollLeft -= walk; + }); +} else { + console.error("Scroll container not found. Please check the element ID."); +} + + let isDown = false; + let startX: number; + // let scrollLeft; + let scrollLeft: number = scrollContainer.scrollLeft; // Initialize and type scrollLeft + + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250523080609.ts b/dot-line-system/.history/src/main_20250523080609.ts new file mode 100644 index 0000000..f018b74 --- /dev/null +++ b/dot-line-system/.history/src/main_20250523080609.ts @@ -0,0 +1,305 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +import '../src/style.css'; + +/* + * If you are using a bundler like Vite, Webpack, or similar, you need to ensure that the `src/images` folder is included in your build output. + * + * For Vite: + * - Place your images in the `public/images` directory instead of `src/images`. + * - Reference them as `/images/filename.png` in your code. + * + * For Webpack: + * - Use `require` or `import` for images, or configure `copy-webpack-plugin` to copy the `src/images` folder to your output directory. + * + * For static hosting (e.g., GitHub Pages, Netlify): + * - Make sure the images are in the output directory (e.g., `dist/images`) after build. + * + * Example for Vite: + * Move images to `public/images` and update imageUrl paths to `/images/filename.png`. + */ + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "/images/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "/images/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "/images/disco.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "/images/pferd.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "/images/gpt.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "/images/oma.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "/images/see.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "/images/feier.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3, + x: 14, + imageUrl: + "/images/hochzeit.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "/images/work.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "/images/klasse.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "/images/familie.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "/images/kinobesuch.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "/images/entspannung.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "/images/sonntag.png", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "/images/kindergeburtstag.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "/images/familie2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "/images/grosseltern.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container"); + + let isDown = false; + let startX: number; + // let scrollLeft; + let scrollLeft: number = scrollContainer.scrollLeft; // Initialize and type scrollLeft + + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("mouseleave", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mouseup", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + // Use the first touch point for calculations + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + }); + + scrollContainer.addEventListener("touchend", () => { + isDown = false; + scrollContainer.classList.remove("active"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + // Use the first touch point for calculations + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/main_20250523080934.ts b/dot-line-system/.history/src/main_20250523080934.ts new file mode 100644 index 0000000..cac6f1b --- /dev/null +++ b/dot-line-system/.history/src/main_20250523080934.ts @@ -0,0 +1,320 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +import '../src/style.css'; + +/* + * If you are using a bundler like Vite, Webpack, or similar, you need to ensure that the `src/images` folder is included in your build output. + * + * For Vite: + * - Place your images in the `public/images` directory instead of `src/images`. + * - Reference them as `/images/filename.png` in your code. + * + * For Webpack: + * - Use `require` or `import` for images, or configure `copy-webpack-plugin` to copy the `src/images` folder to your output directory. + * + * For static hosting (e.g., GitHub Pages, Netlify): + * - Make sure the images are in the output directory (e.g., `dist/images`) after build. + * + * Example for Vite: + * Move images to `public/images` and update imageUrl paths to `/images/filename.png`. + */ + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "/images/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "/images/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "/images/disco.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "/images/pferd.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "/images/gpt.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "/images/oma.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "/images/see.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "/images/feier.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3, + x: 14, + imageUrl: + "/images/hochzeit.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "/images/work.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "/images/klasse.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "/images/familie.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "/images/kinobesuch.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "/images/entspannung.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "/images/sonntag.png", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "/images/kindergeburtstag.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "/images/familie2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "/images/grosseltern.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container") as HTMLElement; + + let isDown = false; + let startX: number; + let scrollLeft: number; + + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + + // Remove smooth scrolling while dragging + scrollContainer.classList.remove("smooth-scroll"); + }); + + scrollContainer.addEventListener("mouseleave", () => { + if (!isDown) return; + isDown = false; + scrollContainer.classList.remove("active"); + + // Add smooth scrolling after dragging + scrollContainer.classList.add("smooth-scroll"); + }); + + scrollContainer.addEventListener("mouseup", () => { + if (!isDown) return; + isDown = false; + scrollContainer.classList.remove("active"); + + // Add smooth scrolling after dragging + scrollContainer.classList.add("smooth-scroll"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + + // Remove smooth scrolling while dragging + scrollContainer.classList.remove("smooth-scroll"); + }); + + scrollContainer.addEventListener("touchend", () => { + if (!isDown) return; + isDown = false; + scrollContainer.classList.remove("active"); + + // Add smooth scrolling after dragging + scrollContainer.classList.add("smooth-scroll"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/.history/src/style_20250515080205.css b/dot-line-system/.history/src/style_20250515080205.css new file mode 100644 index 0000000..e69de29 diff --git a/dot-line-system/.history/src/style_20250522085955.css b/dot-line-system/.history/src/style_20250522085955.css new file mode 100644 index 0000000..4da039c --- /dev/null +++ b/dot-line-system/.history/src/style_20250522085955.css @@ -0,0 +1,67 @@ + body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522090021.css b/dot-line-system/.history/src/style_20250522090021.css new file mode 100644 index 0000000..2e644ca --- /dev/null +++ b/dot-line-system/.history/src/style_20250522090021.css @@ -0,0 +1,68 @@ + body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522090641.css b/dot-line-system/.history/src/style_20250522090641.css new file mode 100644 index 0000000..a4c667e --- /dev/null +++ b/dot-line-system/.history/src/style_20250522090641.css @@ -0,0 +1,74 @@ + body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + height: 1px; + width: 100%; + background-color: #fff; +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522090651.css b/dot-line-system/.history/src/style_20250522090651.css new file mode 100644 index 0000000..1d47c53 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522090651.css @@ -0,0 +1,74 @@ + body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + height: 1px; + width: 100%; + background-color: red; +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522090747.css b/dot-line-system/.history/src/style_20250522090747.css new file mode 100644 index 0000000..b3d6fd3 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522090747.css @@ -0,0 +1,77 @@ + body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + display: flex; +justify-items: center; + + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + height: 1px; + width: 100%; + background-color: red; +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522090807.css b/dot-line-system/.history/src/style_20250522090807.css new file mode 100644 index 0000000..d12bb43 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522090807.css @@ -0,0 +1,74 @@ + body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + height: 1px; + width: 100%; + background-color: red; +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522090836.css b/dot-line-system/.history/src/style_20250522090836.css new file mode 100644 index 0000000..1274256 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522090836.css @@ -0,0 +1,76 @@ + body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + height: 1px; + width: 100%; + background-color: red; +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522090841.css b/dot-line-system/.history/src/style_20250522090841.css new file mode 100644 index 0000000..31dd748 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522090841.css @@ -0,0 +1,77 @@ + body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + background-color: red; +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522090850.css b/dot-line-system/.history/src/style_20250522090850.css new file mode 100644 index 0000000..b987a9b --- /dev/null +++ b/dot-line-system/.history/src/style_20250522090850.css @@ -0,0 +1,77 @@ + body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + background-color: white; +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522090854.css b/dot-line-system/.history/src/style_20250522090854.css new file mode 100644 index 0000000..29255e3 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522090854.css @@ -0,0 +1,77 @@ + body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 2px; + width: 100%; + background-color: white; +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522090906.css b/dot-line-system/.history/src/style_20250522090906.css new file mode 100644 index 0000000..b987a9b --- /dev/null +++ b/dot-line-system/.history/src/style_20250522090906.css @@ -0,0 +1,77 @@ + body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + background-color: white; +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522090923.css b/dot-line-system/.history/src/style_20250522090923.css new file mode 100644 index 0000000..f070a59 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522090923.css @@ -0,0 +1,77 @@ + body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + background-color: rgba(255, 255, 255, 0.5); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522090926.css b/dot-line-system/.history/src/style_20250522090926.css new file mode 100644 index 0000000..c53bbb9 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522090926.css @@ -0,0 +1,77 @@ + body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + background-color: rgba(255, 255, 255, 0.2); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522090936.css b/dot-line-system/.history/src/style_20250522090936.css new file mode 100644 index 0000000..e5b0ed4 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522090936.css @@ -0,0 +1,78 @@ + body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.2); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522090943.css b/dot-line-system/.history/src/style_20250522090943.css new file mode 100644 index 0000000..e051081 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522090943.css @@ -0,0 +1,78 @@ + body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522093837.css b/dot-line-system/.history/src/style_20250522093837.css new file mode 100644 index 0000000..2b1739d --- /dev/null +++ b/dot-line-system/.history/src/style_20250522093837.css @@ -0,0 +1,112 @@ + body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: 50px; + height: 50px; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: bold; +} + +.dot-tooltip .tooltip-description { + font-size: 12px; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522093851.css b/dot-line-system/.history/src/style_20250522093851.css new file mode 100644 index 0000000..2ca9fff --- /dev/null +++ b/dot-line-system/.history/src/style_20250522093851.css @@ -0,0 +1,112 @@ + body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: 80px; + height: 80px; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: bold; +} + +.dot-tooltip .tooltip-description { + font-size: 12px; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522093915.css b/dot-line-system/.history/src/style_20250522093915.css new file mode 100644 index 0000000..53d6c1c --- /dev/null +++ b/dot-line-system/.history/src/style_20250522093915.css @@ -0,0 +1,113 @@ + body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: 80px; + height: 80px; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: bold; + margin-top: 4px; +} + +.dot-tooltip .tooltip-description { + font-size: 12px; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522093919.css b/dot-line-system/.history/src/style_20250522093919.css new file mode 100644 index 0000000..eb5587f --- /dev/null +++ b/dot-line-system/.history/src/style_20250522093919.css @@ -0,0 +1,113 @@ + body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: 80px; + height: 80px; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: bold; + margin-top: 8px; +} + +.dot-tooltip .tooltip-description { + font-size: 12px; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522093925.css b/dot-line-system/.history/src/style_20250522093925.css new file mode 100644 index 0000000..65db527 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522093925.css @@ -0,0 +1,113 @@ + body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: 80px; + height: 80px; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: bold; + margin-top: 8px; +} + +.dot-tooltip .tooltip-description { + font-size: 12px; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522095000.css b/dot-line-system/.history/src/style_20250522095000.css new file mode 100644 index 0000000..f67af40 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522095000.css @@ -0,0 +1,114 @@ + body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: 80px; + height: 80px; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: bold; + margin-top: 8px; + text-align: center; +} + +.dot-tooltip .tooltip-description { + font-size: 12px; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522095014.css b/dot-line-system/.history/src/style_20250522095014.css new file mode 100644 index 0000000..34ee22a --- /dev/null +++ b/dot-line-system/.history/src/style_20250522095014.css @@ -0,0 +1,115 @@ + body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: 80px; + height: 80px; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: bold; + margin-top: 8px; + text-align: center; + text-wrap: balanced; +} + +.dot-tooltip .tooltip-description { + font-size: 12px; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522095017.css b/dot-line-system/.history/src/style_20250522095017.css new file mode 100644 index 0000000..34ee22a --- /dev/null +++ b/dot-line-system/.history/src/style_20250522095017.css @@ -0,0 +1,115 @@ + body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: 80px; + height: 80px; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: bold; + margin-top: 8px; + text-align: center; + text-wrap: balanced; +} + +.dot-tooltip .tooltip-description { + font-size: 12px; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522095208.css b/dot-line-system/.history/src/style_20250522095208.css new file mode 100644 index 0000000..08ba4b8 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522095208.css @@ -0,0 +1,119 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: 80px; + height: 80px; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: bold; + margin-top: 8px; + text-align: center; + text-wrap: balanced; +} + +.dot-tooltip .tooltip-description { + font-size: 12px; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522095223.css b/dot-line-system/.history/src/style_20250522095223.css new file mode 100644 index 0000000..dbdb377 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522095223.css @@ -0,0 +1,119 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: 80px; + height: 80px; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: light; + margin-top: 8px; + text-align: center; + text-wrap: balanced; +} + +.dot-tooltip .tooltip-description { + font-size: 12px; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522095304.css b/dot-line-system/.history/src/style_20250522095304.css new file mode 100644 index 0000000..64a4e78 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522095304.css @@ -0,0 +1,119 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: 80px; + height: 80px; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: light; + margin-top: 8px; + text-align: center; + text-wrap: balanced; +} + +.dot-tooltip .tooltip-description { + font-size: 10px; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522095307.css b/dot-line-system/.history/src/style_20250522095307.css new file mode 100644 index 0000000..dbdb377 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522095307.css @@ -0,0 +1,119 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: 80px; + height: 80px; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: light; + margin-top: 8px; + text-align: center; + text-wrap: balanced; +} + +.dot-tooltip .tooltip-description { + font-size: 12px; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522095311.css b/dot-line-system/.history/src/style_20250522095311.css new file mode 100644 index 0000000..5a007d4 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522095311.css @@ -0,0 +1,119 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: 80px; + height: 80px; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: light; + margin-top: 8px; + text-align: center; + text-wrap: balanced; +} + +.dot-tooltip .tooltip-description { + font-size: 12px; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522095317.css b/dot-line-system/.history/src/style_20250522095317.css new file mode 100644 index 0000000..77640c3 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522095317.css @@ -0,0 +1,119 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: 80px; + height: 80px; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: light; + margin-top: 8px; + text-align: center; + text-wrap: balanced; +} + +.dot-tooltip .tooltip-description { + font-size: 14px; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522095407.css b/dot-line-system/.history/src/style_20250522095407.css new file mode 100644 index 0000000..f18c8fe --- /dev/null +++ b/dot-line-system/.history/src/style_20250522095407.css @@ -0,0 +1,120 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: 80px; + height: 80px; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: light; + margin-top: 8px; + text-align: center; + text-wrap: balanced; +} + +.dot-tooltip .tooltip-description { + font-size: 14px; + margin-bottom: 4px; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522095421.css b/dot-line-system/.history/src/style_20250522095421.css new file mode 100644 index 0000000..3b30efd --- /dev/null +++ b/dot-line-system/.history/src/style_20250522095421.css @@ -0,0 +1,121 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: 80px; + height: 80px; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: light; + margin-top: 8px; + text-align: center; + text-wrap: balanced; +} + +.dot-tooltip .tooltip-description { + font-size: 14px; + font-weight: thin; + margin-bottom: 4px; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522095426.css b/dot-line-system/.history/src/style_20250522095426.css new file mode 100644 index 0000000..f40981b --- /dev/null +++ b/dot-line-system/.history/src/style_20250522095426.css @@ -0,0 +1,121 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: 80px; + height: 80px; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: light; + margin-top: 8px; + text-align: center; + text-wrap: balanced; +} + +.dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: thin; + margin-bottom: 4px; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522095430.css b/dot-line-system/.history/src/style_20250522095430.css new file mode 100644 index 0000000..5326195 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522095430.css @@ -0,0 +1,121 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: 80px; + height: 80px; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-title { + font-size: 16px; + font-weight: light; + margin-top: 8px; + text-align: center; + text-wrap: balanced; +} + +.dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: thin; + margin-bottom: 4px; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522095436.css b/dot-line-system/.history/src/style_20250522095436.css new file mode 100644 index 0000000..1d8faee --- /dev/null +++ b/dot-line-system/.history/src/style_20250522095436.css @@ -0,0 +1,121 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: 80px; + height: 80px; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: light; + margin-top: 8px; + text-align: center; + text-wrap: balanced; +} + +.dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: thin; + margin-bottom: 4px; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522095552.css b/dot-line-system/.history/src/style_20250522095552.css new file mode 100644 index 0000000..145fa00 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522095552.css @@ -0,0 +1,122 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: 80px; + height: 80px; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: light; + margin-top: 8px; + text-align: center; + text-wrap: balanced; + hyphens: auto; +} + +.dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: thin; + margin-bottom: 4px; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522095554.css b/dot-line-system/.history/src/style_20250522095554.css new file mode 100644 index 0000000..145fa00 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522095554.css @@ -0,0 +1,122 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: 80px; + height: 80px; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: light; + margin-top: 8px; + text-align: center; + text-wrap: balanced; + hyphens: auto; +} + +.dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: thin; + margin-bottom: 4px; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522095604.css b/dot-line-system/.history/src/style_20250522095604.css new file mode 100644 index 0000000..529c2d9 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522095604.css @@ -0,0 +1,123 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: 80px; + height: 80px; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: light; + margin-top: 8px; + text-align: center; + text-wrap: balanced; + hyphens: auto; + white-space: wrap; +} + +.dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: thin; + margin-bottom: 4px; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522095617.css b/dot-line-system/.history/src/style_20250522095617.css new file mode 100644 index 0000000..145fa00 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522095617.css @@ -0,0 +1,122 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: 80px; + height: 80px; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: light; + margin-top: 8px; + text-align: center; + text-wrap: balanced; + hyphens: auto; +} + +.dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: thin; + margin-bottom: 4px; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522100913.css b/dot-line-system/.history/src/style_20250522100913.css new file mode 100644 index 0000000..318d2c7 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522100913.css @@ -0,0 +1,122 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: 80px; + height: 80px; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: light; + margin-top: 8px; + text-align: center; + text-wrap: balanced; + hyphens: auto; +} + +.dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: thin; + margin-bottom: 4px; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522100924.css b/dot-line-system/.history/src/style_20250522100924.css new file mode 100644 index 0000000..d86863d --- /dev/null +++ b/dot-line-system/.history/src/style_20250522100924.css @@ -0,0 +1,122 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: 80px; + height: 80px; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-top: 8px; + text-align: center; + text-wrap: balanced; + hyphens: auto; +} + +.dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + margin-bottom: 4px; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522100934.css b/dot-line-system/.history/src/style_20250522100934.css new file mode 100644 index 0000000..7358538 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522100934.css @@ -0,0 +1,122 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: 80px; + height: 80px; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-top: 8px; + text-align: center; + text-wrap: balanced; + hyphens: auto; +} + +.dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + margin-bottom: 4px; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522100943.css b/dot-line-system/.history/src/style_20250522100943.css new file mode 100644 index 0000000..7ee9f9f --- /dev/null +++ b/dot-line-system/.history/src/style_20250522100943.css @@ -0,0 +1,122 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: 80px; + height: 80px; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-top: 8px; + text-align: center; + text-wrap: balance; + hyphens: auto; +} + +.dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + margin-bottom: 4px; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522101311.css b/dot-line-system/.history/src/style_20250522101311.css new file mode 100644 index 0000000..ebeb77c --- /dev/null +++ b/dot-line-system/.history/src/style_20250522101311.css @@ -0,0 +1,127 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: 80px; + height: 80px; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-top: 8px; + text-align: center; + text-wrap: balance; + hyphens: auto; +} + +.dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + margin-bottom: 4px; +} +.dot-tooltip .image_container{ + width: 80px; + height: 80px; + overflow: hidden; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522101328.css b/dot-line-system/.history/src/style_20250522101328.css new file mode 100644 index 0000000..6cb0457 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522101328.css @@ -0,0 +1,127 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: auto; + height: 100%; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-top: 8px; + text-align: center; + text-wrap: balance; + hyphens: auto; +} + +.dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + margin-bottom: 4px; +} +.dot-tooltip .image_container{ + width: 80px; + height: 80px; + overflow: hidden; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522101336.css b/dot-line-system/.history/src/style_20250522101336.css new file mode 100644 index 0000000..15eae64 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522101336.css @@ -0,0 +1,128 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); +} + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + +.median{ + position: fixed; + top:50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); +} + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); +} + +.dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; /* Center vertically */ + align-items: center; /* Center horizontally */ + width: 100%; + height: 100%; + color: white; /* Text color */ +} + +.dot-tooltip .tooltip-image { + width: auto; + height: 100%; + +} + +.dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-top: 8px; + text-align: center; + text-wrap: balance; + hyphens: auto; +} + +.dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + margin-bottom: 4px; +} +.dot-tooltip .image_container{ + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; /* Circular image */ + border: 2px solid white; +} + +.dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); +} diff --git a/dot-line-system/.history/src/style_20250522101350.css b/dot-line-system/.history/src/style_20250522101350.css new file mode 100644 index 0000000..3195d8e --- /dev/null +++ b/dot-line-system/.history/src/style_20250522101350.css @@ -0,0 +1,132 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-top: 8px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + margin-bottom: 4px; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + /* Circular image */ + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522102626.css b/dot-line-system/.history/src/style_20250522102626.css new file mode 100644 index 0000000..f78cbe0 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522102626.css @@ -0,0 +1,133 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-top: 8px; + text-align: center; + text-wrap: balance; + hyphens: auto; + max-width: 100%; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + margin-bottom: 4px; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + /* Circular image */ + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522102642.css b/dot-line-system/.history/src/style_20250522102642.css new file mode 100644 index 0000000..3195d8e --- /dev/null +++ b/dot-line-system/.history/src/style_20250522102642.css @@ -0,0 +1,132 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-top: 8px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + margin-bottom: 4px; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + /* Circular image */ + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522103246.css b/dot-line-system/.history/src/style_20250522103246.css new file mode 100644 index 0000000..6800536 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522103246.css @@ -0,0 +1,133 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + margin-top: 4px; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-top: 8px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + margin-bottom: 4px; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + /* Circular image */ + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522103250.css b/dot-line-system/.history/src/style_20250522103250.css new file mode 100644 index 0000000..6800536 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522103250.css @@ -0,0 +1,133 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + margin-top: 4px; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-top: 8px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + margin-bottom: 4px; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + /* Circular image */ + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522103312.css b/dot-line-system/.history/src/style_20250522103312.css new file mode 100644 index 0000000..2738b91 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522103312.css @@ -0,0 +1,132 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + margin-top: 4px; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 4px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + /* Circular image */ + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522103342.css b/dot-line-system/.history/src/style_20250522103342.css new file mode 100644 index 0000000..36da931 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522103342.css @@ -0,0 +1,140 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + + + .dot-tooltip .image_container { + margin-top: 8px; + + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 4px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + /* Circular image */ + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522103350.css b/dot-line-system/.history/src/style_20250522103350.css new file mode 100644 index 0000000..22f9087 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522103350.css @@ -0,0 +1,140 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + + + .dot-tooltip .image_container { + margin-top: 8px; + + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + /* Circular image */ + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522103407.css b/dot-line-system/.history/src/style_20250522103407.css new file mode 100644 index 0000000..7291bd9 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522103407.css @@ -0,0 +1,134 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + fill: rgba(0, 0, 0, 0.8); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522103422.css b/dot-line-system/.history/src/style_20250522103422.css new file mode 100644 index 0000000..282e4b1 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522103422.css @@ -0,0 +1,135 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + /* fill: rgba(0, 0, 0, 0.8); */ + fill: rgba(255, 255, 255, 0.8); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522103426.css b/dot-line-system/.history/src/style_20250522103426.css new file mode 100644 index 0000000..8e2cc8c --- /dev/null +++ b/dot-line-system/.history/src/style_20250522103426.css @@ -0,0 +1,134 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.8); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + fill: rgba(255, 255, 255, 0.8); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522103431.css b/dot-line-system/.history/src/style_20250522103431.css new file mode 100644 index 0000000..f8f50b2 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522103431.css @@ -0,0 +1,134 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + /* fill: rgba(0, 0, 0, 0.8); */ + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + fill: rgba(255, 255, 255, 0.8); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522103440.css b/dot-line-system/.history/src/style_20250522103440.css new file mode 100644 index 0000000..c6ad579 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522103440.css @@ -0,0 +1,135 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + fill: rgba(255, 255, 255, 0.8); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522104922.css b/dot-line-system/.history/src/style_20250522104922.css new file mode 100644 index 0000000..ff58dd6 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522104922.css @@ -0,0 +1,147 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + fill: rgba(255, 255, 255, 1); + } + + .arrow { + width: 100px; /* Adjust the length of the arrow as needed */ + height: 1px; + background: linear-gradient(to right, transparent, black, transparent); + position: relative; /* Allows positioning if needed */ +} + +/* Optional: To rotate or position the arrow */ +.arrow-vertical { + transform: rotate(90deg); /* Rotates the arrow to vertical */ +} \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522105207.css b/dot-line-system/.history/src/style_20250522105207.css new file mode 100644 index 0000000..f5a302f --- /dev/null +++ b/dot-line-system/.history/src/style_20250522105207.css @@ -0,0 +1,148 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + /* fill: rgba(255, 255, 255, 1); */ + fill: linear-gradient(to right, transparent, black, transparent);; + } + + .arrow { + width: 100px; /* Adjust the length of the arrow as needed */ + height: 1px; + background: linear-gradient(to right, transparent, black, transparent); + position: relative; /* Allows positioning if needed */ +} + +/* Optional: To rotate or position the arrow */ +.arrow-vertical { + transform: rotate(90deg); /* Rotates the arrow to vertical */ +} \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522105209.css b/dot-line-system/.history/src/style_20250522105209.css new file mode 100644 index 0000000..8b92c3a --- /dev/null +++ b/dot-line-system/.history/src/style_20250522105209.css @@ -0,0 +1,148 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + /* fill: rgba(255, 255, 255, 1); */ + fill: linear-gradient(to right, transparent, black, transparent); + } + + .arrow { + width: 100px; /* Adjust the length of the arrow as needed */ + height: 1px; + background: linear-gradient(to right, transparent, black, transparent); + position: relative; /* Allows positioning if needed */ +} + +/* Optional: To rotate or position the arrow */ +.arrow-vertical { + transform: rotate(90deg); /* Rotates the arrow to vertical */ +} \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522105222.css b/dot-line-system/.history/src/style_20250522105222.css new file mode 100644 index 0000000..05e6203 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522105222.css @@ -0,0 +1,136 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + /* fill: rgba(255, 255, 255, 1); */ + fill: linear-gradient(to right, transparent, black, transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522110436.css b/dot-line-system/.history/src/style_20250522110436.css new file mode 100644 index 0000000..05e6203 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522110436.css @@ -0,0 +1,136 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + /* fill: rgba(255, 255, 255, 1); */ + fill: linear-gradient(to right, transparent, black, transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522112314.css b/dot-line-system/.history/src/style_20250522112314.css new file mode 100644 index 0000000..8f3be83 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522112314.css @@ -0,0 +1,140 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + /* fill: rgba(255, 255, 255, 1); */ + /* fill: linear-gradient(to right, transparent, black, transparent); */ + width: 1px; + height: 20px; + background: linear-gradient(to right, transparent, black, transparent); + +} \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522112321.css b/dot-line-system/.history/src/style_20250522112321.css new file mode 100644 index 0000000..681916f --- /dev/null +++ b/dot-line-system/.history/src/style_20250522112321.css @@ -0,0 +1,140 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + /* fill: rgba(255, 255, 255, 1); */ + /* fill: linear-gradient(to right, transparent, black, transparent); */ + width: 2px; + height: 20px; + background: linear-gradient(to right, transparent, black, transparent); + +} \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522112533.css b/dot-line-system/.history/src/style_20250522112533.css new file mode 100644 index 0000000..231076b --- /dev/null +++ b/dot-line-system/.history/src/style_20250522112533.css @@ -0,0 +1,140 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + /* fill: rgba(255, 255, 255, 1); */ + /* fill: linear-gradient(to right, transparent, black, transparent); */ + width: 2px; + height: 20px; + background: linear-gradient(to right, transparent, white, transparent); + +} \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522112544.css b/dot-line-system/.history/src/style_20250522112544.css new file mode 100644 index 0000000..2acccb8 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522112544.css @@ -0,0 +1,140 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + /* fill: rgba(255, 255, 255, 1); */ + /* fill: linear-gradient(to right, transparent, black, transparent); */ + width: 2px; + height: 20px; + background: linear-gradient(to bottom, transparent, white, transparent); + +} \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522112548.css b/dot-line-system/.history/src/style_20250522112548.css new file mode 100644 index 0000000..f3de22d --- /dev/null +++ b/dot-line-system/.history/src/style_20250522112548.css @@ -0,0 +1,140 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + /* fill: rgba(255, 255, 255, 1); */ + /* fill: linear-gradient(to right, transparent, black, transparent); */ + width: 2px; + height: 30px; + background: linear-gradient(to bottom, transparent, white, transparent); + +} \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522112553.css b/dot-line-system/.history/src/style_20250522112553.css new file mode 100644 index 0000000..ed5e837 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522112553.css @@ -0,0 +1,140 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + /* fill: rgba(255, 255, 255, 1); */ + /* fill: linear-gradient(to right, transparent, black, transparent); */ + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, white, transparent); + +} \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522112559.css b/dot-line-system/.history/src/style_20250522112559.css new file mode 100644 index 0000000..ba447d1 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522112559.css @@ -0,0 +1,140 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + /* fill: rgba(255, 255, 255, 1); */ + /* fill: linear-gradient(to right, transparent, black, transparent); */ + width: 1px; + height: 40px; + background: linear-gradient(to bottom, transparent, white, transparent); + +} \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522112603.css b/dot-line-system/.history/src/style_20250522112603.css new file mode 100644 index 0000000..ed5e837 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522112603.css @@ -0,0 +1,140 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + /* fill: rgba(255, 255, 255, 1); */ + /* fill: linear-gradient(to right, transparent, black, transparent); */ + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, white, transparent); + +} \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522112612.css b/dot-line-system/.history/src/style_20250522112612.css new file mode 100644 index 0000000..74ae135 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522112612.css @@ -0,0 +1,140 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + /* fill: rgba(255, 255, 255, 1); */ + /* fill: linear-gradient(to right, transparent, black, transparent); */ + width: 1px; + height: 20px; + background: linear-gradient(to bottom, transparent, white, transparent); + +} \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522112618.css b/dot-line-system/.history/src/style_20250522112618.css new file mode 100644 index 0000000..ed5e837 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522112618.css @@ -0,0 +1,140 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + /* fill: rgba(255, 255, 255, 1); */ + /* fill: linear-gradient(to right, transparent, black, transparent); */ + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, white, transparent); + +} \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522112638.css b/dot-line-system/.history/src/style_20250522112638.css new file mode 100644 index 0000000..c2edfc1 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522112638.css @@ -0,0 +1,138 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, white, transparent); + +} \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522112644.css b/dot-line-system/.history/src/style_20250522112644.css new file mode 100644 index 0000000..3eae7bd --- /dev/null +++ b/dot-line-system/.history/src/style_20250522112644.css @@ -0,0 +1,138 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.5); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, white, transparent); + +} \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522112711.css b/dot-line-system/.history/src/style_20250522112711.css new file mode 100644 index 0000000..c2edfc1 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522112711.css @@ -0,0 +1,138 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, white, transparent); + +} \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522112732.css b/dot-line-system/.history/src/style_20250522112732.css new file mode 100644 index 0000000..0ee5c86 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522112732.css @@ -0,0 +1,138 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.5), transparent); + +} \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522113350.css b/dot-line-system/.history/src/style_20250522113350.css new file mode 100644 index 0000000..8ff1312 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522113350.css @@ -0,0 +1,140 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.5), transparent); + +} \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522113403.css b/dot-line-system/.history/src/style_20250522113403.css new file mode 100644 index 0000000..64594ca --- /dev/null +++ b/dot-line-system/.history/src/style_20250522113403.css @@ -0,0 +1,141 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.5), transparent); + +} \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522113810.css b/dot-line-system/.history/src/style_20250522113810.css new file mode 100644 index 0000000..3ce3551 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522113810.css @@ -0,0 +1,142 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.5), transparent); + +} \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522114215.css b/dot-line-system/.history/src/style_20250522114215.css new file mode 100644 index 0000000..95101fc --- /dev/null +++ b/dot-line-system/.history/src/style_20250522114215.css @@ -0,0 +1,169 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + +.dynamic-gradient-bg { + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98); + background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /*background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; +} + +@keyframes gradientAnimation { + 0% { + background-position: 0% 0%; /* Start Links Mitte */ + } + 25% { + background-position: 100% 0%; /* Oben Rechts */ + } + 50% { + background-position: 100% 100%; /* Unten Rechts */ + } + 75% { + background-position: 0% 100%; /* Unten Links */ + } + 100% { + background-position: 0% 0%; /* Zurück zum Start Links Mitte */ + } +} + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.5), transparent); + +} \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522114227.css b/dot-line-system/.history/src/style_20250522114227.css new file mode 100644 index 0000000..649bee8 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522114227.css @@ -0,0 +1,169 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + +.gradient-bg { + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98); + background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /*background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; +} + +@keyframes gradientAnimation { + 0% { + background-position: 0% 0%; /* Start Links Mitte */ + } + 25% { + background-position: 100% 0%; /* Oben Rechts */ + } + 50% { + background-position: 100% 100%; /* Unten Rechts */ + } + 75% { + background-position: 0% 100%; /* Unten Links */ + } + 100% { + background-position: 0% 0%; /* Zurück zum Start Links Mitte */ + } +} + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.5), transparent); + +} \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522114320.css b/dot-line-system/.history/src/style_20250522114320.css new file mode 100644 index 0000000..649bee8 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522114320.css @@ -0,0 +1,169 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + +.gradient-bg { + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98); + background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /*background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; +} + +@keyframes gradientAnimation { + 0% { + background-position: 0% 0%; /* Start Links Mitte */ + } + 25% { + background-position: 100% 0%; /* Oben Rechts */ + } + 50% { + background-position: 100% 100%; /* Unten Rechts */ + } + 75% { + background-position: 0% 100%; /* Unten Links */ + } + 100% { + background-position: 0% 0%; /* Zurück zum Start Links Mitte */ + } +} + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.5), transparent); + +} \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522114407.css b/dot-line-system/.history/src/style_20250522114407.css new file mode 100644 index 0000000..95101fc --- /dev/null +++ b/dot-line-system/.history/src/style_20250522114407.css @@ -0,0 +1,169 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + +.dynamic-gradient-bg { + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98); + background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /*background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; +} + +@keyframes gradientAnimation { + 0% { + background-position: 0% 0%; /* Start Links Mitte */ + } + 25% { + background-position: 100% 0%; /* Oben Rechts */ + } + 50% { + background-position: 100% 100%; /* Unten Rechts */ + } + 75% { + background-position: 0% 100%; /* Unten Links */ + } + 100% { + background-position: 0% 0%; /* Zurück zum Start Links Mitte */ + } +} + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.5), transparent); + +} \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522114517.css b/dot-line-system/.history/src/style_20250522114517.css new file mode 100644 index 0000000..340da50 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522114517.css @@ -0,0 +1,169 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + +.dynamic-gradient-bg { + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98); + background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /*background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; +} + +@keyframes gradientAnimation { + 0% { + background-position: 0% 0%; /* Start Links Mitte */ + } + 25% { + background-position: 100% 0%; /* Oben Rechts */ + } + 50% { + background-position: 100% 100%; /* Unten Rechts */ + } + 75% { + background-position: 0% 100%; /* Unten Links */ + } + 100% { + background-position: 0% 0%; /* Zurück zum Start Links Mitte */ + } +} + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } +/* + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); + z-index: -1; + } */ + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.5), transparent); + +} \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522114533.css b/dot-line-system/.history/src/style_20250522114533.css new file mode 100644 index 0000000..257a13b --- /dev/null +++ b/dot-line-system/.history/src/style_20250522114533.css @@ -0,0 +1,171 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + + +@keyframes gradientAnimation { + 0% { + background-position: 0% 0%; /* Start Links Mitte */ + } + 25% { + background-position: 100% 0%; /* Oben Rechts */ + } + 50% { + background-position: 100% 100%; /* Unten Rechts */ + } + 75% { + background-position: 0% 100%; /* Unten Links */ + } + 100% { + background-position: 0% 0%; /* Zurück zum Start Links Mitte */ + } +} + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + z-index: -1; + } + + .dynamic-gradient-bg { + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98); + background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /*background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; +} + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.5), transparent); + +} \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522114538.css b/dot-line-system/.history/src/style_20250522114538.css new file mode 100644 index 0000000..fe18e47 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522114538.css @@ -0,0 +1,169 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + + +@keyframes gradientAnimation { + 0% { + background-position: 0% 0%; /* Start Links Mitte */ + } + 25% { + background-position: 100% 0%; /* Oben Rechts */ + } + 50% { + background-position: 100% 100%; /* Unten Rechts */ + } + 75% { + background-position: 0% 100%; /* Unten Links */ + } + 100% { + background-position: 0% 0%; /* Zurück zum Start Links Mitte */ + } +} + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + z-index: -1; + + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98); + background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /*background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; +} + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.5), transparent); + +} \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522114616.css b/dot-line-system/.history/src/style_20250522114616.css new file mode 100644 index 0000000..20c0bb6 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522114616.css @@ -0,0 +1,168 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + + +@keyframes gradientAnimation { + 0% { + background-position: 0% 0%; /* Start Links Mitte */ + } + 25% { + background-position: 100% 0%; /* Oben Rechts */ + } + 50% { + background-position: 100% 100%; /* Unten Rechts */ + } + 75% { + background-position: 0% 100%; /* Unten Links */ + } + 100% { + background-position: 0% 0%; /* Zurück zum Start Links Mitte */ + } +} + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /*background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /*background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; +} + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.5), transparent); + +} \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522114639.css b/dot-line-system/.history/src/style_20250522114639.css new file mode 100644 index 0000000..3381220 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522114639.css @@ -0,0 +1,173 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /*background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /*background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + /* Start Links Mitte */ + } + + 25% { + background-position: 100% 0%; + /* Oben Rechts */ + } + + 50% { + background-position: 100% 100%; + /* Unten Rechts */ + } + + 75% { + background-position: 0% 100%; + /* Unten Links */ + } + + 100% { + background-position: 0% 0%; + /* Zurück zum Start Links Mitte */ + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522114649.css b/dot-line-system/.history/src/style_20250522114649.css new file mode 100644 index 0000000..8701e91 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522114649.css @@ -0,0 +1,168 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /*background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /*background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522114653.css b/dot-line-system/.history/src/style_20250522114653.css new file mode 100644 index 0000000..5a22146 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522114653.css @@ -0,0 +1,168 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522114816.css b/dot-line-system/.history/src/style_20250522114816.css new file mode 100644 index 0000000..4c97910 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522114816.css @@ -0,0 +1,171 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + overflow-x: hidden; + overflow-y: auto; /* Allows vertical scrolling if needed */ + + + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522114848.css b/dot-line-system/.history/src/style_20250522114848.css new file mode 100644 index 0000000..484b475 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522114848.css @@ -0,0 +1,167 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522114856.css b/dot-line-system/.history/src/style_20250522114856.css new file mode 100644 index 0000000..f9fcf4d --- /dev/null +++ b/dot-line-system/.history/src/style_20250522114856.css @@ -0,0 +1,167 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: auto; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522114917.css b/dot-line-system/.history/src/style_20250522114917.css new file mode 100644 index 0000000..484b475 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522114917.css @@ -0,0 +1,167 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + overflow-x: hidden; + overflow-y: hidden; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522114920.css b/dot-line-system/.history/src/style_20250522114920.css new file mode 100644 index 0000000..b870002 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522114920.css @@ -0,0 +1,167 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + /* overflow-x: hidden; + overflow-y: hidden; */ + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: auto; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522114934.css b/dot-line-system/.history/src/style_20250522114934.css new file mode 100644 index 0000000..401e1a9 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522114934.css @@ -0,0 +1,167 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + /* overflow-x: hidden; + overflow-y: hidden; */ + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: auto; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522114947.css b/dot-line-system/.history/src/style_20250522114947.css new file mode 100644 index 0000000..2ebc79e --- /dev/null +++ b/dot-line-system/.history/src/style_20250522114947.css @@ -0,0 +1,167 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + /* overflow-x: hidden; + overflow-y: hidden; */ + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522115024.css b/dot-line-system/.history/src/style_20250522115024.css new file mode 100644 index 0000000..86784e8 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522115024.css @@ -0,0 +1,168 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + /* overflow-x: hidden; + overflow-y: hidden; */ + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522115045.css b/dot-line-system/.history/src/style_20250522115045.css new file mode 100644 index 0000000..48ee122 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522115045.css @@ -0,0 +1,168 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + /* overflow-x: hidden; + overflow-y: hidden; */ + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.5); + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522115052.css b/dot-line-system/.history/src/style_20250522115052.css new file mode 100644 index 0000000..a975cf0 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522115052.css @@ -0,0 +1,168 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + /* overflow-x: hidden; + overflow-y: hidden; */ + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + box-shadow: 0 0 10px 0 rgba(0, 0, 0, 1); + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522115107.css b/dot-line-system/.history/src/style_20250522115107.css new file mode 100644 index 0000000..0649aeb --- /dev/null +++ b/dot-line-system/.history/src/style_20250522115107.css @@ -0,0 +1,169 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + /* overflow-x: hidden; + overflow-y: hidden; */ + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + box-shadow: 0 0 10px 0 rgba(0, 0, 0, 1); + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522115113.css b/dot-line-system/.history/src/style_20250522115113.css new file mode 100644 index 0000000..ada98ed --- /dev/null +++ b/dot-line-system/.history/src/style_20250522115113.css @@ -0,0 +1,169 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + /* overflow-x: hidden; + overflow-y: hidden; */ + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + box-shadow: 0 0 20px 0 rgba(0, 0, 0, 1); + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522115119.css b/dot-line-system/.history/src/style_20250522115119.css new file mode 100644 index 0000000..a124083 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522115119.css @@ -0,0 +1,169 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + /* overflow-x: hidden; + overflow-y: hidden; */ + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2); + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522115124.css b/dot-line-system/.history/src/style_20250522115124.css new file mode 100644 index 0000000..cdf2715 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522115124.css @@ -0,0 +1,169 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + /* overflow-x: hidden; + overflow-y: hidden; */ + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.4); + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522115129.css b/dot-line-system/.history/src/style_20250522115129.css new file mode 100644 index 0000000..bf180ab --- /dev/null +++ b/dot-line-system/.history/src/style_20250522115129.css @@ -0,0 +1,169 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + /* overflow-x: hidden; + overflow-y: hidden; */ + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 300; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522115145.css b/dot-line-system/.history/src/style_20250522115145.css new file mode 100644 index 0000000..2270003 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522115145.css @@ -0,0 +1,169 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + /* overflow-x: hidden; + overflow-y: hidden; */ + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 200; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522115153.css b/dot-line-system/.history/src/style_20250522115153.css new file mode 100644 index 0000000..8361746 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522115153.css @@ -0,0 +1,169 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + /* overflow-x: hidden; + overflow-y: hidden; */ + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522115156.css b/dot-line-system/.history/src/style_20250522115156.css new file mode 100644 index 0000000..6000a74 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522115156.css @@ -0,0 +1,169 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + /* overflow-x: hidden; + overflow-y: hidden; */ + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 11px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522115158.css b/dot-line-system/.history/src/style_20250522115158.css new file mode 100644 index 0000000..af235c3 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522115158.css @@ -0,0 +1,169 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + /* overflow-x: hidden; + overflow-y: hidden; */ + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522115353.css b/dot-line-system/.history/src/style_20250522115353.css new file mode 100644 index 0000000..2f680bc --- /dev/null +++ b/dot-line-system/.history/src/style_20250522115353.css @@ -0,0 +1,177 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + /* overflow-x: hidden; + overflow-y: hidden; */ + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); + transition: box-shadow 0.5s ease-in-out; /* Apply transition to box-shadow */ + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.5s ease-in-out; /* Apply transition to box-shadow */ + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522115410.css b/dot-line-system/.history/src/style_20250522115410.css new file mode 100644 index 0000000..d044926 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522115410.css @@ -0,0 +1,177 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + /* overflow-x: hidden; + overflow-y: hidden; */ + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.5); + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522115441.css b/dot-line-system/.history/src/style_20250522115441.css new file mode 100644 index 0000000..b84fe27 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522115441.css @@ -0,0 +1,178 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + /* overflow-x: hidden; + overflow-y: hidden; */ + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + } + + .dot-tooltip .image_container:hover { + + /* box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.5);*/ + box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522115453.css b/dot-line-system/.history/src/style_20250522115453.css new file mode 100644 index 0000000..f78929c --- /dev/null +++ b/dot-line-system/.history/src/style_20250522115453.css @@ -0,0 +1,178 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + /* overflow-x: hidden; + overflow-y: hidden; */ + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.5); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522115508.css b/dot-line-system/.history/src/style_20250522115508.css new file mode 100644 index 0000000..e0bec63 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522115508.css @@ -0,0 +1,179 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + /* overflow-x: hidden; + overflow-y: hidden; */ + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.5); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522115517.css b/dot-line-system/.history/src/style_20250522115517.css new file mode 100644 index 0000000..68ef695 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522115517.css @@ -0,0 +1,179 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + /* overflow-x: hidden; + overflow-y: hidden; */ + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522115552.css b/dot-line-system/.history/src/style_20250522115552.css new file mode 100644 index 0000000..317ea64 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522115552.css @@ -0,0 +1,179 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + /* overflow-x: hidden; + overflow-y: hidden; */ + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 2px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522115602.css b/dot-line-system/.history/src/style_20250522115602.css new file mode 100644 index 0000000..68ef695 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522115602.css @@ -0,0 +1,179 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + /* overflow-x: hidden; + overflow-y: hidden; */ + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522115619.css b/dot-line-system/.history/src/style_20250522115619.css new file mode 100644 index 0000000..30f1a14 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522115619.css @@ -0,0 +1,179 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + /* overflow-x: hidden; + overflow-y: hidden; */ + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.05); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522115746.css b/dot-line-system/.history/src/style_20250522115746.css new file mode 100644 index 0000000..b4696d1 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522115746.css @@ -0,0 +1,181 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + /* overflow-x: hidden; + overflow-y: hidden; */ + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.05); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + padding-top: 2rem; + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522115820.css b/dot-line-system/.history/src/style_20250522115820.css new file mode 100644 index 0000000..b4696d1 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522115820.css @@ -0,0 +1,181 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + /* overflow-x: hidden; + overflow-y: hidden; */ + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.05); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + padding-top: 2rem; + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522130235.css b/dot-line-system/.history/src/style_20250522130235.css new file mode 100644 index 0000000..b4696d1 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522130235.css @@ -0,0 +1,181 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + /* overflow-x: hidden; + overflow-y: hidden; */ + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 30s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.05); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + padding-top: 2rem; + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522130252.css b/dot-line-system/.history/src/style_20250522130252.css new file mode 100644 index 0000000..efe0cbd --- /dev/null +++ b/dot-line-system/.history/src/style_20250522130252.css @@ -0,0 +1,181 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + /* overflow-x: hidden; + overflow-y: hidden; */ + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 10s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.05); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + padding-top: 2rem; + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522130310.css b/dot-line-system/.history/src/style_20250522130310.css new file mode 100644 index 0000000..efe0cbd --- /dev/null +++ b/dot-line-system/.history/src/style_20250522130310.css @@ -0,0 +1,181 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + /* overflow-x: hidden; + overflow-y: hidden; */ + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 10s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.05); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + padding-top: 2rem; + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522130323.css b/dot-line-system/.history/src/style_20250522130323.css new file mode 100644 index 0000000..b32fb0a --- /dev/null +++ b/dot-line-system/.history/src/style_20250522130323.css @@ -0,0 +1,179 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + animation: gradientAnimation 10s ease infinite; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.05); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + padding-top: 2rem; + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522130438.css b/dot-line-system/.history/src/style_20250522130438.css new file mode 100644 index 0000000..fc1b096 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522130438.css @@ -0,0 +1,179 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.05); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + padding-top: 2rem; + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522130450.css b/dot-line-system/.history/src/style_20250522130450.css new file mode 100644 index 0000000..a2f8aa9 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522130450.css @@ -0,0 +1,179 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 1s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.05); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + padding-top: 2rem; + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522130457.css b/dot-line-system/.history/src/style_20250522130457.css new file mode 100644 index 0000000..a2f8aa9 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522130457.css @@ -0,0 +1,179 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 1s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.05); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + padding-top: 2rem; + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522130520.css b/dot-line-system/.history/src/style_20250522130520.css new file mode 100644 index 0000000..a2f8aa9 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522130520.css @@ -0,0 +1,179 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 1s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.05); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + padding-top: 2rem; + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522130537.css b/dot-line-system/.history/src/style_20250522130537.css new file mode 100644 index 0000000..f621b52 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522130537.css @@ -0,0 +1,179 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 1s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 200% 200%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.05); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + padding-top: 2rem; + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522130552.css b/dot-line-system/.history/src/style_20250522130552.css new file mode 100644 index 0000000..cc9d34e --- /dev/null +++ b/dot-line-system/.history/src/style_20250522130552.css @@ -0,0 +1,179 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 200% 200%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.05); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + padding-top: 2rem; + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522130614.css b/dot-line-system/.history/src/style_20250522130614.css new file mode 100644 index 0000000..cc9d34e --- /dev/null +++ b/dot-line-system/.history/src/style_20250522130614.css @@ -0,0 +1,179 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 200% 200%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.05); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + padding-top: 2rem; + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522130959.css b/dot-line-system/.history/src/style_20250522130959.css new file mode 100644 index 0000000..0b7920b --- /dev/null +++ b/dot-line-system/.history/src/style_20250522130959.css @@ -0,0 +1,198 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 200% 200%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.05); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + padding-top: 2rem; + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; /* Apply transition to box-shadow */ + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + .dot-tooltip { + pointer-events: none; + opacity: 1; /* Always visible */ + } + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522131003.css b/dot-line-system/.history/src/style_20250522131003.css new file mode 100644 index 0000000..85730c0 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522131003.css @@ -0,0 +1,204 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 200% 200%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.05); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + padding-top: 2rem; + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + /* Apply transition to box-shadow */ + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + /* Apply transition to box-shadow */ + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522131623.css b/dot-line-system/.history/src/style_20250522131623.css new file mode 100644 index 0000000..cbf179e --- /dev/null +++ b/dot-line-system/.history/src/style_20250522131623.css @@ -0,0 +1,202 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 200% 200%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.05); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522132147.css b/dot-line-system/.history/src/style_20250522132147.css new file mode 100644 index 0000000..f0c6d1c --- /dev/null +++ b/dot-line-system/.history/src/style_20250522132147.css @@ -0,0 +1,202 @@ + body { + font-family: "Montserrat", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 200% 200%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522132926.css b/dot-line-system/.history/src/style_20250522132926.css new file mode 100644 index 0000000..bf3fcc3 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522132926.css @@ -0,0 +1,202 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 200% 200%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522132930.css b/dot-line-system/.history/src/style_20250522132930.css new file mode 100644 index 0000000..4adefe1 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522132930.css @@ -0,0 +1,202 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 200% 200%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 12px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522132942.css b/dot-line-system/.history/src/style_20250522132942.css new file mode 100644 index 0000000..4ed56f0 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522132942.css @@ -0,0 +1,202 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 200% 200%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 16px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 10px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522132949.css b/dot-line-system/.history/src/style_20250522132949.css new file mode 100644 index 0000000..d21ff7f --- /dev/null +++ b/dot-line-system/.history/src/style_20250522132949.css @@ -0,0 +1,202 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 200% 200%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 16px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522132956.css b/dot-line-system/.history/src/style_20250522132956.css new file mode 100644 index 0000000..8fe6d99 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522132956.css @@ -0,0 +1,202 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 200% 200%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522133003.css b/dot-line-system/.history/src/style_20250522133003.css new file mode 100644 index 0000000..63c3fbf --- /dev/null +++ b/dot-line-system/.history/src/style_20250522133003.css @@ -0,0 +1,203 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 200% 200%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.2; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522133006.css b/dot-line-system/.history/src/style_20250522133006.css new file mode 100644 index 0000000..82e19a5 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522133006.css @@ -0,0 +1,203 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 200% 200%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522133030.css b/dot-line-system/.history/src/style_20250522133030.css new file mode 100644 index 0000000..a1d2e8f --- /dev/null +++ b/dot-line-system/.history/src/style_20250522133030.css @@ -0,0 +1,204 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 200% 200%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + /* text-wrap: balance; */ + text-align: justify; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522133046.css b/dot-line-system/.history/src/style_20250522133046.css new file mode 100644 index 0000000..82e19a5 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522133046.css @@ -0,0 +1,203 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 200% 200%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 50%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522133236.css b/dot-line-system/.history/src/style_20250522133236.css new file mode 100644 index 0000000..90f3454 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522133236.css @@ -0,0 +1,203 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 200% 200%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 60%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522133241.css b/dot-line-system/.history/src/style_20250522133241.css new file mode 100644 index 0000000..427dfa5 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522133241.css @@ -0,0 +1,203 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 200% 200%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 62.5%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522133243.css b/dot-line-system/.history/src/style_20250522133243.css new file mode 100644 index 0000000..4af0f56 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522133243.css @@ -0,0 +1,203 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 200% 200%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 62%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522133246.css b/dot-line-system/.history/src/style_20250522133246.css new file mode 100644 index 0000000..fc23a61 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522133246.css @@ -0,0 +1,203 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 200% 200%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522133248.css b/dot-line-system/.history/src/style_20250522133248.css new file mode 100644 index 0000000..1ebdd19 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522133248.css @@ -0,0 +1,203 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 200% 200%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.5%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522133254.css b/dot-line-system/.history/src/style_20250522133254.css new file mode 100644 index 0000000..e002d7f --- /dev/null +++ b/dot-line-system/.history/src/style_20250522133254.css @@ -0,0 +1,203 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 200% 200%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.75%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522133352.css b/dot-line-system/.history/src/style_20250522133352.css new file mode 100644 index 0000000..e002d7f --- /dev/null +++ b/dot-line-system/.history/src/style_20250522133352.css @@ -0,0 +1,203 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + /* background: linear-gradient(to bottom, #4f46e5, #60a5fa, #4ade80); */ + /* background: linear-gradient(45deg, #541ba2, #d4890b, #fc1c98);*/ + /* background: linear-gradient(45deg, #7317c3, #d2348b, #31e6cb); */ + /* background: linear-gradient(-45deg, #a0197c, #fe4374, #541ba2, #a0197c);*/ + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 200% 200%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.75%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522133401.css b/dot-line-system/.history/src/style_20250522133401.css new file mode 100644 index 0000000..52edf24 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522133401.css @@ -0,0 +1,199 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 200% 200%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.75%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522133408.css b/dot-line-system/.history/src/style_20250522133408.css new file mode 100644 index 0000000..e41bb61 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522133408.css @@ -0,0 +1,199 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 300% 300%; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.75%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522133412.css b/dot-line-system/.history/src/style_20250522133412.css new file mode 100644 index 0000000..4919966 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522133412.css @@ -0,0 +1,199 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 200% 200%; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.75%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522153124.css b/dot-line-system/.history/src/style_20250522153124.css new file mode 100644 index 0000000..a11c985 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522153124.css @@ -0,0 +1,199 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 200% 200%; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.75%; + left: 0; + height: 2px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.1); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522153129.css b/dot-line-system/.history/src/style_20250522153129.css new file mode 100644 index 0000000..e8970db --- /dev/null +++ b/dot-line-system/.history/src/style_20250522153129.css @@ -0,0 +1,199 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 200% 200%; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.75%; + left: 0; + height: 2px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.8); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522153134.css b/dot-line-system/.history/src/style_20250522153134.css new file mode 100644 index 0000000..2119044 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522153134.css @@ -0,0 +1,199 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 200% 200%; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.75%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.8); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522153141.css b/dot-line-system/.history/src/style_20250522153141.css new file mode 100644 index 0000000..30f0809 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522153141.css @@ -0,0 +1,199 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 200% 200%; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.5%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.8); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522153151.css b/dot-line-system/.history/src/style_20250522153151.css new file mode 100644 index 0000000..173b4d9 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522153151.css @@ -0,0 +1,199 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 200% 200%; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.5%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 0, 0, 0.8); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522153532.css b/dot-line-system/.history/src/style_20250522153532.css new file mode 100644 index 0000000..2f057f0 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522153532.css @@ -0,0 +1,199 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 200% 200%; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.5%; + left: 0; + height: 1px; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.2); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522153557.css b/dot-line-system/.history/src/style_20250522153557.css new file mode 100644 index 0000000..02476a1 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522153557.css @@ -0,0 +1,200 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 200% 200%; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.5%; + left: 0; + height: 1px; + border-top: 1px dashed white; + width: 100%; + z-index: -1; + background-color: rgba(255, 255, 255, 0.2); + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522153600.css b/dot-line-system/.history/src/style_20250522153600.css new file mode 100644 index 0000000..c1a966d --- /dev/null +++ b/dot-line-system/.history/src/style_20250522153600.css @@ -0,0 +1,200 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 200% 200%; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.5%; + left: 0; + height: 1px; + border-top: 1px dashed white; + width: 100%; + z-index: -1; + /* background-color: rgba(255, 255, 255, 0.2); */ + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522223323.css b/dot-line-system/.history/src/style_20250522223323.css new file mode 100644 index 0000000..a8e5ad4 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522223323.css @@ -0,0 +1,200 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 200% 200%; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.5%; + left: 0; + height: 1px; + border-top: 1px dashed rgba(255, 255, 255, 0.2); + width: 100%; + z-index: -1; + /* background-color: rgba(255, 255, 255, 0.2); */ + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: auto; + height: 100%; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522230441.css b/dot-line-system/.history/src/style_20250522230441.css new file mode 100644 index 0000000..545d443 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522230441.css @@ -0,0 +1,200 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: -1; + background-size: 200% 200%; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.5%; + left: 0; + height: 1px; + border-top: 1px dashed rgba(255, 255, 255, 0.2); + width: 100%; + z-index: -1; + /* background-color: rgba(255, 255, 255, 0.2); */ + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: 100%; + height: auto; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522232137.css b/dot-line-system/.history/src/style_20250522232137.css new file mode 100644 index 0000000..93e075d --- /dev/null +++ b/dot-line-system/.history/src/style_20250522232137.css @@ -0,0 +1,200 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: 0; + background-size: 200% 200%; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.5%; + left: 0; + height: 1px; + border-top: 1px dashed rgba(255, 255, 255, 0.2); + width: 100%; + z-index: -1; + /* background-color: rgba(255, 255, 255, 0.2); */ + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: 100%; + height: auto; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522232205.css b/dot-line-system/.history/src/style_20250522232205.css new file mode 100644 index 0000000..93e075d --- /dev/null +++ b/dot-line-system/.history/src/style_20250522232205.css @@ -0,0 +1,200 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: 0; + background-size: 200% 200%; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.5%; + left: 0; + height: 1px; + border-top: 1px dashed rgba(255, 255, 255, 0.2); + width: 100%; + z-index: -1; + /* background-color: rgba(255, 255, 255, 0.2); */ + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: 100%; + height: auto; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522232242.css b/dot-line-system/.history/src/style_20250522232242.css new file mode 100644 index 0000000..c35fa4f --- /dev/null +++ b/dot-line-system/.history/src/style_20250522232242.css @@ -0,0 +1,205 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-width: 100%; + z-index: 0; + background-size: 200% 200%; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + .gradient-bg { + border: 2px solid red; /* Temporary for debugging */ +} + + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.5%; + left: 0; + height: 1px; + border-top: 1px dashed rgba(255, 255, 255, 0.2); + width: 100%; + z-index: -1; + /* background-color: rgba(255, 255, 255, 0.2); */ + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: 100%; + height: auto; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522232300.css b/dot-line-system/.history/src/style_20250522232300.css new file mode 100644 index 0000000..201161d --- /dev/null +++ b/dot-line-system/.history/src/style_20250522232300.css @@ -0,0 +1,205 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100vh; + min-width: 100%; + z-index: 0; + background-size: 200% 200%; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + .gradient-bg { + border: 2px solid red; /* Temporary for debugging */ +} + + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.5%; + left: 0; + height: 1px; + border-top: 1px dashed rgba(255, 255, 255, 0.2); + width: 100%; + z-index: -1; + /* background-color: rgba(255, 255, 255, 0.2); */ + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: 100%; + height: auto; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522232311.css b/dot-line-system/.history/src/style_20250522232311.css new file mode 100644 index 0000000..0c0b176 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522232311.css @@ -0,0 +1,205 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100vh; + min-width: 100%; + z-index: 0; + background-size: 200% 200%; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + .gradient-bg { + border: 2px solid green; /* Temporary for debugging */ +} + + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.5%; + left: 0; + height: 1px; + border-top: 1px dashed rgba(255, 255, 255, 0.2); + width: 100%; + z-index: -1; + /* background-color: rgba(255, 255, 255, 0.2); */ + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: 100%; + height: auto; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522232332.css b/dot-line-system/.history/src/style_20250522232332.css new file mode 100644 index 0000000..487866f --- /dev/null +++ b/dot-line-system/.history/src/style_20250522232332.css @@ -0,0 +1,205 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100vh; + min-width: 100%; + z-index: 0; + background-size: 200% 200%; + background-color: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + animation: gradientAnimation 10s ease infinite; + } + + .gradient-bg { + border: 2px solid green; /* Temporary for debugging */ +} + + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.5%; + left: 0; + height: 1px; + border-top: 1px dashed rgba(255, 255, 255, 0.2); + width: 100%; + z-index: -1; + /* background-color: rgba(255, 255, 255, 0.2); */ + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: 100%; + height: auto; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522232342.css b/dot-line-system/.history/src/style_20250522232342.css new file mode 100644 index 0000000..eedaebd --- /dev/null +++ b/dot-line-system/.history/src/style_20250522232342.css @@ -0,0 +1,205 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100vh; + min-width: 100%; + z-index: 0; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + background-size: 200% 200%; + animation: gradientAnimation 10s ease infinite; + } + + .gradient-bg { + border: 2px solid green; /* Temporary for debugging */ +} + + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.5%; + left: 0; + height: 1px; + border-top: 1px dashed rgba(255, 255, 255, 0.2); + width: 100%; + z-index: -1; + /* background-color: rgba(255, 255, 255, 0.2); */ + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: 100%; + height: auto; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522232352.css b/dot-line-system/.history/src/style_20250522232352.css new file mode 100644 index 0000000..27bc2e2 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522232352.css @@ -0,0 +1,205 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100vh; + min-width: 100%; + z-index: 0; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + background-size: 200% 200%; + animation: gradientAnimation 30s ease infinite; + } + + .gradient-bg { + border: 2px solid green; /* Temporary for debugging */ +} + + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.5%; + left: 0; + height: 1px; + border-top: 1px dashed rgba(255, 255, 255, 0.2); + width: 100%; + z-index: -1; + /* background-color: rgba(255, 255, 255, 0.2); */ + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: 100%; + height: auto; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522232356.css b/dot-line-system/.history/src/style_20250522232356.css new file mode 100644 index 0000000..30c2087 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522232356.css @@ -0,0 +1,200 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100vh; + min-width: 100%; + z-index: 0; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + background-size: 200% 200%; + animation: gradientAnimation 30s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.5%; + left: 0; + height: 1px; + border-top: 1px dashed rgba(255, 255, 255, 0.2); + width: 100%; + z-index: -1; + /* background-color: rgba(255, 255, 255, 0.2); */ + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: 100%; + height: auto; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522232403.css b/dot-line-system/.history/src/style_20250522232403.css new file mode 100644 index 0000000..45fc6a6 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522232403.css @@ -0,0 +1,200 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100vh; + min-width: 100%; + z-index: 0; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + background-size: 200% 200%; + animation: gradientAnimation 20s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.5%; + left: 0; + height: 1px; + border-top: 1px dashed rgba(255, 255, 255, 0.2); + width: 100%; + z-index: -1; + /* background-color: rgba(255, 255, 255, 0.2); */ + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: 100%; + height: auto; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522232543.css b/dot-line-system/.history/src/style_20250522232543.css new file mode 100644 index 0000000..9e6d4c1 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522232543.css @@ -0,0 +1,200 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100vh; + min-width: 100%; + z-index: 0; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + background-size: 200% 200%; + animation: gradientAnimation 20s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.5%; + left: 0; + height: 1px; + border-top: 1px dashed rgba(255, 255, 255, 0.2); + width: 100%; + z-index: 0; + /* background-color: rgba(255, 255, 255, 0.2); */ + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: 100%; + height: auto; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522232557.css b/dot-line-system/.history/src/style_20250522232557.css new file mode 100644 index 0000000..b7c9577 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522232557.css @@ -0,0 +1,200 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100vh; + min-width: 100%; + z-index: 0; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + background-size: 200% 200%; + animation: gradientAnimation 20s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.5%; + left: 0; + height: 1px; + border-top: 1px dashed rgba(255, 255, 255, 0.2); + width: 100%; + z-index: 1; + /* background-color: rgba(255, 255, 255, 0.2); */ + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: 100%; + height: auto; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522232605.css b/dot-line-system/.history/src/style_20250522232605.css new file mode 100644 index 0000000..9e6d4c1 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522232605.css @@ -0,0 +1,200 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100vh; + min-width: 100%; + z-index: 0; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + background-size: 200% 200%; + animation: gradientAnimation 20s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.5%; + left: 0; + height: 1px; + border-top: 1px dashed rgba(255, 255, 255, 0.2); + width: 100%; + z-index: 0; + /* background-color: rgba(255, 255, 255, 0.2); */ + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: 100%; + height: auto; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522232609.css b/dot-line-system/.history/src/style_20250522232609.css new file mode 100644 index 0000000..73b62df --- /dev/null +++ b/dot-line-system/.history/src/style_20250522232609.css @@ -0,0 +1,200 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100vh; + min-width: 100%; + z-index: -1; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + background-size: 200% 200%; + animation: gradientAnimation 20s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.5%; + left: 0; + height: 1px; + border-top: 1px dashed rgba(255, 255, 255, 0.2); + width: 100%; + z-index: 0; + /* background-color: rgba(255, 255, 255, 0.2); */ + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: 100%; + height: auto; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250522232619.css b/dot-line-system/.history/src/style_20250522232619.css new file mode 100644 index 0000000..dcc3e88 --- /dev/null +++ b/dot-line-system/.history/src/style_20250522232619.css @@ -0,0 +1,200 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100vh; + min-width: 100%; + z-index: -1; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + background-size: 200% 200%; + animation: gradientAnimation 20s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.5%; + left: 0; + height: 1px; + border-top: 1px dashed rgba(255, 255, 255, 0.2); + width: 100%; + z-index: -1; + /* background-color: rgba(255, 255, 255, 0.2); */ + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + /* padding-top: 2rem; */ + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: 100%; + height: auto; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250523080846.css b/dot-line-system/.history/src/style_20250523080846.css new file mode 100644 index 0000000..266c32c --- /dev/null +++ b/dot-line-system/.history/src/style_20250523080846.css @@ -0,0 +1,203 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100vh; + min-width: 100%; + z-index: -1; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + background-size: 200% 200%; + animation: gradientAnimation 20s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.5%; + left: 0; + height: 1px; + border-top: 1px dashed rgba(255, 255, 255, 0.2); + width: 100%; + z-index: -1; + /* background-color: rgba(255, 255, 255, 0.2); */ + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .smooth-scroll { + transition: scroll-left 0.3s ease-out; /* Add easing on scroll-left */ +} + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: 100%; + height: auto; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250523080941.css b/dot-line-system/.history/src/style_20250523080941.css new file mode 100644 index 0000000..266c32c --- /dev/null +++ b/dot-line-system/.history/src/style_20250523080941.css @@ -0,0 +1,203 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100vh; + min-width: 100%; + z-index: -1; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + background-size: 200% 200%; + animation: gradientAnimation 20s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.5%; + left: 0; + height: 1px; + border-top: 1px dashed rgba(255, 255, 255, 0.2); + width: 100%; + z-index: -1; + /* background-color: rgba(255, 255, 255, 0.2); */ + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .smooth-scroll { + transition: scroll-left 0.3s ease-out; /* Add easing on scroll-left */ +} + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: 100%; + height: auto; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250523081026.css b/dot-line-system/.history/src/style_20250523081026.css new file mode 100644 index 0000000..2b05fcd --- /dev/null +++ b/dot-line-system/.history/src/style_20250523081026.css @@ -0,0 +1,203 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100vh; + min-width: 100%; + z-index: -1; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + background-size: 200% 200%; + animation: gradientAnimation 20s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.5%; + left: 0; + height: 1px; + border-top: 1px dashed rgba(255, 255, 255, 0.2); + width: 100%; + z-index: -1; + /* background-color: rgba(255, 255, 255, 0.2); */ + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .smooth-scroll { + transition: scroll-left 1s ease-out; /* Add easing on scroll-left */ +} + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: 100%; + height: auto; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/.history/src/style_20250523081040.css b/dot-line-system/.history/src/style_20250523081040.css new file mode 100644 index 0000000..9d13415 --- /dev/null +++ b/dot-line-system/.history/src/style_20250523081040.css @@ -0,0 +1,203 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100vh; + min-width: 100%; + z-index: -1; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + background-size: 200% 200%; + animation: gradientAnimation 20s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.5%; + left: 0; + height: 1px; + border-top: 1px dashed rgba(255, 255, 255, 0.2); + width: 100%; + z-index: -1; + /* background-color: rgba(255, 255, 255, 0.2); */ + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .smooth-scroll { + transition: scroll-left 0.5s ease-out; /* Add easing on scroll-left */ +} + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: 100%; + height: auto; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/bun.lock b/dot-line-system/bun.lock new file mode 100644 index 0000000..c575191 --- /dev/null +++ b/dot-line-system/bun.lock @@ -0,0 +1,128 @@ +{ + "lockfileVersion": 1, + "workspaces": { + "": { + "name": "dot-line-system", + "dependencies": { + "gsap": "./gsap-bonus.tgz", + }, + "devDependencies": { + "typescript": "~5.7.2", + "vite": "^6.2.0", + }, + }, + }, + "packages": { + "@esbuild/aix-ppc64": ["@esbuild/aix-ppc64@0.25.2", "", { "os": "aix", "cpu": "ppc64" }, "sha512-wCIboOL2yXZym2cgm6mlA742s9QeJ8DjGVaL39dLN4rRwrOgOyYSnOaFPhKZGLb2ngj4EyfAFjsNJwPXZvseag=="], + + "@esbuild/android-arm": ["@esbuild/android-arm@0.25.2", "", { "os": "android", "cpu": "arm" }, "sha512-NQhH7jFstVY5x8CKbcfa166GoV0EFkaPkCKBQkdPJFvo5u+nGXLEH/ooniLb3QI8Fk58YAx7nsPLozUWfCBOJA=="], + + "@esbuild/android-arm64": ["@esbuild/android-arm64@0.25.2", "", { "os": "android", "cpu": "arm64" }, "sha512-5ZAX5xOmTligeBaeNEPnPaeEuah53Id2tX4c2CVP3JaROTH+j4fnfHCkr1PjXMd78hMst+TlkfKcW/DlTq0i4w=="], + + "@esbuild/android-x64": ["@esbuild/android-x64@0.25.2", "", { "os": "android", "cpu": "x64" }, "sha512-Ffcx+nnma8Sge4jzddPHCZVRvIfQ0kMsUsCMcJRHkGJ1cDmhe4SsrYIjLUKn1xpHZybmOqCWwB0zQvsjdEHtkg=="], + + "@esbuild/darwin-arm64": ["@esbuild/darwin-arm64@0.25.2", "", { "os": "darwin", "cpu": "arm64" }, "sha512-MpM6LUVTXAzOvN4KbjzU/q5smzryuoNjlriAIx+06RpecwCkL9JpenNzpKd2YMzLJFOdPqBpuub6eVRP5IgiSA=="], + + "@esbuild/darwin-x64": ["@esbuild/darwin-x64@0.25.2", "", { "os": "darwin", "cpu": "x64" }, "sha512-5eRPrTX7wFyuWe8FqEFPG2cU0+butQQVNcT4sVipqjLYQjjh8a8+vUTfgBKM88ObB85ahsnTwF7PSIt6PG+QkA=="], + + "@esbuild/freebsd-arm64": ["@esbuild/freebsd-arm64@0.25.2", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-mLwm4vXKiQ2UTSX4+ImyiPdiHjiZhIaE9QvC7sw0tZ6HoNMjYAqQpGyui5VRIi5sGd+uWq940gdCbY3VLvsO1w=="], + + "@esbuild/freebsd-x64": ["@esbuild/freebsd-x64@0.25.2", "", { "os": "freebsd", "cpu": "x64" }, "sha512-6qyyn6TjayJSwGpm8J9QYYGQcRgc90nmfdUb0O7pp1s4lTY+9D0H9O02v5JqGApUyiHOtkz6+1hZNvNtEhbwRQ=="], + + "@esbuild/linux-arm": ["@esbuild/linux-arm@0.25.2", "", { "os": "linux", "cpu": "arm" }, "sha512-UHBRgJcmjJv5oeQF8EpTRZs/1knq6loLxTsjc3nxO9eXAPDLcWW55flrMVc97qFPbmZP31ta1AZVUKQzKTzb0g=="], + + "@esbuild/linux-arm64": ["@esbuild/linux-arm64@0.25.2", "", { "os": "linux", "cpu": "arm64" }, "sha512-gq/sjLsOyMT19I8obBISvhoYiZIAaGF8JpeXu1u8yPv8BE5HlWYobmlsfijFIZ9hIVGYkbdFhEqC0NvM4kNO0g=="], + + "@esbuild/linux-ia32": ["@esbuild/linux-ia32@0.25.2", "", { "os": "linux", "cpu": "ia32" }, "sha512-bBYCv9obgW2cBP+2ZWfjYTU+f5cxRoGGQ5SeDbYdFCAZpYWrfjjfYwvUpP8MlKbP0nwZ5gyOU/0aUzZ5HWPuvQ=="], + + "@esbuild/linux-loong64": ["@esbuild/linux-loong64@0.25.2", "", { "os": "linux", "cpu": "none" }, "sha512-SHNGiKtvnU2dBlM5D8CXRFdd+6etgZ9dXfaPCeJtz+37PIUlixvlIhI23L5khKXs3DIzAn9V8v+qb1TRKrgT5w=="], + + "@esbuild/linux-mips64el": ["@esbuild/linux-mips64el@0.25.2", "", { "os": "linux", "cpu": "none" }, "sha512-hDDRlzE6rPeoj+5fsADqdUZl1OzqDYow4TB4Y/3PlKBD0ph1e6uPHzIQcv2Z65u2K0kpeByIyAjCmjn1hJgG0Q=="], + + "@esbuild/linux-ppc64": ["@esbuild/linux-ppc64@0.25.2", "", { "os": "linux", "cpu": "ppc64" }, "sha512-tsHu2RRSWzipmUi9UBDEzc0nLc4HtpZEI5Ba+Omms5456x5WaNuiG3u7xh5AO6sipnJ9r4cRWQB2tUjPyIkc6g=="], + + "@esbuild/linux-riscv64": ["@esbuild/linux-riscv64@0.25.2", "", { "os": "linux", "cpu": "none" }, "sha512-k4LtpgV7NJQOml/10uPU0s4SAXGnowi5qBSjaLWMojNCUICNu7TshqHLAEbkBdAszL5TabfvQ48kK84hyFzjnw=="], + + "@esbuild/linux-s390x": ["@esbuild/linux-s390x@0.25.2", "", { "os": "linux", "cpu": "s390x" }, "sha512-GRa4IshOdvKY7M/rDpRR3gkiTNp34M0eLTaC1a08gNrh4u488aPhuZOCpkF6+2wl3zAN7L7XIpOFBhnaE3/Q8Q=="], + + "@esbuild/linux-x64": ["@esbuild/linux-x64@0.25.2", "", { "os": "linux", "cpu": "x64" }, "sha512-QInHERlqpTTZ4FRB0fROQWXcYRD64lAoiegezDunLpalZMjcUcld3YzZmVJ2H/Cp0wJRZ8Xtjtj0cEHhYc/uUg=="], + + "@esbuild/netbsd-arm64": ["@esbuild/netbsd-arm64@0.25.2", "", { "os": "none", "cpu": "arm64" }, "sha512-talAIBoY5M8vHc6EeI2WW9d/CkiO9MQJ0IOWX8hrLhxGbro/vBXJvaQXefW2cP0z0nQVTdQ/eNyGFV1GSKrxfw=="], + + "@esbuild/netbsd-x64": ["@esbuild/netbsd-x64@0.25.2", "", { "os": "none", "cpu": "x64" }, "sha512-voZT9Z+tpOxrvfKFyfDYPc4DO4rk06qamv1a/fkuzHpiVBMOhpjK+vBmWM8J1eiB3OLSMFYNaOaBNLXGChf5tg=="], + + "@esbuild/openbsd-arm64": ["@esbuild/openbsd-arm64@0.25.2", "", { "os": "openbsd", "cpu": "arm64" }, "sha512-dcXYOC6NXOqcykeDlwId9kB6OkPUxOEqU+rkrYVqJbK2hagWOMrsTGsMr8+rW02M+d5Op5NNlgMmjzecaRf7Tg=="], + + "@esbuild/openbsd-x64": ["@esbuild/openbsd-x64@0.25.2", "", { "os": "openbsd", "cpu": "x64" }, "sha512-t/TkWwahkH0Tsgoq1Ju7QfgGhArkGLkF1uYz8nQS/PPFlXbP5YgRpqQR3ARRiC2iXoLTWFxc6DJMSK10dVXluw=="], + + "@esbuild/sunos-x64": ["@esbuild/sunos-x64@0.25.2", "", { "os": "sunos", "cpu": "x64" }, "sha512-cfZH1co2+imVdWCjd+D1gf9NjkchVhhdpgb1q5y6Hcv9TP6Zi9ZG/beI3ig8TvwT9lH9dlxLq5MQBBgwuj4xvA=="], + + "@esbuild/win32-arm64": ["@esbuild/win32-arm64@0.25.2", "", { "os": "win32", "cpu": "arm64" }, "sha512-7Loyjh+D/Nx/sOTzV8vfbB3GJuHdOQyrOryFdZvPHLf42Tk9ivBU5Aedi7iyX+x6rbn2Mh68T4qq1SDqJBQO5Q=="], + + "@esbuild/win32-ia32": ["@esbuild/win32-ia32@0.25.2", "", { "os": "win32", "cpu": "ia32" }, "sha512-WRJgsz9un0nqZJ4MfhabxaD9Ft8KioqU3JMinOTvobbX6MOSUigSBlogP8QB3uxpJDsFS6yN+3FDBdqE5lg9kg=="], + + "@esbuild/win32-x64": ["@esbuild/win32-x64@0.25.2", "", { "os": "win32", "cpu": "x64" }, "sha512-kM3HKb16VIXZyIeVrM1ygYmZBKybX8N4p754bw390wGO3Tf2j4L2/WYL+4suWujpgf6GBYs3jv7TyUivdd05JA=="], + + "@rollup/rollup-android-arm-eabi": ["@rollup/rollup-android-arm-eabi@4.39.0", "", { "os": "android", "cpu": "arm" }, "sha512-lGVys55Qb00Wvh8DMAocp5kIcaNzEFTmGhfFd88LfaogYTRKrdxgtlO5H6S49v2Nd8R2C6wLOal0qv6/kCkOwA=="], + + "@rollup/rollup-android-arm64": ["@rollup/rollup-android-arm64@4.39.0", "", { "os": "android", "cpu": "arm64" }, "sha512-It9+M1zE31KWfqh/0cJLrrsCPiF72PoJjIChLX+rEcujVRCb4NLQ5QzFkzIZW8Kn8FTbvGQBY5TkKBau3S8cCQ=="], + + "@rollup/rollup-darwin-arm64": ["@rollup/rollup-darwin-arm64@4.39.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-lXQnhpFDOKDXiGxsU9/l8UEGGM65comrQuZ+lDcGUx+9YQ9dKpF3rSEGepyeR5AHZ0b5RgiligsBhWZfSSQh8Q=="], + + "@rollup/rollup-darwin-x64": ["@rollup/rollup-darwin-x64@4.39.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-mKXpNZLvtEbgu6WCkNij7CGycdw9cJi2k9v0noMb++Vab12GZjFgUXD69ilAbBh034Zwn95c2PNSz9xM7KYEAQ=="], + + "@rollup/rollup-freebsd-arm64": ["@rollup/rollup-freebsd-arm64@4.39.0", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-jivRRlh2Lod/KvDZx2zUR+I4iBfHcu2V/BA2vasUtdtTN2Uk3jfcZczLa81ESHZHPHy4ih3T/W5rPFZ/hX7RtQ=="], + + "@rollup/rollup-freebsd-x64": ["@rollup/rollup-freebsd-x64@4.39.0", "", { "os": "freebsd", "cpu": "x64" }, "sha512-8RXIWvYIRK9nO+bhVz8DwLBepcptw633gv/QT4015CpJ0Ht8punmoHU/DuEd3iw9Hr8UwUV+t+VNNuZIWYeY7Q=="], + + "@rollup/rollup-linux-arm-gnueabihf": ["@rollup/rollup-linux-arm-gnueabihf@4.39.0", "", { "os": "linux", "cpu": "arm" }, "sha512-mz5POx5Zu58f2xAG5RaRRhp3IZDK7zXGk5sdEDj4o96HeaXhlUwmLFzNlc4hCQi5sGdR12VDgEUqVSHer0lI9g=="], + + "@rollup/rollup-linux-arm-musleabihf": ["@rollup/rollup-linux-arm-musleabihf@4.39.0", "", { "os": "linux", "cpu": "arm" }, "sha512-+YDwhM6gUAyakl0CD+bMFpdmwIoRDzZYaTWV3SDRBGkMU/VpIBYXXEvkEcTagw/7VVkL2vA29zU4UVy1mP0/Yw=="], + + "@rollup/rollup-linux-arm64-gnu": ["@rollup/rollup-linux-arm64-gnu@4.39.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-EKf7iF7aK36eEChvlgxGnk7pdJfzfQbNvGV/+l98iiMwU23MwvmV0Ty3pJ0p5WQfm3JRHOytSIqD9LB7Bq7xdQ=="], + + "@rollup/rollup-linux-arm64-musl": ["@rollup/rollup-linux-arm64-musl@4.39.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-vYanR6MtqC7Z2SNr8gzVnzUul09Wi1kZqJaek3KcIlI/wq5Xtq4ZPIZ0Mr/st/sv/NnaPwy/D4yXg5x0B3aUUA=="], + + "@rollup/rollup-linux-loongarch64-gnu": ["@rollup/rollup-linux-loongarch64-gnu@4.39.0", "", { "os": "linux", "cpu": "none" }, "sha512-NMRUT40+h0FBa5fb+cpxtZoGAggRem16ocVKIv5gDB5uLDgBIwrIsXlGqYbLwW8YyO3WVTk1FkFDjMETYlDqiw=="], + + "@rollup/rollup-linux-powerpc64le-gnu": ["@rollup/rollup-linux-powerpc64le-gnu@4.39.0", "", { "os": "linux", "cpu": "ppc64" }, "sha512-0pCNnmxgduJ3YRt+D+kJ6Ai/r+TaePu9ZLENl+ZDV/CdVczXl95CbIiwwswu4L+K7uOIGf6tMo2vm8uadRaICQ=="], + + "@rollup/rollup-linux-riscv64-gnu": ["@rollup/rollup-linux-riscv64-gnu@4.39.0", "", { "os": "linux", "cpu": "none" }, "sha512-t7j5Zhr7S4bBtksT73bO6c3Qa2AV/HqiGlj9+KB3gNF5upcVkx+HLgxTm8DK4OkzsOYqbdqbLKwvGMhylJCPhQ=="], + + "@rollup/rollup-linux-riscv64-musl": ["@rollup/rollup-linux-riscv64-musl@4.39.0", "", { "os": "linux", "cpu": "none" }, "sha512-m6cwI86IvQ7M93MQ2RF5SP8tUjD39Y7rjb1qjHgYh28uAPVU8+k/xYWvxRO3/tBN2pZkSMa5RjnPuUIbrwVxeA=="], + + "@rollup/rollup-linux-s390x-gnu": ["@rollup/rollup-linux-s390x-gnu@4.39.0", "", { "os": "linux", "cpu": "s390x" }, "sha512-iRDJd2ebMunnk2rsSBYlsptCyuINvxUfGwOUldjv5M4tpa93K8tFMeYGpNk2+Nxl+OBJnBzy2/JCscGeO507kA=="], + + "@rollup/rollup-linux-x64-gnu": ["@rollup/rollup-linux-x64-gnu@4.39.0", "", { "os": "linux", "cpu": "x64" }, "sha512-t9jqYw27R6Lx0XKfEFe5vUeEJ5pF3SGIM6gTfONSMb7DuG6z6wfj2yjcoZxHg129veTqU7+wOhY6GX8wmf90dA=="], + + "@rollup/rollup-linux-x64-musl": ["@rollup/rollup-linux-x64-musl@4.39.0", "", { "os": "linux", "cpu": "x64" }, "sha512-ThFdkrFDP55AIsIZDKSBWEt/JcWlCzydbZHinZ0F/r1h83qbGeenCt/G/wG2O0reuENDD2tawfAj2s8VK7Bugg=="], + + "@rollup/rollup-win32-arm64-msvc": ["@rollup/rollup-win32-arm64-msvc@4.39.0", "", { "os": "win32", "cpu": "arm64" }, "sha512-jDrLm6yUtbOg2TYB3sBF3acUnAwsIksEYjLeHL+TJv9jg+TmTwdyjnDex27jqEMakNKf3RwwPahDIt7QXCSqRQ=="], + + "@rollup/rollup-win32-ia32-msvc": ["@rollup/rollup-win32-ia32-msvc@4.39.0", "", { "os": "win32", "cpu": "ia32" }, "sha512-6w9uMuza+LbLCVoNKL5FSLE7yvYkq9laSd09bwS0tMjkwXrmib/4KmoJcrKhLWHvw19mwU+33ndC69T7weNNjQ=="], + + "@rollup/rollup-win32-x64-msvc": ["@rollup/rollup-win32-x64-msvc@4.39.0", "", { "os": "win32", "cpu": "x64" }, "sha512-yAkUOkIKZlK5dl7u6dg897doBgLXmUHhIINM2c+sND3DZwnrdQkkSiDh7N75Ll4mM4dxSkYfXqU9fW3lLkMFug=="], + + "@types/estree": ["@types/estree@1.0.7", "", {}, "sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ=="], + + "esbuild": ["esbuild@0.25.2", "", { "optionalDependencies": { "@esbuild/aix-ppc64": "0.25.2", "@esbuild/android-arm": "0.25.2", "@esbuild/android-arm64": "0.25.2", "@esbuild/android-x64": "0.25.2", "@esbuild/darwin-arm64": "0.25.2", "@esbuild/darwin-x64": "0.25.2", "@esbuild/freebsd-arm64": "0.25.2", "@esbuild/freebsd-x64": "0.25.2", "@esbuild/linux-arm": "0.25.2", "@esbuild/linux-arm64": "0.25.2", "@esbuild/linux-ia32": "0.25.2", "@esbuild/linux-loong64": "0.25.2", "@esbuild/linux-mips64el": "0.25.2", "@esbuild/linux-ppc64": "0.25.2", "@esbuild/linux-riscv64": "0.25.2", "@esbuild/linux-s390x": "0.25.2", "@esbuild/linux-x64": "0.25.2", "@esbuild/netbsd-arm64": "0.25.2", "@esbuild/netbsd-x64": "0.25.2", "@esbuild/openbsd-arm64": "0.25.2", "@esbuild/openbsd-x64": "0.25.2", "@esbuild/sunos-x64": "0.25.2", "@esbuild/win32-arm64": "0.25.2", "@esbuild/win32-ia32": "0.25.2", "@esbuild/win32-x64": "0.25.2" }, "bin": { "esbuild": "bin/esbuild" } }, "sha512-16854zccKPnC+toMywC+uKNeYSv+/eXkevRAfwRD/G9Cleq66m8XFIrigkbvauLLlCfDL45Q2cWegSg53gGBnQ=="], + + "fsevents": ["fsevents@2.3.3", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="], + + "gsap": ["gsap@./gsap-bonus.tgz", {}], + + "nanoid": ["nanoid@3.3.11", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w=="], + + "picocolors": ["picocolors@1.1.1", "", {}, "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="], + + "postcss": ["postcss@8.5.3", "", { "dependencies": { "nanoid": "^3.3.8", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" } }, "sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A=="], + + "rollup": ["rollup@4.39.0", "", { "dependencies": { "@types/estree": "1.0.7" }, "optionalDependencies": { "@rollup/rollup-android-arm-eabi": "4.39.0", "@rollup/rollup-android-arm64": "4.39.0", "@rollup/rollup-darwin-arm64": "4.39.0", "@rollup/rollup-darwin-x64": "4.39.0", "@rollup/rollup-freebsd-arm64": "4.39.0", "@rollup/rollup-freebsd-x64": "4.39.0", "@rollup/rollup-linux-arm-gnueabihf": "4.39.0", "@rollup/rollup-linux-arm-musleabihf": "4.39.0", "@rollup/rollup-linux-arm64-gnu": "4.39.0", "@rollup/rollup-linux-arm64-musl": "4.39.0", "@rollup/rollup-linux-loongarch64-gnu": "4.39.0", "@rollup/rollup-linux-powerpc64le-gnu": "4.39.0", "@rollup/rollup-linux-riscv64-gnu": "4.39.0", "@rollup/rollup-linux-riscv64-musl": "4.39.0", "@rollup/rollup-linux-s390x-gnu": "4.39.0", "@rollup/rollup-linux-x64-gnu": "4.39.0", "@rollup/rollup-linux-x64-musl": "4.39.0", "@rollup/rollup-win32-arm64-msvc": "4.39.0", "@rollup/rollup-win32-ia32-msvc": "4.39.0", "@rollup/rollup-win32-x64-msvc": "4.39.0", "fsevents": "~2.3.2" }, "bin": { "rollup": "dist/bin/rollup" } }, "sha512-thI8kNc02yNvnmJp8dr3fNWJ9tCONDhp6TV35X6HkKGGs9E6q7YWCHbe5vKiTa7TAiNcFEmXKj3X/pG2b3ci0g=="], + + "source-map-js": ["source-map-js@1.2.1", "", {}, "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA=="], + + "typescript": ["typescript@5.7.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw=="], + + "vite": ["vite@6.2.5", "", { "dependencies": { "esbuild": "^0.25.0", "postcss": "^8.5.3", "rollup": "^4.30.1" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", "jiti": ">=1.21.0", "less": "*", "lightningcss": "^1.21.0", "sass": "*", "sass-embedded": "*", "stylus": "*", "sugarss": "*", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@types/node", "jiti", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx", "yaml"], "bin": { "vite": "bin/vite.js" } }, "sha512-j023J/hCAa4pRIUH6J9HemwYfjB5llR2Ps0CWeikOtdR8+pAURAk0DoJC5/mm9kd+UgdnIy7d6HE4EAvlYhPhA=="], + } +} diff --git a/dot-line-system/index.html b/dot-line-system/index.html new file mode 100644 index 0000000..415baa6 --- /dev/null +++ b/dot-line-system/index.html @@ -0,0 +1,25 @@ + + + + + + + + Life Line + + + + + + + + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/dot-line-system/package-lock.json b/dot-line-system/package-lock.json new file mode 100644 index 0000000..139d2ca --- /dev/null +++ b/dot-line-system/package-lock.json @@ -0,0 +1,1006 @@ +{ + "name": "dot-line-system", + "version": "0.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "dot-line-system", + "version": "0.0.0", + "devDependencies": { + "typescript": "~5.7.2", + "vite": "^6.3.5" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.25.4", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.4.tgz", + "integrity": "sha512-1VCICWypeQKhVbE9oW/sJaAmjLxhVqacdkvPLEjwlttjfwENRSClS8EjBz0KzRyFSCPDIkuXW34Je/vk7zdB7Q==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.25.4", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.4.tgz", + "integrity": "sha512-QNdQEps7DfFwE3hXiU4BZeOV68HHzYwGd0Nthhd3uCkkEKK7/R6MTgM0P7H7FAs5pU/DIWsviMmEGxEoxIZ+ZQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.25.4", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.4.tgz", + "integrity": "sha512-bBy69pgfhMGtCnwpC/x5QhfxAz/cBgQ9enbtwjf6V9lnPI/hMyT9iWpR1arm0l3kttTr4L0KSLpKmLp/ilKS9A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.25.4", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.4.tgz", + "integrity": "sha512-TVhdVtQIFuVpIIR282btcGC2oGQoSfZfmBdTip2anCaVYcqWlZXGcdcKIUklfX2wj0JklNYgz39OBqh2cqXvcQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.25.4", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.4.tgz", + "integrity": "sha512-Y1giCfM4nlHDWEfSckMzeWNdQS31BQGs9/rouw6Ub91tkK79aIMTH3q9xHvzH8d0wDru5Ci0kWB8b3up/nl16g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.25.4", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.4.tgz", + "integrity": "sha512-CJsry8ZGM5VFVeyUYB3cdKpd/H69PYez4eJh1W/t38vzutdjEjtP7hB6eLKBoOdxcAlCtEYHzQ/PJ/oU9I4u0A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.25.4", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.4.tgz", + "integrity": "sha512-0FgvOJ6UUMflsHSPLzdfDnnBBVoCDtBTVyn/MrWloUNvq/5SFmh13l3dvgRPkDihRxb77Y17MbqbCAa2strMQQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.25.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.4.tgz", + "integrity": "sha512-kro4c0P85GMfFYqW4TWOpvmF8rFShbWGnrLqlzp4X1TNWjRY3JMYUfDCtOxPKOIY8B0WC8HN51hGP4I4hz4AaQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.25.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.4.tgz", + "integrity": "sha512-+89UsQTfXdmjIvZS6nUnOOLoXnkUTB9hR5QAeLrQdzOSWZvNSAXAtcRDHWtqAUtAmv7ZM1WPOOeSxDzzzMogiQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.25.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.4.tgz", + "integrity": "sha512-yTEjoapy8UP3rv8dB0ip3AfMpRbyhSN3+hY8mo/i4QXFeDxmiYbEKp3ZRjBKcOP862Ua4b1PDfwlvbuwY7hIGQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.25.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.4.tgz", + "integrity": "sha512-NeqqYkrcGzFwi6CGRGNMOjWGGSYOpqwCjS9fvaUlX5s3zwOtn1qwg1s2iE2svBe4Q/YOG1q6875lcAoQK/F4VA==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.25.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.4.tgz", + "integrity": "sha512-IcvTlF9dtLrfL/M8WgNI/qJYBENP3ekgsHbYUIzEzq5XJzzVEV/fXY9WFPfEEXmu3ck2qJP8LG/p3Q8f7Zc2Xg==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.25.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.4.tgz", + "integrity": "sha512-HOy0aLTJTVtoTeGZh4HSXaO6M95qu4k5lJcH4gxv56iaycfz1S8GO/5Jh6X4Y1YiI0h7cRyLi+HixMR+88swag==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.25.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.4.tgz", + "integrity": "sha512-i8JUDAufpz9jOzo4yIShCTcXzS07vEgWzyX3NH2G7LEFVgrLEhjwL3ajFE4fZI3I4ZgiM7JH3GQ7ReObROvSUA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.25.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.4.tgz", + "integrity": "sha512-jFnu+6UbLlzIjPQpWCNh5QtrcNfMLjgIavnwPQAfoGx4q17ocOU9MsQ2QVvFxwQoWpZT8DvTLooTvmOQXkO51g==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.25.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.4.tgz", + "integrity": "sha512-6e0cvXwzOnVWJHq+mskP8DNSrKBr1bULBvnFLpc1KY+d+irZSgZ02TGse5FsafKS5jg2e4pbvK6TPXaF/A6+CA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.4", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.4.tgz", + "integrity": "sha512-vUnkBYxZW4hL/ie91hSqaSNjulOnYXE1VSLusnvHg2u3jewJBz3YzB9+oCw8DABeVqZGg94t9tyZFoHma8gWZQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.25.4", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.4.tgz", + "integrity": "sha512-XAg8pIQn5CzhOB8odIcAm42QsOfa98SBeKUdo4xa8OvX8LbMZqEtgeWE9P/Wxt7MlG2QqvjGths+nq48TrUiKw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.4", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.4.tgz", + "integrity": "sha512-Ct2WcFEANlFDtp1nVAXSNBPDxyU+j7+tId//iHXU2f/lN5AmO4zLyhDcpR5Cz1r08mVxzt3Jpyt4PmXQ1O6+7A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.25.4", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.4.tgz", + "integrity": "sha512-xAGGhyOQ9Otm1Xu8NT1ifGLnA6M3sJxZ6ixylb+vIUVzvvd6GOALpwQrYrtlPouMqd/vSbgehz6HaVk4+7Afhw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.25.4", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.4.tgz", + "integrity": "sha512-Mw+tzy4pp6wZEK0+Lwr76pWLjrtjmJyUB23tHKqEDP74R3q95luY/bXqXZeYl4NYlvwOqoRKlInQialgCKy67Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.25.4", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.4.tgz", + "integrity": "sha512-AVUP428VQTSddguz9dO9ngb+E5aScyg7nOeJDrF1HPYu555gmza3bDGMPhmVXL8svDSoqPCsCPjb265yG/kLKQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.25.4", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.4.tgz", + "integrity": "sha512-i1sW+1i+oWvQzSgfRcxxG2k4I9n3O9NRqy8U+uugaT2Dy7kLO9Y7wI72haOahxceMX8hZAzgGou1FhndRldxRg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.25.4", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.4.tgz", + "integrity": "sha512-nOT2vZNw6hJ+z43oP1SPea/G/6AbN6X+bGNhNuq8NtRHy4wsMhw765IKLNmnjek7GvjWBYQ8Q5VBoYTFg9y1UQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.40.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.40.2.tgz", + "integrity": "sha512-JkdNEq+DFxZfUwxvB58tHMHBHVgX23ew41g1OQinthJ+ryhdRk67O31S7sYw8u2lTjHUPFxwar07BBt1KHp/hg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.40.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.40.2.tgz", + "integrity": "sha512-13unNoZ8NzUmnndhPTkWPWbX3vtHodYmy+I9kuLxN+F+l+x3LdVF7UCu8TWVMt1POHLh6oDHhnOA04n8oJZhBw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.40.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.40.2.tgz", + "integrity": "sha512-Gzf1Hn2Aoe8VZzevHostPX23U7N5+4D36WJNHK88NZHCJr7aVMG4fadqkIf72eqVPGjGc0HJHNuUaUcxiR+N/w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.40.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.40.2.tgz", + "integrity": "sha512-47N4hxa01a4x6XnJoskMKTS8XZ0CZMd8YTbINbi+w03A2w4j1RTlnGHOz/P0+Bg1LaVL6ufZyNprSg+fW5nYQQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.40.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.40.2.tgz", + "integrity": "sha512-8t6aL4MD+rXSHHZUR1z19+9OFJ2rl1wGKvckN47XFRVO+QL/dUSpKA2SLRo4vMg7ELA8pzGpC+W9OEd1Z/ZqoQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.40.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.40.2.tgz", + "integrity": "sha512-C+AyHBzfpsOEYRFjztcYUFsH4S7UsE9cDtHCtma5BK8+ydOZYgMmWg1d/4KBytQspJCld8ZIujFMAdKG1xyr4Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.40.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.40.2.tgz", + "integrity": "sha512-de6TFZYIvJwRNjmW3+gaXiZ2DaWL5D5yGmSYzkdzjBDS3W+B9JQ48oZEsmMvemqjtAFzE16DIBLqd6IQQRuG9Q==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.40.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.40.2.tgz", + "integrity": "sha512-urjaEZubdIkacKc930hUDOfQPysezKla/O9qV+O89enqsqUmQm8Xj8O/vh0gHg4LYfv7Y7UsE3QjzLQzDYN1qg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.40.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.40.2.tgz", + "integrity": "sha512-KlE8IC0HFOC33taNt1zR8qNlBYHj31qGT1UqWqtvR/+NuCVhfufAq9fxO8BMFC22Wu0rxOwGVWxtCMvZVLmhQg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.40.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.40.2.tgz", + "integrity": "sha512-j8CgxvfM0kbnhu4XgjnCWJQyyBOeBI1Zq91Z850aUddUmPeQvuAy6OiMdPS46gNFgy8gN1xkYyLgwLYZG3rBOg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loongarch64-gnu": { + "version": "4.40.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.40.2.tgz", + "integrity": "sha512-Ybc/1qUampKuRF4tQXc7G7QY9YRyeVSykfK36Y5Qc5dmrIxwFhrOzqaVTNoZygqZ1ZieSWTibfFhQ5qK8jpWxw==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { + "version": "4.40.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.40.2.tgz", + "integrity": "sha512-3FCIrnrt03CCsZqSYAOW/k9n625pjpuMzVfeI+ZBUSDT3MVIFDSPfSUgIl9FqUftxcUXInvFah79hE1c9abD+Q==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.40.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.40.2.tgz", + "integrity": "sha512-QNU7BFHEvHMp2ESSY3SozIkBPaPBDTsfVNGx3Xhv+TdvWXFGOSH2NJvhD1zKAT6AyuuErJgbdvaJhYVhVqrWTg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.40.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.40.2.tgz", + "integrity": "sha512-5W6vNYkhgfh7URiXTO1E9a0cy4fSgfE4+Hl5agb/U1sa0kjOLMLC1wObxwKxecE17j0URxuTrYZZME4/VH57Hg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.40.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.40.2.tgz", + "integrity": "sha512-B7LKIz+0+p348JoAL4X/YxGx9zOx3sR+o6Hj15Y3aaApNfAshK8+mWZEf759DXfRLeL2vg5LYJBB7DdcleYCoQ==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.40.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.40.2.tgz", + "integrity": "sha512-lG7Xa+BmBNwpjmVUbmyKxdQJ3Q6whHjMjzQplOs5Z+Gj7mxPtWakGHqzMqNER68G67kmCX9qX57aRsW5V0VOng==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.40.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.40.2.tgz", + "integrity": "sha512-tD46wKHd+KJvsmije4bUskNuvWKFcTOIM9tZ/RrmIvcXnbi0YK/cKS9FzFtAm7Oxi2EhV5N2OpfFB348vSQRXA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.40.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.40.2.tgz", + "integrity": "sha512-Bjv/HG8RRWLNkXwQQemdsWw4Mg+IJ29LK+bJPW2SCzPKOUaMmPEppQlu/Fqk1d7+DX3V7JbFdbkh/NMmurT6Pg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.40.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.40.2.tgz", + "integrity": "sha512-dt1llVSGEsGKvzeIO76HToiYPNPYPkmjhMHhP00T9S4rDern8P2ZWvWAQUEJ+R1UdMWJ/42i/QqJ2WV765GZcA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.40.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.40.2.tgz", + "integrity": "sha512-bwspbWB04XJpeElvsp+DCylKfF4trJDa2Y9Go8O6A7YLX2LIKGcNK/CYImJN6ZP4DcuOHB4Utl3iCbnR62DudA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@types/estree": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.7.tgz", + "integrity": "sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/esbuild": { + "version": "0.25.4", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.4.tgz", + "integrity": "sha512-8pgjLUcUjcgDg+2Q4NYXnPbo/vncAY4UmyaCm0jZevERqCHZIaWwdJHkf8XQtu4AxSKCdvrUbT0XUr1IdZzI8Q==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.25.4", + "@esbuild/android-arm": "0.25.4", + "@esbuild/android-arm64": "0.25.4", + "@esbuild/android-x64": "0.25.4", + "@esbuild/darwin-arm64": "0.25.4", + "@esbuild/darwin-x64": "0.25.4", + "@esbuild/freebsd-arm64": "0.25.4", + "@esbuild/freebsd-x64": "0.25.4", + "@esbuild/linux-arm": "0.25.4", + "@esbuild/linux-arm64": "0.25.4", + "@esbuild/linux-ia32": "0.25.4", + "@esbuild/linux-loong64": "0.25.4", + "@esbuild/linux-mips64el": "0.25.4", + "@esbuild/linux-ppc64": "0.25.4", + "@esbuild/linux-riscv64": "0.25.4", + "@esbuild/linux-s390x": "0.25.4", + "@esbuild/linux-x64": "0.25.4", + "@esbuild/netbsd-arm64": "0.25.4", + "@esbuild/netbsd-x64": "0.25.4", + "@esbuild/openbsd-arm64": "0.25.4", + "@esbuild/openbsd-x64": "0.25.4", + "@esbuild/sunos-x64": "0.25.4", + "@esbuild/win32-arm64": "0.25.4", + "@esbuild/win32-ia32": "0.25.4", + "@esbuild/win32-x64": "0.25.4" + } + }, + "node_modules/fdir": { + "version": "6.4.4", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.4.tgz", + "integrity": "sha512-1NZP+GK4GfuAv3PqKvxQRDMjdSRZjnkq7KfhlNrCNNlZ0ygQFpebfrnfnq/W7fpUnAv9aGWmY1zKx7FYL3gwhg==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/nanoid": { + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", + "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", + "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/postcss": { + "version": "8.5.3", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.3.tgz", + "integrity": "sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.8", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/rollup": { + "version": "4.40.2", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.40.2.tgz", + "integrity": "sha512-tfUOg6DTP4rhQ3VjOO6B4wyrJnGOX85requAXvqYTHsOgb2TFJdZ3aWpT8W2kPoypSGP7dZUyzxJ9ee4buM5Fg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.7" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.40.2", + "@rollup/rollup-android-arm64": "4.40.2", + "@rollup/rollup-darwin-arm64": "4.40.2", + "@rollup/rollup-darwin-x64": "4.40.2", + "@rollup/rollup-freebsd-arm64": "4.40.2", + "@rollup/rollup-freebsd-x64": "4.40.2", + "@rollup/rollup-linux-arm-gnueabihf": "4.40.2", + "@rollup/rollup-linux-arm-musleabihf": "4.40.2", + "@rollup/rollup-linux-arm64-gnu": "4.40.2", + "@rollup/rollup-linux-arm64-musl": "4.40.2", + "@rollup/rollup-linux-loongarch64-gnu": "4.40.2", + "@rollup/rollup-linux-powerpc64le-gnu": "4.40.2", + "@rollup/rollup-linux-riscv64-gnu": "4.40.2", + "@rollup/rollup-linux-riscv64-musl": "4.40.2", + "@rollup/rollup-linux-s390x-gnu": "4.40.2", + "@rollup/rollup-linux-x64-gnu": "4.40.2", + "@rollup/rollup-linux-x64-musl": "4.40.2", + "@rollup/rollup-win32-arm64-msvc": "4.40.2", + "@rollup/rollup-win32-ia32-msvc": "4.40.2", + "@rollup/rollup-win32-x64-msvc": "4.40.2", + "fsevents": "~2.3.2" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.13.tgz", + "integrity": "sha512-mEwzpUgrLySlveBwEVDMKk5B57bhLPYovRfPAXD5gA/98Opn0rCDj3GtLwFvCvH5RK9uPCExUROW5NjDwvqkxw==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.4.4", + "picomatch": "^4.0.2" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/typescript": { + "version": "5.7.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz", + "integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/vite": { + "version": "6.3.5", + "resolved": "https://registry.npmjs.org/vite/-/vite-6.3.5.tgz", + "integrity": "sha512-cZn6NDFE7wdTpINgs++ZJ4N49W2vRp8LCKrn3Ob1kYNtOo21vfDoaV5GzBfLU4MovSAB8uNRm4jgzVQZ+mBzPQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "^0.25.0", + "fdir": "^6.4.4", + "picomatch": "^4.0.2", + "postcss": "^8.5.3", + "rollup": "^4.34.9", + "tinyglobby": "^0.2.13" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^18.0.0 || ^20.0.0 || >=22.0.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", + "jiti": ">=1.21.0", + "less": "*", + "lightningcss": "^1.21.0", + "sass": "*", + "sass-embedded": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + } + } +} diff --git a/dot-line-system/package.json b/dot-line-system/package.json new file mode 100644 index 0000000..882780f --- /dev/null +++ b/dot-line-system/package.json @@ -0,0 +1,20 @@ +{ + "name": "dot-line-system", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc && vite build", + "preview": "vite preview" + }, + "devDependencies": { + "typescript": "~5.7.2", + "vite": "^6.3.5" + }, + "scripts": { + "build": "vite build", + "start": "vite", + "tsc": "tsc" + } +} diff --git a/dot-line-system/public/ScrollTrigger.min.js b/dot-line-system/public/ScrollTrigger.min.js new file mode 100644 index 0000000..01c8533 --- /dev/null +++ b/dot-line-system/public/ScrollTrigger.min.js @@ -0,0 +1,11 @@ +/*! + * ScrollTrigger 3.12.7 + * https://gsap.com + * + * @license Copyright 2025, GreenSock. All rights reserved. + * Subject to the terms at https://gsap.com/standard-license or for Club GSAP members, the agreement issued with that membership. + * @author: Jack Doyle, jack@greensock.com + */ + +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).window=e.window||{})}(this,function(e){"use strict";function _defineProperties(e,t){for(var r=0;r=Math.abs(r)?t:r}function O(){(Ae=Te.core.globals().ScrollTrigger)&&Ae.core&&function _integrate(){var e=Ae.core,r=e.bridge||{},t=e._scrollers,n=e._proxies;t.push.apply(t,qe),n.push.apply(n,Ie),qe=t,Ie=n,o=function _bridge(e,t){return r[e](t)}}()}function P(e){return Te=e||r(),!Ce&&Te&&"undefined"!=typeof document&&document.body&&(Se=window,Ee=(ke=document).documentElement,Pe=ke.body,t=[Se,ke,Ee,Pe],Te.utils.clamp,Re=Te.core.context||function(){},Oe="onpointerenter"in Pe?"pointer":"mouse",Me=k.isTouch=Se.matchMedia&&Se.matchMedia("(hover: none), (pointer: coarse)").matches?1:"ontouchstart"in Se||0=i,n=Math.abs(t)>=i;S&&(r||n)&&S(se,e,t,me,ye),r&&(m&&0Math.abs(t)?"x":"y",oe=!0),"y"!==ae&&(me[2]+=e,se._vx.update(e,!0)),"x"!==ae&&(ye[2]+=t,se._vy.update(t,!0)),n?ee=ee||requestAnimationFrame(ff):ff()}function jf(e){if(!df(e,1)){var t=(e=M(e,s)).clientX,r=e.clientY,n=t-se.x,i=r-se.y,o=se.isDragging;se.x=t,se.y=r,(o||(n||i)&&(Math.abs(se.startX-t)>=a||Math.abs(se.startY-r)>=a))&&(re=o?2:1,o||(se.isDragging=!0),hf(n,i))}}function mf(e){return e.touches&&1=e)return a[n];return a[n-1]}for(n=a.length,e+=r;n--;)if(a[n]<=e)return a[n];return a[0]}:function(e,t,r){void 0===r&&(r=.001);var n=o(e);return!t||Math.abs(n-e)r&&(n*=t/100),e=e.substr(0,r-1)),e=n+(e in H?H[e]*t:~e.indexOf("%")?parseFloat(e)*t/100:parseFloat(e)||0)}return e}function Db(e,t,r,n,i,o,a,s){var l=i.startColor,c=i.endColor,u=i.fontSize,f=i.indent,d=i.fontWeight,p=Xe.createElement("div"),g=La(r)||"fixed"===z(r,"pinType"),h=-1!==e.indexOf("scroller"),v=g?Je:r,b=-1!==e.indexOf("start"),m=b?l:c,y="border-color:"+m+";font-size:"+u+";color:"+m+";font-weight:"+d+";pointer-events:none;white-space:nowrap;font-family:sans-serif,Arial;z-index:1000;padding:4px 8px;border-width:0;border-style:solid;";return y+="position:"+((h||s)&&g?"fixed;":"absolute;"),!h&&!s&&g||(y+=(n===ze?q:I)+":"+(o+parseFloat(f))+"px;"),a&&(y+="box-sizing:border-box;text-align:left;width:"+a.offsetWidth+"px;"),p._isStart=b,p.setAttribute("class","gsap-marker-"+e+(t?" marker-"+t:"")),p.style.cssText=y,p.innerText=t||0===t?e+"-"+t:e,v.children[0]?v.insertBefore(p,v.children[0]):v.appendChild(p),p._offset=p["offset"+n.op.d2],X(p,0,n,b),p}function Ib(){return 34Je.clientWidth)||(qe.cache++,v?D=D||requestAnimationFrame(Z):Z(),st||U("scrollStart"),st=at())}function Kb(){y=Ne.innerWidth,m=Ne.innerHeight}function Lb(e){qe.cache++,!0!==e&&(Ke||h||Xe.fullscreenElement||Xe.webkitFullscreenElement||b&&y===Ne.innerWidth&&!(Math.abs(Ne.innerHeight-m)>.25*Ne.innerHeight))||c.restart(!0)}function Ob(){return xb(ne,"scrollEnd",Ob)||Et(!0)}function Rb(e){for(var t=0;tt,n=e._startClamp&&e.start>=t;(r||n)&&e.setPositions(n?t-1:e.start,r?Math.max(n?t:e.start+1,t):e.end,!0)}),Zb(!1),et=0,r.forEach(function(e){return e&&e.render&&e.render(-1)}),qe.forEach(function(e){Ta(e)&&(e.smooth&&requestAnimationFrame(function(){return e.target.style.scrollBehavior="smooth"}),e.rec&&e(e.rec))}),Tb(w,1),c.pause(),kt++,Z(rt=2),Ct.forEach(function(e){return Ta(e.vars.onRefresh)&&e.vars.onRefresh(e)}),rt=ne.isRefreshing=!1,U("refresh")}else wb(ne,"scrollEnd",Ob)},Q=0,Pt=1,Z=function _updateAll(e){if(2===e||!rt&&!S){ne.isUpdating=!0,it&&it.update(0);var t=Ct.length,r=at(),n=50<=r-R,i=t&&Ct[0].scroll();if(Pt=i=Qa(be,he)){if(oe&&Ae()&&!de)for(o=oe.parentNode;o&&o!==Je;)o._pinOffset&&(R-=o._pinOffset,L-=o._pinOffset),o=o.parentNode}else i=mb(ae),s=he===ze,a=Ae(),j=parseFloat(G(he.a))+_,!y&&1=L})},Ce.update=function(e,t,r){if(!de||r||e){var n,i,o,a,s,l,c,u=!0===rt?re:Ce.scroll(),f=e?0:(u-R)/N,d=f<0?0:1u+(u-B)/(at()-Ge)*P&&(d=.9999)),d!==p&&Ce.enabled){if(a=(s=(n=Ce.isActive=!!d&&d<1)!=(!!p&&p<1))||!!d!=!!p,Ce.direction=p=Qa(be,he),fe)if(e||!n&&!l)oc(ae,U);else{var g=wt(ae,!0),h=u-R;oc(ae,Je,g.top+(he===ze?h:0)+xt,g.left+(he===ze?0:h)+xt)}Mt(n||l?W:V),$&&d<1&&n||b(j+(1!==d||l?0:Q))}}else b(Ia(j+Q*d));!ue||A.tween||Ke||ot||te.restart(!0),S&&(s||ce&&d&&(d<1||!tt))&&Ve(S.targets).forEach(function(e){return e.classList[n||ce?"add":"remove"](S.className)}),!C||ve||e||C(Ce),a&&!Ke?(ve&&(c&&("complete"===o?O.pause().totalProgress(1):"reset"===o?O.restart(!0).pause():"restart"===o?O.restart(!0):O[o]()),C&&C(Ce)),!s&&tt||(k&&s&&Xa(Ce,k),xe[i]&&Xa(Ce,xe[i]),ce&&(1===d?Ce.kill(!1,1):xe[i]=0),s||xe[i=1===d?1:3]&&Xa(Ce,xe[i])),pe&&!n&&Math.abs(Ce.getVelocity())>(Ua(pe)?pe:2500)&&(Wa(Ce.callbackAnimation),ee?ee.progress(1):Wa(O,"reverse"===o?1:!d,1))):ve&&C&&!Ke&&C(Ce)}if(x){var v=de?u/de.duration()*(de._caScrollDist||0):u;y(v+(Y._isFlipped?1:0)),x(v)}T&&T(-u/de.duration()*(de._caScrollDist||0))}},Ce.enable=function(e,t){Ce.enabled||(Ce.enabled=!0,wb(be,"resize",Lb),me||wb(be,"scroll",Jb),Se&&wb(ScrollTrigger,"refreshInit",Se),!1!==e&&(Ce.progress=Oe=0,D=B=Pe=Ae()),!1!==t&&Ce.refresh())},Ce.getTween=function(e){return e&&A?A.tween:ee},Ce.setPositions=function(e,t,r,n){if(de){var i=de.scrollTrigger,o=de.duration(),a=i.end-i.start;e=i.start+a*e/o,t=i.start+a*t/o}Ce.refresh(!1,!1,{start:Da(e,r&&!!Ce._startClamp),end:Da(t,r&&!!Ce._endClamp)},n),Ce.update()},Ce.adjustPinSpacing=function(e){if(Z&&e){var t=Z.indexOf(he.d)+1;Z[t]=parseFloat(Z[t])+e+xt,Z[1]=parseFloat(Z[1])+e+xt,Mt(Z)}},Ce.disable=function(e,t){if(Ce.enabled&&(!1!==e&&Ce.revert(!0,!0),Ce.enabled=Ce.isActive=!1,t||ee&&ee.pause(),re=0,n&&(n.uncache=1),Se&&xb(ScrollTrigger,"refreshInit",Se),te&&(te.pause(),A.tween&&A.tween.kill()&&(A.tween=0)),!me)){for(var r=Ct.length;r--;)if(Ct[r].scroller===be&&Ct[r]!==Ce)return;xb(be,"resize",Lb),me||xb(be,"scroll",Jb)}},Ce.kill=function(e,t){Ce.disable(e,t),ee&&!t&&ee.kill(),a&&delete St[a];var r=Ct.indexOf(Ce);0<=r&&Ct.splice(r,1),r===Qe&&0o&&(b()>o?a.progress(1)&&b(o):a.resetTo("scrollY",o))}Va(e)||(e={}),e.preventDefault=e.isNormalizer=e.allowClicks=!0,e.type||(e.type="wheel,touch"),e.debounce=!!e.debounce,e.id=e.id||"normalizer";var n,o,l,i,a,c,u,s,f=e.normalizeScrollX,t=e.momentum,r=e.allowNestedScroll,d=e.onRelease,p=J(e.target)||We,g=He.core.globals().ScrollSmoother,h=g&&g.get(),v=E&&(e.content&&J(e.content)||h&&!1!==e.content&&!h.smooth()&&h.content()),b=K(p,ze),m=K(p,Fe),y=1,x=(k.isTouch&&Ne.visualViewport?Ne.visualViewport.scale*Ne.visualViewport.width:Ne.outerWidth)/Ne.innerWidth,w=0,_=Ta(t)?function(){return t(n)}:function(){return t||2.8},T=xc(p,e.type,!0,r),C=Ha,S=Ha;return v&&He.set(v,{y:"+=0"}),e.ignoreCheck=function(e){return E&&"touchmove"===e.type&&function ignoreDrag(){if(i){requestAnimationFrame(Bq);var e=Ia(n.deltaY/2),t=S(b.v-e);if(v&&t!==b.v+b.offset){b.offset=t-b.v;var r=Ia((parseFloat(v&&v._gsap.y)||0)-b.offset);v.style.transform="matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, "+r+", 0, 1)",v._gsap.y=r+"px",b.cacheID=qe.cache,Z()}return!0}b.offset&&Fq(),i=!0}()||1.05=o||o-1<=r)&&He.to({},{onUpdate:Lq,duration:i})}else s.restart(!0);d&&d(e)},e.onWheel=function(){a._ts&&a.pause(),1e3 gsap || (typeof(window) !== \"undefined\" && (gsap = window.gsap) && gsap.registerPlugin && gsap),\n\t_startup = 1,\n\t_observers = [],\n\t_scrollers = [],\n\t_proxies = [],\n\t_getTime = Date.now,\n\t_bridge = (name, value) => value,\n\t_integrate = () => {\n\t\tlet core = ScrollTrigger.core,\n\t\t\tdata = core.bridge || {},\n\t\t\tscrollers = core._scrollers,\n\t\t\tproxies = core._proxies;\n\t\tscrollers.push(..._scrollers);\n\t\tproxies.push(..._proxies);\n\t\t_scrollers = scrollers;\n\t\t_proxies = proxies;\n\t\t_bridge = (name, value) => data[name](value);\n\t},\n\t_getProxyProp = (element, property) => ~_proxies.indexOf(element) && _proxies[_proxies.indexOf(element) + 1][property],\n\t_isViewport = el => !!~_root.indexOf(el),\n\t_addListener = (element, type, func, passive, capture) => element.addEventListener(type, func, {passive: passive !== false, capture: !!capture}),\n\t_removeListener = (element, type, func, capture) => element.removeEventListener(type, func, !!capture),\n\t_scrollLeft = \"scrollLeft\",\n\t_scrollTop = \"scrollTop\",\n\t_onScroll = () => (_normalizer && _normalizer.isPressed) || _scrollers.cache++,\n\t_scrollCacheFunc = (f, doNotCache) => {\n\t\tlet cachingFunc = value => { // since reading the scrollTop/scrollLeft/pageOffsetY/pageOffsetX can trigger a layout, this function allows us to cache the value so it only gets read fresh after a \"scroll\" event fires (or while we're refreshing because that can lengthen the page and alter the scroll position). when \"soft\" is true, that means don't actually set the scroll, but cache the new value instead (useful in ScrollSmoother)\n\t\t\tif (value || value === 0) {\n\t\t\t\t_startup && (_win.history.scrollRestoration = \"manual\"); // otherwise the new position will get overwritten by the browser onload.\n\t\t\t\tlet isNormalizing = _normalizer && _normalizer.isPressed;\n\t\t\t\tvalue = cachingFunc.v = Math.round(value) || (_normalizer && _normalizer.iOS ? 1 : 0); //TODO: iOS Bug: if you allow it to go to 0, Safari can start to report super strange (wildly inaccurate) touch positions!\n\t\t\t\tf(value);\n\t\t\t\tcachingFunc.cacheID = _scrollers.cache;\n\t\t\t\tisNormalizing && _bridge(\"ss\", value); // set scroll (notify ScrollTrigger so it can dispatch a \"scrollStart\" event if necessary\n\t\t\t} else if (doNotCache || _scrollers.cache !== cachingFunc.cacheID || _bridge(\"ref\")) {\n\t\t\t\tcachingFunc.cacheID = _scrollers.cache;\n\t\t\t\tcachingFunc.v = f();\n\t\t\t}\n\t\t\treturn cachingFunc.v + cachingFunc.offset;\n\t\t};\n\t\tcachingFunc.offset = 0;\n\t\treturn f && cachingFunc;\n\t},\n\t_horizontal = {s: _scrollLeft, p: \"left\", p2: \"Left\", os: \"right\", os2: \"Right\", d: \"width\", d2: \"Width\", a: \"x\", sc: _scrollCacheFunc(function(value) { return arguments.length ? _win.scrollTo(value, _vertical.sc()) : _win.pageXOffset || _doc[_scrollLeft] || _docEl[_scrollLeft] || _body[_scrollLeft] || 0})},\n\t_vertical = {s: _scrollTop, p: \"top\", p2: \"Top\", os: \"bottom\", os2: \"Bottom\", d: \"height\", d2: \"Height\", a: \"y\", op: _horizontal, sc: _scrollCacheFunc(function(value) { return arguments.length ? _win.scrollTo(_horizontal.sc(), value) : _win.pageYOffset || _doc[_scrollTop] || _docEl[_scrollTop] || _body[_scrollTop] || 0})},\n\t_getTarget = (t, self) => ((self && self._ctx && self._ctx.selector) || gsap.utils.toArray)(t)[0] || (typeof(t) === \"string\" && gsap.config().nullTargetWarn !== false ? console.warn(\"Element not found:\", t) : null),\n\n\t_getScrollFunc = (element, {s, sc}) => { // we store the scroller functions in an alternating sequenced Array like [element, verticalScrollFunc, horizontalScrollFunc, ...] so that we can minimize memory, maximize performance, and we also record the last position as a \".rec\" property in order to revert to that after refreshing to ensure things don't shift around.\n\t\t_isViewport(element) && (element = _doc.scrollingElement || _docEl);\n\t\tlet i = _scrollers.indexOf(element),\n\t\t\toffset = sc === _vertical.sc ? 1 : 2;\n\t\t!~i && (i = _scrollers.push(element) - 1);\n\t\t_scrollers[i + offset] || _addListener(element, \"scroll\", _onScroll); // clear the cache when a scroll occurs\n\t\tlet prev = _scrollers[i + offset],\n\t\t\tfunc = prev || (_scrollers[i + offset] = _scrollCacheFunc(_getProxyProp(element, s), true) || (_isViewport(element) ? sc : _scrollCacheFunc(function(value) { return arguments.length ? (element[s] = value) : element[s]; })));\n\t\tfunc.target = element;\n\t\tprev || (func.smooth = gsap.getProperty(element, \"scrollBehavior\") === \"smooth\"); // only set it the first time (don't reset every time a scrollFunc is requested because perhaps it happens during a refresh() when it's disabled in ScrollTrigger.\n\t\treturn func;\n\t},\n\t_getVelocityProp = (value, minTimeRefresh, useDelta) => {\n\t\tlet v1 = value,\n\t\t\tv2 = value,\n\t\t\tt1 = _getTime(),\n\t\t\tt2 = t1,\n\t\t\tmin = minTimeRefresh || 50,\n\t\t\tdropToZeroTime = Math.max(500, min * 3),\n\t\t\tupdate = (value, force) => {\n\t\t\t\tlet t = _getTime();\n\t\t\t\tif (force || t - t1 > min) {\n\t\t\t\t\tv2 = v1;\n\t\t\t\t\tv1 = value;\n\t\t\t\t\tt2 = t1;\n\t\t\t\t\tt1 = t;\n\t\t\t\t} else if (useDelta) {\n\t\t\t\t\tv1 += value;\n\t\t\t\t} else { // not totally necessary, but makes it a bit more accurate by adjusting the v1 value according to the new slope. This way we're not just ignoring the incoming data. Removing for now because it doesn't seem to make much practical difference and it's probably not worth the kb.\n\t\t\t\t\tv1 = v2 + (value - v2) / (t - t2) * (t1 - t2);\n\t\t\t\t}\n\t\t\t},\n\t\t\treset = () => { v2 = v1 = useDelta ? 0 : v1; t2 = t1 = 0; },\n\t\t\tgetVelocity = latestValue => {\n\t\t\t\tlet tOld = t2,\n\t\t\t\t\tvOld = v2,\n\t\t\t\t\tt = _getTime();\n\t\t\t\t(latestValue || latestValue === 0) && latestValue !== v1 && update(latestValue);\n\t\t\t\treturn (t1 === t2 || t - t2 > dropToZeroTime) ? 0 : (v1 + (useDelta ? vOld : -vOld)) / ((useDelta ? t : t1) - tOld) * 1000;\n\t\t\t};\n\t\treturn {update, reset, getVelocity};\n\t},\n\t_getEvent = (e, preventDefault) => {\n\t\tpreventDefault && !e._gsapAllow && e.preventDefault();\n\t\treturn e.changedTouches ? e.changedTouches[0] : e;\n\t},\n\t_getAbsoluteMax = a => {\n\t\tlet max = Math.max(...a),\n\t\t\tmin = Math.min(...a);\n\t\treturn Math.abs(max) >= Math.abs(min) ? max : min;\n\t},\n\t_setScrollTrigger = () => {\n\t\tScrollTrigger = gsap.core.globals().ScrollTrigger;\n\t\tScrollTrigger && ScrollTrigger.core && _integrate();\n\t},\n\t_initCore = core => {\n\t\tgsap = core || _getGSAP();\n\t\tif (!_coreInitted && gsap && typeof(document) !== \"undefined\" && document.body) {\n\t\t\t_win = window;\n\t\t\t_doc = document;\n\t\t\t_docEl = _doc.documentElement;\n\t\t\t_body = _doc.body;\n\t\t\t_root = [_win, _doc, _docEl, _body];\n\t\t\t_clamp = gsap.utils.clamp;\n\t\t\t_context = gsap.core.context || function() {};\n\t\t\t_pointerType = \"onpointerenter\" in _body ? \"pointer\" : \"mouse\";\n\t\t\t// isTouch is 0 if no touch, 1 if ONLY touch, and 2 if it can accommodate touch but also other types like mouse/pointer.\n\t\t\t_isTouch = Observer.isTouch = _win.matchMedia && _win.matchMedia(\"(hover: none), (pointer: coarse)\").matches ? 1 : (\"ontouchstart\" in _win || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0) ? 2 : 0;\n\t\t\t_eventTypes = Observer.eventTypes = (\"ontouchstart\" in _docEl ? \"touchstart,touchmove,touchcancel,touchend\" : !(\"onpointerdown\" in _docEl) ? \"mousedown,mousemove,mouseup,mouseup\" : \"pointerdown,pointermove,pointercancel,pointerup\").split(\",\");\n\t\t\tsetTimeout(() => _startup = 0, 500);\n\t\t\t_setScrollTrigger();\n\t\t\t_coreInitted = 1;\n\t\t}\n\t\treturn _coreInitted;\n\t};\n\n_horizontal.op = _vertical;\n_scrollers.cache = 0;\n\nexport class Observer {\n\tconstructor(vars) {\n\t\tthis.init(vars);\n\t}\n\n\tinit(vars) {\n\t\t_coreInitted || _initCore(gsap) || console.warn(\"Please gsap.registerPlugin(Observer)\");\n\t\tScrollTrigger || _setScrollTrigger();\n\t\tlet {tolerance, dragMinimum, type, target, lineHeight, debounce, preventDefault, onStop, onStopDelay, ignore, wheelSpeed, event, onDragStart, onDragEnd, onDrag, onPress, onRelease, onRight, onLeft, onUp, onDown, onChangeX, onChangeY, onChange, onToggleX, onToggleY, onHover, onHoverEnd, onMove, ignoreCheck, isNormalizer, onGestureStart, onGestureEnd, onWheel, onEnable, onDisable, onClick, scrollSpeed, capture, allowClicks, lockAxis, onLockAxis} = vars;\n\t\tthis.target = target = _getTarget(target) || _docEl;\n\t\tthis.vars = vars;\n\t\tignore && (ignore = gsap.utils.toArray(ignore));\n\t\ttolerance = tolerance || 1e-9;\n\t\tdragMinimum = dragMinimum || 0;\n\t\twheelSpeed = wheelSpeed || 1;\n\t\tscrollSpeed = scrollSpeed || 1;\n\t\ttype = type || \"wheel,touch,pointer\";\n\t\tdebounce = debounce !== false;\n\t\tlineHeight || (lineHeight = parseFloat(_win.getComputedStyle(_body).lineHeight) || 22); // note: browser may report \"normal\", so default to 22.\n\t\tlet id, onStopDelayedCall, dragged, moved, wheeled, locked, axis,\n\t\t\tself = this,\n\t\t\tprevDeltaX = 0,\n\t\t\tprevDeltaY = 0,\n\t\t\tpassive = vars.passive || (!preventDefault && vars.passive !== false),\n\t\t\tscrollFuncX = _getScrollFunc(target, _horizontal),\n\t\t\tscrollFuncY = _getScrollFunc(target, _vertical),\n\t\t\tscrollX = scrollFuncX(),\n\t\t\tscrollY = scrollFuncY(),\n\t\t\tlimitToTouch = ~type.indexOf(\"touch\") && !~type.indexOf(\"pointer\") && _eventTypes[0] === \"pointerdown\", // for devices that accommodate mouse events and touch events, we need to distinguish.\n\t\t\tisViewport = _isViewport(target),\n\t\t\townerDoc = target.ownerDocument || _doc,\n\t\t\tdeltaX = [0, 0, 0], // wheel, scroll, pointer/touch\n\t\t\tdeltaY = [0, 0, 0],\n\t\t\tonClickTime = 0,\n\t\t\tclickCapture = () => onClickTime = _getTime(),\n\t\t\t_ignoreCheck = (e, isPointerOrTouch) => (self.event = e) && (ignore && ~ignore.indexOf(e.target)) || (isPointerOrTouch && limitToTouch && e.pointerType !== \"touch\") || (ignoreCheck && ignoreCheck(e, isPointerOrTouch)),\n\t\t\tonStopFunc = () => {\n\t\t\t\tself._vx.reset();\n\t\t\t\tself._vy.reset();\n\t\t\t\tonStopDelayedCall.pause();\n\t\t\t\tonStop && onStop(self);\n\t\t\t},\n\t\t\tupdate = () => {\n\t\t\t\tlet dx = self.deltaX = _getAbsoluteMax(deltaX),\n\t\t\t\t\tdy = self.deltaY = _getAbsoluteMax(deltaY),\n\t\t\t\t\tchangedX = Math.abs(dx) >= tolerance,\n\t\t\t\t\tchangedY = Math.abs(dy) >= tolerance;\n\t\t\t\tonChange && (changedX || changedY) && onChange(self, dx, dy, deltaX, deltaY); // in ScrollTrigger.normalizeScroll(), we need to know if it was touch/pointer so we need access to the deltaX/deltaY Arrays before we clear them out.\n\t\t\t\tif (changedX) {\n\t\t\t\t\tonRight && self.deltaX > 0 && onRight(self);\n\t\t\t\t\tonLeft && self.deltaX < 0 && onLeft(self);\n\t\t\t\t\tonChangeX && onChangeX(self);\n\t\t\t\t\tonToggleX && ((self.deltaX < 0) !== (prevDeltaX < 0)) && onToggleX(self);\n\t\t\t\t\tprevDeltaX = self.deltaX;\n\t\t\t\t\tdeltaX[0] = deltaX[1] = deltaX[2] = 0\n\t\t\t\t}\n\t\t\t\tif (changedY) {\n\t\t\t\t\tonDown && self.deltaY > 0 && onDown(self);\n\t\t\t\t\tonUp && self.deltaY < 0 && onUp(self);\n\t\t\t\t\tonChangeY && onChangeY(self);\n\t\t\t\t\tonToggleY && ((self.deltaY < 0) !== (prevDeltaY < 0)) && onToggleY(self);\n\t\t\t\t\tprevDeltaY = self.deltaY;\n\t\t\t\t\tdeltaY[0] = deltaY[1] = deltaY[2] = 0\n\t\t\t\t}\n\t\t\t\tif (moved || dragged) {\n\t\t\t\t\tonMove && onMove(self);\n\t\t\t\t\tif (dragged) {\n\t\t\t\t\t\tonDragStart && dragged === 1 && onDragStart(self);\n\t\t\t\t\t\tonDrag && onDrag(self);\n\t\t\t\t\t\tdragged = 0;\n\t\t\t\t\t}\n\t\t\t\t\tmoved = false;\n\t\t\t\t}\n\t\t\t\tlocked && !(locked = false) && onLockAxis && onLockAxis(self);\n\t\t\t\tif (wheeled) {\n\t\t\t\t\tonWheel(self);\n\t\t\t\t\twheeled = false;\n\t\t\t\t}\n\t\t\t\tid = 0;\n\t\t\t},\n\t\t\tonDelta = (x, y, index) => {\n\t\t\t\tdeltaX[index] += x;\n\t\t\t\tdeltaY[index] += y;\n\t\t\t\tself._vx.update(x);\n\t\t\t\tself._vy.update(y);\n\t\t\t\tdebounce ? id || (id = requestAnimationFrame(update)) : update();\n\t\t\t},\n\t\t\tonTouchOrPointerDelta = (x, y) => {\n\t\t\t\tif (lockAxis && !axis) {\n\t\t\t\t\tself.axis = axis = Math.abs(x) > Math.abs(y) ? \"x\" : \"y\";\n\t\t\t\t\tlocked = true;\n\t\t\t\t}\n\t\t\t\tif (axis !== \"y\") {\n\t\t\t\t\tdeltaX[2] += x;\n\t\t\t\t\tself._vx.update(x, true); // update the velocity as frequently as possible instead of in the debounced function so that very quick touch-scrolls (flicks) feel natural. If it's the mouse/touch/pointer, force it so that we get snappy/accurate momentum scroll.\n\t\t\t\t}\n\t\t\t\tif (axis !== \"x\") {\n\t\t\t\t\tdeltaY[2] += y;\n\t\t\t\t\tself._vy.update(y, true);\n\t\t\t\t}\n\t\t\t\tdebounce ? id || (id = requestAnimationFrame(update)) : update();\n\t\t\t},\n\t\t\t_onDrag = e => {\n\t\t\t\tif (_ignoreCheck(e, 1)) {return;}\n\t\t\t\te = _getEvent(e, preventDefault);\n\t\t\t\tlet x = e.clientX,\n\t\t\t\t\ty = e.clientY,\n\t\t\t\t\tdx = x - self.x,\n\t\t\t\t\tdy = y - self.y,\n\t\t\t\t\tisDragging = self.isDragging;\n\t\t\t\tself.x = x;\n\t\t\t\tself.y = y;\n\t\t\t\tif (isDragging || ((dx || dy) && (Math.abs(self.startX - x) >= dragMinimum || Math.abs(self.startY - y) >= dragMinimum))) {\n\t\t\t\t\tdragged = isDragging ? 2 : 1; // dragged: 0 = not dragging, 1 = first drag, 2 = normal drag\n\t\t\t\t\tisDragging || (self.isDragging = true);\n\t\t\t\t\tonTouchOrPointerDelta(dx, dy);\n\t\t\t\t}\n\t\t\t},\n\t\t\t_onPress = self.onPress = e => {\n\t\t\t\tif (_ignoreCheck(e, 1) || (e && e.button)) {return;}\n\t\t\t\tself.axis = axis = null;\n\t\t\t\tonStopDelayedCall.pause();\n\t\t\t\tself.isPressed = true;\n\t\t\t\te = _getEvent(e); // note: may need to preventDefault(?) Won't side-scroll on iOS Safari if we do, though.\n\t\t\t\tprevDeltaX = prevDeltaY = 0;\n\t\t\t\tself.startX = self.x = e.clientX;\n\t\t\t\tself.startY = self.y = e.clientY;\n\t\t\t\tself._vx.reset(); // otherwise the t2 may be stale if the user touches and flicks super fast and releases in less than 2 requestAnimationFrame ticks, causing velocity to be 0.\n\t\t\t\tself._vy.reset();\n\t\t\t\t_addListener(isNormalizer ? target : ownerDoc, _eventTypes[1], _onDrag, passive, true);\n\t\t\t\tself.deltaX = self.deltaY = 0;\n\t\t\t\tonPress && onPress(self);\n\t\t\t},\n\t\t\t_onRelease = self.onRelease = e => {\n\t\t\t\tif (_ignoreCheck(e, 1)) {return;}\n\t\t\t\t_removeListener(isNormalizer ? target : ownerDoc, _eventTypes[1], _onDrag, true);\n\t\t\t\tlet isTrackingDrag = !isNaN(self.y - self.startY),\n\t\t\t\t\twasDragging = self.isDragging,\n\t\t\t\t\tisDragNotClick = wasDragging && (Math.abs(self.x - self.startX) > 3 || Math.abs(self.y - self.startY) > 3), // some touch devices need some wiggle room in terms of sensing clicks - the finger may move a few pixels.\n\t\t\t\t\teventData = _getEvent(e);\n\t\t\t\tif (!isDragNotClick && isTrackingDrag) {\n\t\t\t\t\tself._vx.reset();\n\t\t\t\t\tself._vy.reset();\n\t\t\t\t\t//if (preventDefault && allowClicks && self.isPressed) { // check isPressed because in a rare edge case, the inputObserver in ScrollTrigger may stopPropagation() on the press/drag, so the onRelease may get fired without the onPress/onDrag ever getting called, thus it could trigger a click to occur on a link after scroll-dragging it.\n\t\t\t\t\tif (preventDefault && allowClicks) {\n\t\t\t\t\t\tgsap.delayedCall(0.08, () => { // some browsers (like Firefox) won't trust script-generated clicks, so if the user tries to click on a video to play it, for example, it simply won't work. Since a regular \"click\" event will most likely be generated anyway (one that has its isTrusted flag set to true), we must slightly delay our script-generated click so that the \"real\"/trusted one is prioritized. Remember, when there are duplicate events in quick succession, we suppress all but the first one. Some browsers don't even trigger the \"real\" one at all, so our synthetic one is a safety valve that ensures that no matter what, a click event does get dispatched.\n\t\t\t\t\t\t\tif (_getTime() - onClickTime > 300 && !e.defaultPrevented) {\n\t\t\t\t\t\t\t\tif (e.target.click) { //some browsers (like mobile Safari) don't properly trigger the click event\n\t\t\t\t\t\t\t\t\te.target.click();\n\t\t\t\t\t\t\t\t} else if (ownerDoc.createEvent) {\n\t\t\t\t\t\t\t\t\tlet syntheticEvent = ownerDoc.createEvent(\"MouseEvents\");\n\t\t\t\t\t\t\t\t\tsyntheticEvent.initMouseEvent(\"click\", true, true, _win, 1, eventData.screenX, eventData.screenY, eventData.clientX, eventData.clientY, false, false, false, false, 0, null);\n\t\t\t\t\t\t\t\t\te.target.dispatchEvent(syntheticEvent);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tself.isDragging = self.isGesturing = self.isPressed = false;\n\t\t\t\tonStop && wasDragging && !isNormalizer && onStopDelayedCall.restart(true);\n\t\t\t\tdragged && update(); // in case debouncing, we don't want onDrag to fire AFTER onDragEnd().\n\t\t\t\tonDragEnd && wasDragging && onDragEnd(self);\n\t\t\t\tonRelease && onRelease(self, isDragNotClick);\n\t\t\t},\n\t\t\t_onGestureStart = e => e.touches && e.touches.length > 1 && (self.isGesturing = true) && onGestureStart(e, self.isDragging),\n\t\t\t_onGestureEnd = () => (self.isGesturing = false) || onGestureEnd(self),\n\t\t\tonScroll = e => {\n\t\t\t\tif (_ignoreCheck(e)) {return;}\n\t\t\t\tlet x = scrollFuncX(),\n\t\t\t\t\ty = scrollFuncY();\n\t\t\t\tonDelta((x - scrollX) * scrollSpeed, (y - scrollY) * scrollSpeed, 1);\n\t\t\t\tscrollX = x;\n\t\t\t\tscrollY = y;\n\t\t\t\tonStop && onStopDelayedCall.restart(true);\n\t\t\t},\n\t\t\t_onWheel = e => {\n\t\t\t\tif (_ignoreCheck(e)) {return;}\n\t\t\t\te = _getEvent(e, preventDefault);\n\t\t\t\tonWheel && (wheeled = true);\n\t\t\t\tlet multiplier = (e.deltaMode === 1 ? lineHeight : e.deltaMode === 2 ? _win.innerHeight : 1) * wheelSpeed;\n\t\t\t\tonDelta(e.deltaX * multiplier, e.deltaY * multiplier, 0);\n\t\t\t\tonStop && !isNormalizer && onStopDelayedCall.restart(true);\n\t\t\t},\n\t\t\t_onMove = e => {\n\t\t\t\tif (_ignoreCheck(e)) {return;}\n\t\t\t\tlet x = e.clientX,\n\t\t\t\t\ty = e.clientY,\n\t\t\t\t\tdx = x - self.x,\n\t\t\t\t\tdy = y - self.y;\n\t\t\t\tself.x = x;\n\t\t\t\tself.y = y;\n\t\t\t\tmoved = true;\n\t\t\t\tonStop && onStopDelayedCall.restart(true);\n\t\t\t\t(dx || dy) && onTouchOrPointerDelta(dx, dy);\n\t\t\t},\n\t\t\t_onHover = e => {self.event = e; onHover(self);},\n\t\t\t_onHoverEnd = e => {self.event = e; onHoverEnd(self);},\n\t\t\t_onClick = e => _ignoreCheck(e) || (_getEvent(e, preventDefault) && onClick(self));\n\n\t\tonStopDelayedCall = self._dc = gsap.delayedCall(onStopDelay || 0.25, onStopFunc).pause();\n\n\t\tself.deltaX = self.deltaY = 0;\n\t\tself._vx = _getVelocityProp(0, 50, true);\n\t\tself._vy = _getVelocityProp(0, 50, true);\n\t\tself.scrollX = scrollFuncX;\n\t\tself.scrollY = scrollFuncY;\n\t\tself.isDragging = self.isGesturing = self.isPressed = false;\n\t\t_context(this);\n\t\tself.enable = e => {\n\t\t\tif (!self.isEnabled) {\n\t\t\t\t_addListener(isViewport ? ownerDoc : target, \"scroll\", _onScroll);\n\t\t\t\ttype.indexOf(\"scroll\") >= 0 && _addListener(isViewport ? ownerDoc : target, \"scroll\", onScroll, passive, capture);\n\t\t\t\ttype.indexOf(\"wheel\") >= 0 && _addListener(target, \"wheel\", _onWheel, passive, capture);\n\t\t\t\tif ((type.indexOf(\"touch\") >= 0 && _isTouch) || type.indexOf(\"pointer\") >= 0) {\n\t\t\t\t\t_addListener(target, _eventTypes[0], _onPress, passive, capture);\n\t\t\t\t\t_addListener(ownerDoc, _eventTypes[2], _onRelease);\n\t\t\t\t\t_addListener(ownerDoc, _eventTypes[3], _onRelease);\n\t\t\t\t\tallowClicks && _addListener(target, \"click\", clickCapture, true, true);\n\t\t\t\t\tonClick && _addListener(target, \"click\", _onClick);\n\t\t\t\t\tonGestureStart && _addListener(ownerDoc, \"gesturestart\", _onGestureStart);\n\t\t\t\t\tonGestureEnd && _addListener(ownerDoc, \"gestureend\", _onGestureEnd);\n\t\t\t\t\tonHover && _addListener(target, _pointerType + \"enter\", _onHover);\n\t\t\t\t\tonHoverEnd && _addListener(target, _pointerType + \"leave\", _onHoverEnd);\n\t\t\t\t\tonMove && _addListener(target, _pointerType + \"move\", _onMove);\n\t\t\t\t}\n\t\t\t\tself.isEnabled = true;\n\t\t\t\tself.isDragging = self.isGesturing = self.isPressed = moved = dragged = false;\n\t\t\t\tself._vx.reset();\n\t\t\t\tself._vy.reset();\n\t\t\t\tscrollX = scrollFuncX();\n\t\t\t\tscrollY = scrollFuncY();\n\t\t\t\te && e.type && _onPress(e);\n\t\t\t\tonEnable && onEnable(self);\n\t\t\t}\n\t\t\treturn self;\n\t\t};\n\t\tself.disable = () => {\n\t\t\tif (self.isEnabled) {\n\t\t\t\t// only remove the _onScroll listener if there aren't any others that rely on the functionality.\n\t\t\t\t_observers.filter(o => o !== self && _isViewport(o.target)).length || _removeListener(isViewport ? ownerDoc : target, \"scroll\", _onScroll);\n\t\t\t\tif (self.isPressed) {\n\t\t\t\t\tself._vx.reset();\n\t\t\t\t\tself._vy.reset();\n\t\t\t\t\t_removeListener(isNormalizer ? target : ownerDoc, _eventTypes[1], _onDrag, true);\n\t\t\t\t}\n\t\t\t\t_removeListener(isViewport ? ownerDoc : target, \"scroll\", onScroll, capture);\n\t\t\t\t_removeListener(target, \"wheel\", _onWheel, capture);\n\t\t\t\t_removeListener(target, _eventTypes[0], _onPress, capture);\n\t\t\t\t_removeListener(ownerDoc, _eventTypes[2], _onRelease);\n\t\t\t\t_removeListener(ownerDoc, _eventTypes[3], _onRelease);\n\t\t\t\t_removeListener(target, \"click\", clickCapture, true);\n\t\t\t\t_removeListener(target, \"click\", _onClick);\n\t\t\t\t_removeListener(ownerDoc, \"gesturestart\", _onGestureStart);\n\t\t\t\t_removeListener(ownerDoc, \"gestureend\", _onGestureEnd);\n\t\t\t\t_removeListener(target, _pointerType + \"enter\", _onHover);\n\t\t\t\t_removeListener(target, _pointerType + \"leave\", _onHoverEnd);\n\t\t\t\t_removeListener(target, _pointerType + \"move\", _onMove);\n\t\t\t\tself.isEnabled = self.isPressed = self.isDragging = false;\n\t\t\t\tonDisable && onDisable(self);\n\t\t\t}\n\t\t};\n\n\t\tself.kill = self.revert = () => {\n\t\t\tself.disable();\n\t\t\tlet i = _observers.indexOf(self);\n\t\t\ti >= 0 && _observers.splice(i, 1);\n\t\t\t_normalizer === self && (_normalizer = 0);\n\t\t}\n\n\t\t_observers.push(self);\n\t\tisNormalizer && _isViewport(target) && (_normalizer = self);\n\n\t\tself.enable(event);\n\t}\n\n\tget velocityX() {\n\t\treturn this._vx.getVelocity();\n\t}\n\tget velocityY() {\n\t\treturn this._vy.getVelocity();\n\t}\n\n}\n\nObserver.version = \"3.12.7\";\nObserver.create = vars => new Observer(vars);\nObserver.register = _initCore;\nObserver.getAll = () => _observers.slice();\nObserver.getById = id => _observers.filter(o => o.vars.id === id)[0];\n\n_getGSAP() && gsap.registerPlugin(Observer);\n\nexport { Observer as default, _isViewport, _scrollers, _getScrollFunc, _getProxyProp, _proxies, _getVelocityProp, _vertical, _horizontal, _getTarget };","/*!\n * ScrollTrigger 3.12.7\n * https://gsap.com\n *\n * @license Copyright 2008-2025, GreenSock. All rights reserved.\n * Subject to the terms at https://gsap.com/standard-license or for\n * Club GSAP members, the agreement issued with that membership.\n * @author: Jack Doyle, jack@greensock.com\n*/\n/* eslint-disable */\n\nimport { Observer, _getTarget, _vertical, _horizontal, _scrollers, _proxies, _getScrollFunc, _getProxyProp, _getVelocityProp } from \"./Observer.js\";\n\nlet gsap, _coreInitted, _win, _doc, _docEl, _body, _root, _resizeDelay, _toArray, _clamp, _time2, _syncInterval, _refreshing, _pointerIsDown, _transformProp, _i, _prevWidth, _prevHeight, _autoRefresh, _sort, _suppressOverwrites, _ignoreResize, _normalizer, _ignoreMobileResize, _baseScreenHeight, _baseScreenWidth, _fixIOSBug, _context, _scrollRestoration, _div100vh, _100vh, _isReverted, _clampingMax,\n\t_limitCallbacks, // if true, we'll only trigger callbacks if the active state toggles, so if you scroll immediately past both the start and end positions of a ScrollTrigger (thus inactive to inactive), neither its onEnter nor onLeave will be called. This is useful during startup.\n\t_startup = 1,\n\t_getTime = Date.now,\n\t_time1 = _getTime(),\n\t_lastScrollTime = 0,\n\t_enabled = 0,\n\t_parseClamp = (value, type, self) => {\n\t\tlet clamp = (_isString(value) && (value.substr(0, 6) === \"clamp(\" || value.indexOf(\"max\") > -1));\n\t\tself[\"_\" + type + \"Clamp\"] = clamp;\n\t\treturn clamp ? value.substr(6, value.length - 7) : value;\n\t},\n\t_keepClamp = (value, clamp) => clamp && (!_isString(value) || value.substr(0, 6) !== \"clamp(\") ? \"clamp(\" + value + \")\" : value,\n\t_rafBugFix = () => _enabled && requestAnimationFrame(_rafBugFix), // in some browsers (like Firefox), screen repaints weren't consistent unless we had SOMETHING queued up in requestAnimationFrame()! So this just creates a super simple loop to keep it alive and smooth out repaints.\n\t_pointerDownHandler = () => _pointerIsDown = 1,\n\t_pointerUpHandler = () => _pointerIsDown = 0,\n\t_passThrough = v => v,\n\t_round = value => Math.round(value * 100000) / 100000 || 0,\n\t_windowExists = () => typeof(window) !== \"undefined\",\n\t_getGSAP = () => gsap || (_windowExists() && (gsap = window.gsap) && gsap.registerPlugin && gsap),\n\t_isViewport = e => !!~_root.indexOf(e),\n\t_getViewportDimension = dimensionProperty => (dimensionProperty === \"Height\" ? _100vh : _win[\"inner\" + dimensionProperty]) || _docEl[\"client\" + dimensionProperty] || _body[\"client\" + dimensionProperty],\n\t_getBoundsFunc = element => _getProxyProp(element, \"getBoundingClientRect\") || (_isViewport(element) ? () => {_winOffsets.width = _win.innerWidth; _winOffsets.height = _100vh; return _winOffsets;} : () => _getBounds(element)),\n\t_getSizeFunc = (scroller, isViewport, {d, d2, a}) => (a = _getProxyProp(scroller, \"getBoundingClientRect\")) ? () => a()[d] : () => (isViewport ? _getViewportDimension(d2) : scroller[\"client\" + d2]) || 0,\n\t_getOffsetsFunc = (element, isViewport) => !isViewport || ~_proxies.indexOf(element) ? _getBoundsFunc(element) : () => _winOffsets,\n\t_maxScroll = (element, {s, d2, d, a}) => Math.max(0, (s = \"scroll\" + d2) && (a = _getProxyProp(element, s)) ? a() - _getBoundsFunc(element)()[d] : _isViewport(element) ? (_docEl[s] || _body[s]) - _getViewportDimension(d2) : element[s] - element[\"offset\" + d2]),\n\t_iterateAutoRefresh = (func, events) => {\n\t\tfor (let i = 0; i < _autoRefresh.length; i += 3) {\n\t\t\t(!events || ~events.indexOf(_autoRefresh[i+1])) && func(_autoRefresh[i], _autoRefresh[i+1], _autoRefresh[i+2]);\n\t\t}\n\t},\n\t_isString = value => typeof(value) === \"string\",\n\t_isFunction = value => typeof(value) === \"function\",\n\t_isNumber = value => typeof(value) === \"number\",\n\t_isObject = value => typeof(value) === \"object\",\n\t_endAnimation = (animation, reversed, pause) => animation && animation.progress(reversed ? 0 : 1) && pause && animation.pause(),\n\t_callback = (self, func) => {\n\t\tif (self.enabled) {\n\t\t\tlet result = self._ctx ? self._ctx.add(() => func(self)) : func(self);\n\t\t\tresult && result.totalTime && (self.callbackAnimation = result);\n\t\t}\n\t},\n\t_abs = Math.abs,\n\t_left = \"left\",\n\t_top = \"top\",\n\t_right = \"right\",\n\t_bottom = \"bottom\",\n\t_width = \"width\",\n\t_height = \"height\",\n\t_Right = \"Right\",\n\t_Left = \"Left\",\n\t_Top = \"Top\",\n\t_Bottom = \"Bottom\",\n\t_padding = \"padding\",\n\t_margin = \"margin\",\n\t_Width = \"Width\",\n\t_Height = \"Height\",\n\t_px = \"px\",\n\t_getComputedStyle = element => _win.getComputedStyle(element),\n\t_makePositionable = element => { // if the element already has position: absolute or fixed, leave that, otherwise make it position: relative\n\t\tlet position = _getComputedStyle(element).position;\n\t\telement.style.position = (position === \"absolute\" || position === \"fixed\") ? position : \"relative\";\n\t},\n\t_setDefaults = (obj, defaults) => {\n\t\tfor (let p in defaults) {\n\t\t\t(p in obj) || (obj[p] = defaults[p]);\n\t\t}\n\t\treturn obj;\n\t},\n\t_getBounds = (element, withoutTransforms) => {\n\t\tlet tween = withoutTransforms && _getComputedStyle(element)[_transformProp] !== \"matrix(1, 0, 0, 1, 0, 0)\" && gsap.to(element, {x: 0, y: 0, xPercent: 0, yPercent: 0, rotation: 0, rotationX: 0, rotationY: 0, scale: 1, skewX: 0, skewY: 0}).progress(1),\n\t\t\tbounds = element.getBoundingClientRect();\n\t\ttween && tween.progress(0).kill();\n\t\treturn bounds;\n\t},\n\t_getSize = (element, {d2}) => element[\"offset\" + d2] || element[\"client\" + d2] || 0,\n\t_getLabelRatioArray = timeline => {\n\t\tlet a = [],\n\t\t\tlabels = timeline.labels,\n\t\t\tduration = timeline.duration(),\n\t\t\tp;\n\t\tfor (p in labels) {\n\t\t\ta.push(labels[p] / duration);\n\t\t}\n\t\treturn a;\n\t},\n\t_getClosestLabel = animation => value => gsap.utils.snap(_getLabelRatioArray(animation), value),\n\t_snapDirectional = snapIncrementOrArray => {\n\t\tlet snap = gsap.utils.snap(snapIncrementOrArray),\n\t\t\ta = Array.isArray(snapIncrementOrArray) && snapIncrementOrArray.slice(0).sort((a, b) => a - b);\n\t\treturn a ? (value, direction, threshold= 1e-3) => {\n\t\t\tlet i;\n\t\t\tif (!direction) {\n\t\t\t\treturn snap(value);\n\t\t\t}\n\t\t\tif (direction > 0) {\n\t\t\t\tvalue -= threshold; // to avoid rounding errors. If we're too strict, it might snap forward, then immediately again, and again.\n\t\t\t\tfor (i = 0; i < a.length; i++) {\n\t\t\t\t\tif (a[i] >= value) {\n\t\t\t\t\t\treturn a[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn a[i-1];\n\t\t\t} else {\n\t\t\t\ti = a.length;\n\t\t\t\tvalue += threshold;\n\t\t\t\twhile (i--) {\n\t\t\t\t\tif (a[i] <= value) {\n\t\t\t\t\t\treturn a[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn a[0];\n\t\t} : (value, direction, threshold= 1e-3) => {\n\t\t\tlet snapped = snap(value);\n\t\t\treturn !direction || Math.abs(snapped - value) < threshold || ((snapped - value < 0) === direction < 0) ? snapped : snap(direction < 0 ? value - snapIncrementOrArray : value + snapIncrementOrArray);\n\t\t};\n\t},\n\t_getLabelAtDirection = timeline => (value, st) => _snapDirectional(_getLabelRatioArray(timeline))(value, st.direction),\n\t_multiListener = (func, element, types, callback) => types.split(\",\").forEach(type => func(element, type, callback)),\n\t_addListener = (element, type, func, nonPassive, capture) => element.addEventListener(type, func, {passive: !nonPassive, capture: !!capture}),\n\t_removeListener = (element, type, func, capture) => element.removeEventListener(type, func, !!capture),\n\t_wheelListener = (func, el, scrollFunc) => {\n\t\tscrollFunc = scrollFunc && scrollFunc.wheelHandler\n\t\tif (scrollFunc) {\n\t\t\tfunc(el, \"wheel\", scrollFunc);\n\t\t\tfunc(el, \"touchmove\", scrollFunc);\n\t\t}\n\t},\n\t_markerDefaults = {startColor: \"green\", endColor: \"red\", indent: 0, fontSize: \"16px\", fontWeight:\"normal\"},\n\t_defaults = {toggleActions: \"play\", anticipatePin: 0},\n\t_keywords = {top: 0, left: 0, center: 0.5, bottom: 1, right: 1},\n\t_offsetToPx = (value, size) => {\n\t\tif (_isString(value)) {\n\t\t\tlet eqIndex = value.indexOf(\"=\"),\n\t\t\t\trelative = ~eqIndex ? +(value.charAt(eqIndex-1) + 1) * parseFloat(value.substr(eqIndex + 1)) : 0;\n\t\t\tif (~eqIndex) {\n\t\t\t\t(value.indexOf(\"%\") > eqIndex) && (relative *= size / 100);\n\t\t\t\tvalue = value.substr(0, eqIndex-1);\n\t\t\t}\n\t\t\tvalue = relative + ((value in _keywords) ? _keywords[value] * size : ~value.indexOf(\"%\") ? parseFloat(value) * size / 100 : parseFloat(value) || 0);\n\t\t}\n\t\treturn value;\n\t},\n\t_createMarker = (type, name, container, direction, {startColor, endColor, fontSize, indent, fontWeight}, offset, matchWidthEl, containerAnimation) => {\n\t\tlet e = _doc.createElement(\"div\"),\n\t\t\tuseFixedPosition = _isViewport(container) || _getProxyProp(container, \"pinType\") === \"fixed\",\n\t\t\tisScroller = type.indexOf(\"scroller\") !== -1,\n\t\t\tparent = useFixedPosition ? _body : container,\n\t\t\tisStart = type.indexOf(\"start\") !== -1,\n\t\t\tcolor = isStart ? startColor : endColor,\n\t\t\tcss = \"border-color:\" + color + \";font-size:\" + fontSize + \";color:\" + color + \";font-weight:\" + fontWeight + \";pointer-events:none;white-space:nowrap;font-family:sans-serif,Arial;z-index:1000;padding:4px 8px;border-width:0;border-style:solid;\";\n\t\tcss += \"position:\" + ((isScroller || containerAnimation) && useFixedPosition ? \"fixed;\" : \"absolute;\");\n\t\t(isScroller || containerAnimation || !useFixedPosition) && (css += (direction === _vertical ? _right : _bottom) + \":\" + (offset + parseFloat(indent)) + \"px;\");\n\t\tmatchWidthEl && (css += \"box-sizing:border-box;text-align:left;width:\" + matchWidthEl.offsetWidth + \"px;\");\n\t\te._isStart = isStart;\n\t\te.setAttribute(\"class\", \"gsap-marker-\" + type + (name ? \" marker-\" + name : \"\"));\n\t\te.style.cssText = css;\n\t\te.innerText = name || name === 0 ? type + \"-\" + name : type;\n\t\tparent.children[0] ? parent.insertBefore(e, parent.children[0]) : parent.appendChild(e);\n\t\te._offset = e[\"offset\" + direction.op.d2];\n\t\t_positionMarker(e, 0, direction, isStart);\n\t\treturn e;\n\t},\n\t_positionMarker = (marker, start, direction, flipped) => {\n\t\tlet vars = {display: \"block\"},\n\t\t\tside = direction[flipped ? \"os2\" : \"p2\"],\n\t\t\toppositeSide = direction[flipped ? \"p2\" : \"os2\"];\n\t\tmarker._isFlipped = flipped;\n\t\tvars[direction.a + \"Percent\"] = flipped ? -100 : 0;\n\t\tvars[direction.a] = flipped ? \"1px\" : 0;\n\t\tvars[\"border\" + side + _Width] = 1;\n\t\tvars[\"border\" + oppositeSide + _Width] = 0;\n\t\tvars[direction.p] = start + \"px\";\n\t\tgsap.set(marker, vars);\n\t},\n\t_triggers = [],\n\t_ids = {},\n\t_rafID,\n\t_sync = () => _getTime() - _lastScrollTime > 34 && (_rafID || (_rafID = requestAnimationFrame(_updateAll))),\n\t_onScroll = () => { // previously, we tried to optimize performance by batching/deferring to the next requestAnimationFrame(), but discovered that Safari has a few bugs that make this unworkable (especially on iOS). See https://codepen.io/GreenSock/pen/16c435b12ef09c38125204818e7b45fc?editors=0010 and https://codepen.io/GreenSock/pen/JjOxYpQ/3dd65ccec5a60f1d862c355d84d14562?editors=0010 and https://codepen.io/GreenSock/pen/ExbrPNa/087cef197dc35445a0951e8935c41503?editors=0010\n\t\tif (!_normalizer || !_normalizer.isPressed || _normalizer.startX > _body.clientWidth) { // if the user is dragging the scrollbar, allow it.\n\t\t\t_scrollers.cache++;\n\t\t\tif (_normalizer) {\n\t\t\t\t_rafID || (_rafID = requestAnimationFrame(_updateAll));\n\t\t\t} else {\n\t\t\t\t_updateAll(); // Safari in particular (on desktop) NEEDS the immediate update rather than waiting for a requestAnimationFrame() whereas iOS seems to benefit from waiting for the requestAnimationFrame() tick, at least when normalizing. See https://codepen.io/GreenSock/pen/qBYozqO?editors=0110\n\t\t\t}\n\t\t\t_lastScrollTime || _dispatch(\"scrollStart\");\n\t\t\t_lastScrollTime = _getTime();\n\t\t}\n\t},\n\t_setBaseDimensions = () => {\n\t\t_baseScreenWidth = _win.innerWidth;\n\t\t_baseScreenHeight = _win.innerHeight;\n\t},\n\t_onResize = (force) => {\n\t\t_scrollers.cache++;\n\t\t(force === true || (!_refreshing && !_ignoreResize && !_doc.fullscreenElement && !_doc.webkitFullscreenElement && (!_ignoreMobileResize || _baseScreenWidth !== _win.innerWidth || Math.abs(_win.innerHeight - _baseScreenHeight) > _win.innerHeight * 0.25))) && _resizeDelay.restart(true);\n\t}, // ignore resizes triggered by refresh()\n\t_listeners = {},\n\t_emptyArray = [],\n\t_softRefresh = () => _removeListener(ScrollTrigger, \"scrollEnd\", _softRefresh) || _refreshAll(true),\n\t_dispatch = type => (_listeners[type] && _listeners[type].map(f => f())) || _emptyArray,\n\t_savedStyles = [], // when ScrollTrigger.saveStyles() is called, the inline styles are recorded in this Array in a sequential format like [element, cssText, gsCache, media]. This keeps it very memory-efficient and fast to iterate through.\n\t_revertRecorded = media => {\n\t\tfor (let i = 0; i < _savedStyles.length; i+=5) {\n\t\t\tif (!media || _savedStyles[i+4] && _savedStyles[i+4].query === media) {\n\t\t\t\t_savedStyles[i].style.cssText = _savedStyles[i+1];\n\t\t\t\t_savedStyles[i].getBBox && _savedStyles[i].setAttribute(\"transform\", _savedStyles[i+2] || \"\");\n\t\t\t\t_savedStyles[i+3].uncache = 1;\n\t\t\t}\n\t\t}\n\t},\n\t_revertAll = (kill, media) => {\n\t\tlet trigger;\n\t\tfor (_i = 0; _i < _triggers.length; _i++) {\n\t\t\ttrigger = _triggers[_i];\n\t\t\tif (trigger && (!media || trigger._ctx === media)) {\n\t\t\t\tif (kill) {\n\t\t\t\t\ttrigger.kill(1);\n\t\t\t\t} else {\n\t\t\t\t\ttrigger.revert(true, true);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t_isReverted = true;\n\t\tmedia && _revertRecorded(media);\n\t\tmedia || _dispatch(\"revert\");\n\t},\n\t_clearScrollMemory = (scrollRestoration, force) => { // zero-out all the recorded scroll positions. Don't use _triggers because if, for example, .matchMedia() is used to create some ScrollTriggers and then the user resizes and it removes ALL ScrollTriggers, and then go back to a size where there are ScrollTriggers, it would have kept the position(s) saved from the initial state.\n\t\t_scrollers.cache++;\n\t\t(force || !_refreshingAll) && _scrollers.forEach(obj => _isFunction(obj) && obj.cacheID++ && (obj.rec = 0));\n\t\t_isString(scrollRestoration) && (_win.history.scrollRestoration = _scrollRestoration = scrollRestoration);\n\t},\n\t_refreshingAll,\n\t_refreshID = 0,\n\t_queueRefreshID,\n\t_queueRefreshAll = () => { // we don't want to call _refreshAll() every time we create a new ScrollTrigger (for performance reasons) - it's better to batch them. Some frameworks dynamically load content and we can't rely on the window's \"load\" or \"DOMContentLoaded\" events to trigger it.\n\t\tif (_queueRefreshID !== _refreshID) {\n\t\t\tlet id = _queueRefreshID = _refreshID;\n\t\t\trequestAnimationFrame(() => id === _refreshID && _refreshAll(true));\n\t\t}\n\t},\n\t_refresh100vh = () => {\n\t\t_body.appendChild(_div100vh);\n\t\t_100vh = (!_normalizer && _div100vh.offsetHeight) || _win.innerHeight;\n\t\t_body.removeChild(_div100vh);\n\t},\n\t_hideAllMarkers = hide => _toArray(\".gsap-marker-start, .gsap-marker-end, .gsap-marker-scroller-start, .gsap-marker-scroller-end\").forEach(el => el.style.display = hide ? \"none\" : \"block\"),\n\t_refreshAll = (force, skipRevert) => {\n\t\t_docEl = _doc.documentElement; // some frameworks like Astro may cache the and replace it during routing, so we'll just re-record the _docEl and _body for safety (otherwise, the markers may not get added properly).\n\t\t_body = _doc.body;\n\t\t_root = [_win, _doc, _docEl, _body];\n\t\tif (_lastScrollTime && !force && !_isReverted) {\n\t\t\t_addListener(ScrollTrigger, \"scrollEnd\", _softRefresh);\n\t\t\treturn;\n\t\t}\n\t\t_refresh100vh();\n\t\t_refreshingAll = ScrollTrigger.isRefreshing = true;\n\t\t_scrollers.forEach(obj => _isFunction(obj) && ++obj.cacheID && (obj.rec = obj())); // force the clearing of the cache because some browsers take a little while to dispatch the \"scroll\" event and the user may have changed the scroll position and then called ScrollTrigger.refresh() right away\n\t\tlet refreshInits = _dispatch(\"refreshInit\");\n\t\t_sort && ScrollTrigger.sort();\n\t\tskipRevert || _revertAll();\n\t\t_scrollers.forEach(obj => {\n\t\t\tif (_isFunction(obj)) {\n\t\t\t\tobj.smooth && (obj.target.style.scrollBehavior = \"auto\"); // smooth scrolling interferes\n\t\t\t\tobj(0);\n\t\t\t}\n\t\t});\n\t\t_triggers.slice(0).forEach(t => t.refresh()) // don't loop with _i because during a refresh() someone could call ScrollTrigger.update() which would iterate through _i resulting in a skip.\n\t\t_isReverted = false;\n\t\t_triggers.forEach((t) => { // nested pins (pinnedContainer) with pinSpacing may expand the container, so we must accommodate that here.\n\t\t\tif (t._subPinOffset && t.pin) {\n\t\t\t\tlet prop = t.vars.horizontal ? \"offsetWidth\" : \"offsetHeight\",\n\t\t\t\t\toriginal = t.pin[prop];\n\t\t\t\tt.revert(true, 1);\n\t\t\t\tt.adjustPinSpacing(t.pin[prop] - original);\n\t\t\t\tt.refresh();\n\t\t\t}\n\t\t});\n\t\t_clampingMax = 1; // pinSpacing might be propping a page open, thus when we .setPositions() to clamp a ScrollTrigger's end we should leave the pinSpacing alone. That's what this flag is for.\n\t\t_hideAllMarkers(true);\n\t\t_triggers.forEach(t => { // the scroller's max scroll position may change after all the ScrollTriggers refreshed (like pinning could push it down), so we need to loop back and correct any with end: \"max\". Same for anything with a clamped end\n\t\t\tlet max = _maxScroll(t.scroller, t._dir),\n\t\t\t\tendClamp = t.vars.end === \"max\" || (t._endClamp && t.end > max),\n\t\t\t\tstartClamp = t._startClamp && t.start >= max;\n\t\t\t(endClamp || startClamp) && t.setPositions(startClamp ? max - 1 : t.start, endClamp ? Math.max(startClamp ? max : t.start + 1, max) : t.end, true);\n\t\t});\n\t\t_hideAllMarkers(false);\n\t\t_clampingMax = 0;\n\t\trefreshInits.forEach(result => result && result.render && result.render(-1)); // if the onRefreshInit() returns an animation (typically a gsap.set()), revert it. This makes it easy to put things in a certain spot before refreshing for measurement purposes, and then put things back.\n\t\t_scrollers.forEach(obj => {\n\t\t\tif (_isFunction(obj)) {\n\t\t\t\tobj.smooth && requestAnimationFrame(() => obj.target.style.scrollBehavior = \"smooth\");\n\t\t\t\tobj.rec && obj(obj.rec);\n\t\t\t}\n\t\t});\n\t\t_clearScrollMemory(_scrollRestoration, 1);\n\t\t_resizeDelay.pause();\n\t\t_refreshID++;\n\t\t_refreshingAll = 2;\n\t\t_updateAll(2);\n\t\t_triggers.forEach(t => _isFunction(t.vars.onRefresh) && t.vars.onRefresh(t));\n\t\t_refreshingAll = ScrollTrigger.isRefreshing = false;\n\t\t_dispatch(\"refresh\");\n\t},\n\t_lastScroll = 0,\n\t_direction = 1,\n\t_primary,\n\t_updateAll = (force) => {\n\t\tif (force === 2 || (!_refreshingAll && !_isReverted)) { // _isReverted could be true if, for example, a matchMedia() is in the process of executing. We don't want to update during the time everything is reverted.\n\t\t\tScrollTrigger.isUpdating = true;\n\t\t\t_primary && _primary.update(0); // ScrollSmoother uses refreshPriority -9999 to become the primary that gets updated before all others because it affects the scroll position.\n\t\t\tlet l = _triggers.length,\n\t\t\t\ttime = _getTime(),\n\t\t\t\trecordVelocity = time - _time1 >= 50,\n\t\t\t\tscroll = l && _triggers[0].scroll();\n\t\t\t_direction = _lastScroll > scroll ? -1 : 1;\n\t\t\t_refreshingAll || (_lastScroll = scroll);\n\t\t\tif (recordVelocity) {\n\t\t\t\tif (_lastScrollTime && !_pointerIsDown && time - _lastScrollTime > 200) {\n\t\t\t\t\t_lastScrollTime = 0;\n\t\t\t\t\t_dispatch(\"scrollEnd\");\n\t\t\t\t}\n\t\t\t\t_time2 = _time1;\n\t\t\t\t_time1 = time;\n\t\t\t}\n\t\t\tif (_direction < 0) {\n\t\t\t\t_i = l;\n\t\t\t\twhile (_i-- > 0) {\n\t\t\t\t\t_triggers[_i] && _triggers[_i].update(0, recordVelocity);\n\t\t\t\t}\n\t\t\t\t_direction = 1;\n\t\t\t} else {\n\t\t\t\tfor (_i = 0; _i < l; _i++) {\n\t\t\t\t\t_triggers[_i] && _triggers[_i].update(0, recordVelocity);\n\t\t\t\t}\n\t\t\t}\n\t\t\tScrollTrigger.isUpdating = false;\n\t\t}\n\t\t_rafID = 0;\n\t},\n\t_propNamesToCopy = [_left, _top, _bottom, _right, _margin + _Bottom, _margin + _Right, _margin + _Top, _margin + _Left, \"display\", \"flexShrink\", \"float\", \"zIndex\", \"gridColumnStart\", \"gridColumnEnd\", \"gridRowStart\", \"gridRowEnd\", \"gridArea\", \"justifySelf\", \"alignSelf\", \"placeSelf\", \"order\"],\n\t_stateProps = _propNamesToCopy.concat([_width, _height, \"boxSizing\", \"max\" + _Width, \"max\" + _Height, \"position\", _margin, _padding, _padding + _Top, _padding + _Right, _padding + _Bottom, _padding + _Left]),\n\t_swapPinOut = (pin, spacer, state) => {\n\t\t_setState(state);\n\t\tlet cache = pin._gsap;\n\t\tif (cache.spacerIsNative) {\n\t\t\t_setState(cache.spacerState);\n\t\t} else if (pin._gsap.swappedIn) {\n\t\t\tlet parent = spacer.parentNode;\n\t\t\tif (parent) {\n\t\t\t\tparent.insertBefore(pin, spacer);\n\t\t\t\tparent.removeChild(spacer);\n\t\t\t}\n\t\t}\n\t\tpin._gsap.swappedIn = false;\n\t},\n\t_swapPinIn = (pin, spacer, cs, spacerState) => {\n\t\tif (!pin._gsap.swappedIn) {\n\t\t\tlet i = _propNamesToCopy.length,\n\t\t\t\tspacerStyle = spacer.style,\n\t\t\t\tpinStyle = pin.style,\n\t\t\t\tp;\n\t\t\twhile (i--) {\n\t\t\t\tp = _propNamesToCopy[i];\n\t\t\t\tspacerStyle[p] = cs[p];\n\t\t\t}\n\t\t\tspacerStyle.position = cs.position === \"absolute\" ? \"absolute\" : \"relative\";\n\t\t\t(cs.display === \"inline\") && (spacerStyle.display = \"inline-block\");\n\t\t\tpinStyle[_bottom] = pinStyle[_right] = \"auto\";\n\t\t\tspacerStyle.flexBasis = cs.flexBasis || \"auto\";\n\t\t\tspacerStyle.overflow = \"visible\";\n\t\t\tspacerStyle.boxSizing = \"border-box\";\n\t\t\tspacerStyle[_width] = _getSize(pin, _horizontal) + _px;\n\t\t\tspacerStyle[_height] = _getSize(pin, _vertical) + _px;\n\t\t\tspacerStyle[_padding] = pinStyle[_margin] = pinStyle[_top] = pinStyle[_left] = \"0\";\n\t\t\t_setState(spacerState);\n\t\t\tpinStyle[_width] = pinStyle[\"max\" + _Width] = cs[_width];\n\t\t\tpinStyle[_height] = pinStyle[\"max\" + _Height] = cs[_height];\n\t\t\tpinStyle[_padding] = cs[_padding];\n\t\t\tif (pin.parentNode !== spacer) {\n\t\t\t\tpin.parentNode.insertBefore(spacer, pin);\n\t\t\t\tspacer.appendChild(pin);\n\t\t\t}\n\t\t\tpin._gsap.swappedIn = true;\n\t\t}\n\t},\n\t_capsExp = /([A-Z])/g,\n\t_setState = state => {\n\t\tif (state) {\n\t\t\tlet style = state.t.style,\n\t\t\t\tl = state.length,\n\t\t\t\ti = 0,\n\t\t\t\tp, value;\n\t\t\t(state.t._gsap || gsap.core.getCache(state.t)).uncache = 1; // otherwise transforms may be off\n\t\t\tfor (; i < l; i +=2) {\n\t\t\t\tvalue = state[i+1];\n\t\t\t\tp = state[i];\n\t\t\t\tif (value) {\n\t\t\t\t\tstyle[p] = value;\n\t\t\t\t} else if (style[p]) {\n\t\t\t\t\tstyle.removeProperty(p.replace(_capsExp, \"-$1\").toLowerCase());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\t_getState = element => { // returns an Array with alternating values like [property, value, property, value] and a \"t\" property pointing to the target (element). Makes it fast and cheap.\n\t\tlet l = _stateProps.length,\n\t\t\tstyle = element.style,\n\t\t\tstate = [],\n\t\t\ti = 0;\n\t\tfor (; i < l; i++) {\n\t\t\tstate.push(_stateProps[i], style[_stateProps[i]]);\n\t\t}\n\t\tstate.t = element;\n\t\treturn state;\n\t},\n\t_copyState = (state, override, omitOffsets) => {\n\t\tlet result = [],\n\t\t\tl = state.length,\n\t\t\ti = omitOffsets ? 8 : 0, // skip top, left, right, bottom if omitOffsets is true\n\t\t\tp;\n\t\tfor (; i < l; i += 2) {\n\t\t\tp = state[i];\n\t\t\tresult.push(p, (p in override) ? override[p] : state[i+1]);\n\t\t}\n\t\tresult.t = state.t;\n\t\treturn result;\n\t},\n\t_winOffsets = {left:0, top:0},\n\t// // potential future feature (?) Allow users to calculate where a trigger hits (scroll position) like getScrollPosition(\"#id\", \"top bottom\")\n\t// _getScrollPosition = (trigger, position, {scroller, containerAnimation, horizontal}) => {\n\t// \tscroller = _getTarget(scroller || _win);\n\t// \tlet direction = horizontal ? _horizontal : _vertical,\n\t// \t\tisViewport = _isViewport(scroller);\n\t// \t_getSizeFunc(scroller, isViewport, direction);\n\t// \treturn _parsePosition(position, _getTarget(trigger), _getSizeFunc(scroller, isViewport, direction)(), direction, _getScrollFunc(scroller, direction)(), 0, 0, 0, _getOffsetsFunc(scroller, isViewport)(), isViewport ? 0 : parseFloat(_getComputedStyle(scroller)[\"border\" + direction.p2 + _Width]) || 0, 0, containerAnimation ? containerAnimation.duration() : _maxScroll(scroller), containerAnimation);\n\t// },\n\t_parsePosition = (value, trigger, scrollerSize, direction, scroll, marker, markerScroller, self, scrollerBounds, borderWidth, useFixedPosition, scrollerMax, containerAnimation, clampZeroProp) => {\n\t\t_isFunction(value) && (value = value(self));\n\t\tif (_isString(value) && value.substr(0,3) === \"max\") {\n\t\t\tvalue = scrollerMax + (value.charAt(4) === \"=\" ? _offsetToPx(\"0\" + value.substr(3), scrollerSize) : 0);\n\t\t}\n\t\tlet time = containerAnimation ? containerAnimation.time() : 0,\n\t\t\tp1, p2, element;\n\t\tcontainerAnimation && containerAnimation.seek(0);\n\t\tisNaN(value) || (value = +value); // convert a string number like \"45\" to an actual number\n\t\tif (!_isNumber(value)) {\n\t\t\t_isFunction(trigger) && (trigger = trigger(self));\n\t\t\tlet offsets = (value || \"0\").split(\" \"),\n\t\t\t\tbounds, localOffset, globalOffset, display;\n\t\t\telement = _getTarget(trigger, self) || _body;\n\t\t\tbounds = _getBounds(element) || {};\n\t\t\tif ((!bounds || (!bounds.left && !bounds.top)) && _getComputedStyle(element).display === \"none\") { // if display is \"none\", it won't report getBoundingClientRect() properly\n\t\t\t\tdisplay = element.style.display;\n\t\t\t\telement.style.display = \"block\";\n\t\t\t\tbounds = _getBounds(element);\n\t\t\t\tdisplay ? (element.style.display = display) : element.style.removeProperty(\"display\");\n\t\t\t}\n\t\t\tlocalOffset = _offsetToPx(offsets[0], bounds[direction.d]);\n\t\t\tglobalOffset = _offsetToPx(offsets[1] || \"0\", scrollerSize);\n\t\t\tvalue = bounds[direction.p] - scrollerBounds[direction.p] - borderWidth + localOffset + scroll - globalOffset;\n\t\t\tmarkerScroller && _positionMarker(markerScroller, globalOffset, direction, (scrollerSize - globalOffset < 20 || (markerScroller._isStart && globalOffset > 20)));\n\t\t\tscrollerSize -= scrollerSize - globalOffset; // adjust for the marker\n\t\t} else {\n\t\t\tcontainerAnimation && (value = gsap.utils.mapRange(containerAnimation.scrollTrigger.start, containerAnimation.scrollTrigger.end, 0, scrollerMax, value));\n\t\t\tmarkerScroller && _positionMarker(markerScroller, scrollerSize, direction, true);\n\t\t}\n\t\tif (clampZeroProp) {\n\t\t\tself[clampZeroProp] = value || -0.001;\n\t\t\tvalue < 0 && (value = 0);\n\t\t}\n\t\tif (marker) {\n\t\t\tlet position = value + scrollerSize,\n\t\t\t\tisStart = marker._isStart;\n\t\t\tp1 = \"scroll\" + direction.d2;\n\t\t\t_positionMarker(marker, position, direction, (isStart && position > 20) || (!isStart && (useFixedPosition ? Math.max(_body[p1], _docEl[p1]) : marker.parentNode[p1]) <= position + 1));\n\t\t\tif (useFixedPosition) {\n\t\t\t\tscrollerBounds = _getBounds(markerScroller);\n\t\t\t\tuseFixedPosition && (marker.style[direction.op.p] = (scrollerBounds[direction.op.p] - direction.op.m - marker._offset) + _px);\n\t\t\t}\n\t\t}\n\t\tif (containerAnimation && element) {\n\t\t\tp1 = _getBounds(element);\n\t\t\tcontainerAnimation.seek(scrollerMax);\n\t\t\tp2 = _getBounds(element);\n\t\t\tcontainerAnimation._caScrollDist = p1[direction.p] - p2[direction.p];\n\t\t\tvalue = value / (containerAnimation._caScrollDist) * scrollerMax;\n\t\t}\n\t\tcontainerAnimation && containerAnimation.seek(time);\n\t\treturn containerAnimation ? value : Math.round(value);\n\t},\n\t_prefixExp = /(webkit|moz|length|cssText|inset)/i,\n\t_reparent = (element, parent, top, left) => {\n\t\tif (element.parentNode !== parent) {\n\t\t\tlet style = element.style,\n\t\t\t\tp, cs;\n\t\t\tif (parent === _body) {\n\t\t\t\telement._stOrig = style.cssText; // record original inline styles so we can revert them later\n\t\t\t\tcs = _getComputedStyle(element);\n\t\t\t\tfor (p in cs) { // must copy all relevant styles to ensure that nothing changes visually when we reparent to the . Skip the vendor prefixed ones.\n\t\t\t\t\tif (!+p && !_prefixExp.test(p) && cs[p] && typeof style[p] === \"string\" && p !== \"0\") {\n\t\t\t\t\t\tstyle[p] = cs[p];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tstyle.top = top;\n\t\t\t\tstyle.left = left;\n\t\t\t} else {\n\t\t\t\tstyle.cssText = element._stOrig;\n\t\t\t}\n\t\t\tgsap.core.getCache(element).uncache = 1;\n\t\t\tparent.appendChild(element);\n\t\t}\n\t},\n\t_interruptionTracker = (getValueFunc, initialValue, onInterrupt) => {\n\t\tlet last1 = initialValue,\n\t\t\tlast2 = last1;\n\t\treturn value => {\n\t\t\tlet current = Math.round(getValueFunc()); // round because in some [very uncommon] Windows environments, scroll can get reported with decimals even though it was set without.\n\t\t\tif (current !== last1 && current !== last2 && Math.abs(current - last1) > 3 && Math.abs(current - last2) > 3) { // if the user scrolls, kill the tween. iOS Safari intermittently misreports the scroll position, it may be the most recently-set one or the one before that! When Safari is zoomed (CMD-+), it often misreports as 1 pixel off too! So if we set the scroll position to 125, for example, it'll actually report it as 124.\n\t\t\t\tvalue = current;\n\t\t\t\tonInterrupt && onInterrupt();\n\t\t\t}\n\t\t\tlast2 = last1;\n\t\t\tlast1 = Math.round(value);\n\t\t\treturn last1;\n\t\t};\n\t},\n\t_shiftMarker = (marker, direction, value) => {\n\t\tlet vars = {};\n\t\tvars[direction.p] = \"+=\" + value;\n\t\tgsap.set(marker, vars);\n\t},\n\t// _mergeAnimations = animations => {\n\t// \tlet tl = gsap.timeline({smoothChildTiming: true}).startTime(Math.min(...animations.map(a => a.globalTime(0))));\n\t// \tanimations.forEach(a => {let time = a.totalTime(); tl.add(a); a.totalTime(time); });\n\t// \ttl.smoothChildTiming = false;\n\t// \treturn tl;\n\t// },\n\n\t// returns a function that can be used to tween the scroll position in the direction provided, and when doing so it'll add a .tween property to the FUNCTION itself, and remove it when the tween completes or gets killed. This gives us a way to have multiple ScrollTriggers use a central function for any given scroller and see if there's a scroll tween running (which would affect if/how things get updated)\n\t_getTweenCreator = (scroller, direction) => {\n\t\tlet getScroll = _getScrollFunc(scroller, direction),\n\t\t\tprop = \"_scroll\" + direction.p2, // add a tweenable property to the scroller that's a getter/setter function, like _scrollTop or _scrollLeft. This way, if someone does gsap.killTweensOf(scroller) it'll kill the scroll tween.\n\t\t\tgetTween = (scrollTo, vars, initialValue, change1, change2) => {\n\t\t\t\tlet tween = getTween.tween,\n\t\t\t\t\tonComplete = vars.onComplete,\n\t\t\t\t\tmodifiers = {};\n\t\t\t\tinitialValue = initialValue || getScroll();\n\t\t\t\tlet checkForInterruption = _interruptionTracker(getScroll, initialValue, () => {\n\t\t\t\t\ttween.kill();\n\t\t\t\t\tgetTween.tween = 0;\n\t\t\t\t});\n\t\t\t\tchange2 = (change1 && change2) || 0; // if change1 is 0, we set that to the difference and ignore change2. Otherwise, there would be a compound effect.\n\t\t\t\tchange1 = change1 || (scrollTo - initialValue);\n\t\t\t\ttween && tween.kill();\n\t\t\t\tvars[prop] = scrollTo;\n\t\t\t\tvars.inherit = false;\n\t\t\t\tvars.modifiers = modifiers;\n\t\t\t\tmodifiers[prop] = () => checkForInterruption(initialValue + change1 * tween.ratio + change2 * tween.ratio * tween.ratio);\n\t\t\t\tvars.onUpdate = () => {\n\t\t\t\t\t_scrollers.cache++;\n\t\t\t\t\tgetTween.tween && _updateAll(); // if it was interrupted/killed, like in a context.revert(), don't force an updateAll()\n\t\t\t\t};\n\t\t\t\tvars.onComplete = () => {\n\t\t\t\t\tgetTween.tween = 0;\n\t\t\t\t\tonComplete && onComplete.call(tween);\n\t\t\t\t};\n\t\t\t\ttween = getTween.tween = gsap.to(scroller, vars);\n\t\t\t\treturn tween;\n\t\t\t};\n\t\tscroller[prop] = getScroll;\n\t\tgetScroll.wheelHandler = () => getTween.tween && getTween.tween.kill() && (getTween.tween = 0);\n\t\t_addListener(scroller, \"wheel\", getScroll.wheelHandler); // Windows machines handle mousewheel scrolling in chunks (like \"3 lines per scroll\") meaning the typical strategy for cancelling the scroll isn't as sensitive. It's much more likely to match one of the previous 2 scroll event positions. So we kill any snapping as soon as there's a wheel event.\n\t\tScrollTrigger.isTouch && _addListener(scroller, \"touchmove\", getScroll.wheelHandler);\n\t\treturn getTween;\n\t};\n\n\n\n\nexport class ScrollTrigger {\n\n\tconstructor(vars, animation) {\n\t\t_coreInitted || ScrollTrigger.register(gsap) || console.warn(\"Please gsap.registerPlugin(ScrollTrigger)\");\n\t\t_context(this);\n\t\tthis.init(vars, animation);\n\t}\n\n\tinit(vars, animation) {\n\t\tthis.progress = this.start = 0;\n\t\tthis.vars && this.kill(true, true); // in case it's being initted again\n\t\tif (!_enabled) {\n\t\t\tthis.update = this.refresh = this.kill = _passThrough;\n\t\t\treturn;\n\t\t}\n\t\tvars = _setDefaults((_isString(vars) || _isNumber(vars) || vars.nodeType) ? {trigger: vars} : vars, _defaults);\n\t\tlet {onUpdate, toggleClass, id, onToggle, onRefresh, scrub, trigger, pin, pinSpacing, invalidateOnRefresh, anticipatePin, onScrubComplete, onSnapComplete, once, snap, pinReparent, pinSpacer, containerAnimation, fastScrollEnd, preventOverlaps} = vars,\n\t\t\tdirection = vars.horizontal || (vars.containerAnimation && vars.horizontal !== false) ? _horizontal : _vertical,\n\t\t\tisToggle = !scrub && scrub !== 0,\n\t\t\tscroller = _getTarget(vars.scroller || _win),\n\t\t\tscrollerCache = gsap.core.getCache(scroller),\n\t\t\tisViewport = _isViewport(scroller),\n\t\t\tuseFixedPosition = (\"pinType\" in vars ? vars.pinType : _getProxyProp(scroller, \"pinType\") || (isViewport && \"fixed\")) === \"fixed\",\n\t\t\tcallbacks = [vars.onEnter, vars.onLeave, vars.onEnterBack, vars.onLeaveBack],\n\t\t\ttoggleActions = isToggle && vars.toggleActions.split(\" \"),\n\t\t\tmarkers = \"markers\" in vars ? vars.markers : _defaults.markers,\n\t\t\tborderWidth = isViewport ? 0 : parseFloat(_getComputedStyle(scroller)[\"border\" + direction.p2 + _Width]) || 0,\n\t\t\tself = this,\n\t\t\tonRefreshInit = vars.onRefreshInit && (() => vars.onRefreshInit(self)),\n\t\t\tgetScrollerSize = _getSizeFunc(scroller, isViewport, direction),\n\t\t\tgetScrollerOffsets = _getOffsetsFunc(scroller, isViewport),\n\t\t\tlastSnap = 0,\n\t\t\tlastRefresh = 0,\n\t\t\tprevProgress = 0,\n\t\t\tscrollFunc = _getScrollFunc(scroller, direction),\n\t\t\ttweenTo, pinCache, snapFunc, scroll1, scroll2, start, end, markerStart, markerEnd, markerStartTrigger, markerEndTrigger, markerVars, executingOnRefresh,\n\t\t\tchange, pinOriginalState, pinActiveState, pinState, spacer, offset, pinGetter, pinSetter, pinStart, pinChange, spacingStart, spacerState, markerStartSetter, pinMoves,\n\t\t\tmarkerEndSetter, cs, snap1, snap2, scrubTween, scrubSmooth, snapDurClamp, snapDelayedCall, prevScroll, prevAnimProgress, caMarkerSetter, customRevertReturn;\n\n\t\t// for the sake of efficiency, _startClamp/_endClamp serve like a truthy value indicating that clamping was enabled on the start/end, and ALSO store the actual pre-clamped numeric value. We tap into that in ScrollSmoother for speed effects. So for example, if start=\"clamp(top bottom)\" results in a start of -100 naturally, it would get clamped to 0 but -100 would be stored in _startClamp.\n\t\tself._startClamp = self._endClamp = false;\n\t\tself._dir = direction;\n\t\tanticipatePin *= 45;\n\t\tself.scroller = scroller;\n\t\tself.scroll = containerAnimation ? containerAnimation.time.bind(containerAnimation) : scrollFunc;\n\t\tscroll1 = scrollFunc();\n\t\tself.vars = vars;\n\t\tanimation = animation || vars.animation;\n\t\tif (\"refreshPriority\" in vars) {\n\t\t\t_sort = 1;\n\t\t\tvars.refreshPriority === -9999 && (_primary = self); // used by ScrollSmoother\n\t\t}\n\t\tscrollerCache.tweenScroll = scrollerCache.tweenScroll || {\n\t\t\ttop: _getTweenCreator(scroller, _vertical),\n\t\t\tleft: _getTweenCreator(scroller, _horizontal)\n\t\t};\n\t\tself.tweenTo = tweenTo = scrollerCache.tweenScroll[direction.p];\n\t\tself.scrubDuration = value => {\n\t\t\tscrubSmooth = _isNumber(value) && value;\n\t\t\tif (!scrubSmooth) {\n\t\t\t\tscrubTween && scrubTween.progress(1).kill();\n\t\t\t\tscrubTween = 0;\n\t\t\t} else {\n\t\t\t\tscrubTween ? scrubTween.duration(value) : (scrubTween = gsap.to(animation, {ease: \"expo\", totalProgress: \"+=0\", inherit: false, duration: scrubSmooth, paused: true, onComplete: () => onScrubComplete && onScrubComplete(self)}));\n\t\t\t}\n\t\t};\n\t\tif (animation) {\n\t\t\tanimation.vars.lazy = false;\n\t\t\t(animation._initted && !self.isReverted) || (animation.vars.immediateRender !== false && vars.immediateRender !== false && animation.duration() && animation.render(0, true, true)); // special case: if this ScrollTrigger gets re-initted, a from() tween with a stagger could get initted initially and then reverted on the re-init which means it'll need to get rendered again here to properly display things. Otherwise, See https://gsap.com/forums/topic/36777-scrollsmoother-splittext-nextjs/ and https://codepen.io/GreenSock/pen/eYPyPpd?editors=0010\n\t\t\tself.animation = animation.pause();\n\t\t\tanimation.scrollTrigger = self;\n\t\t\tself.scrubDuration(scrub);\n\t\t\tsnap1 = 0;\n\t\t\tid || (id = animation.vars.id);\n\t\t}\n\n\t\tif (snap) {\n\t\t\t// TODO: potential idea: use legitimate CSS scroll snapping by pushing invisible elements into the DOM that serve as snap positions, and toggle the document.scrollingElement.style.scrollSnapType onToggle. See https://codepen.io/GreenSock/pen/JjLrgWM for a quick proof of concept.\n\t\t\tif (!_isObject(snap) || snap.push) {\n\t\t\t\tsnap = {snapTo: snap};\n\t\t\t}\n\t\t\t(\"scrollBehavior\" in _body.style) && gsap.set(isViewport ? [_body, _docEl] : scroller, {scrollBehavior: \"auto\"}); // smooth scrolling doesn't work with snap.\n\t\t\t_scrollers.forEach(o => _isFunction(o) && o.target === (isViewport ? _doc.scrollingElement || _docEl : scroller) && (o.smooth = false)); // note: set smooth to false on both the vertical and horizontal scroll getters/setters\n\t\t\tsnapFunc = _isFunction(snap.snapTo) ? snap.snapTo : snap.snapTo === \"labels\" ? _getClosestLabel(animation) : snap.snapTo === \"labelsDirectional\" ? _getLabelAtDirection(animation) : snap.directional !== false ? (value, st) => _snapDirectional(snap.snapTo)(value, _getTime() - lastRefresh < 500 ? 0 : st.direction) : gsap.utils.snap(snap.snapTo);\n\t\t\tsnapDurClamp = snap.duration || {min: 0.1, max: 2};\n\t\t\tsnapDurClamp = _isObject(snapDurClamp) ? _clamp(snapDurClamp.min, snapDurClamp.max) : _clamp(snapDurClamp, snapDurClamp);\n\t\t\tsnapDelayedCall = gsap.delayedCall(snap.delay || (scrubSmooth / 2) || 0.1, () => {\n\t\t\t\tlet scroll = scrollFunc(),\n\t\t\t\t\trefreshedRecently = _getTime() - lastRefresh < 500,\n\t\t\t\t\ttween = tweenTo.tween;\n\t\t\t\tif ((refreshedRecently || Math.abs(self.getVelocity()) < 10) && !tween && !_pointerIsDown && lastSnap !== scroll) {\n\t\t\t\t\tlet progress = (scroll - start) / change, // don't use self.progress because this might run between the refresh() and when the scroll position updates and self.progress is set properly in the update() method.\n\t\t\t\t\t\ttotalProgress = animation && !isToggle ? animation.totalProgress() : progress,\n\t\t\t\t\t\tvelocity = refreshedRecently ? 0 : ((totalProgress - snap2) / (_getTime() - _time2) * 1000) || 0,\n\t\t\t\t\t\tchange1 = gsap.utils.clamp(-progress, 1 - progress, _abs(velocity / 2) * velocity / 0.185),\n\t\t\t\t\t\tnaturalEnd = progress + (snap.inertia === false ? 0 : change1),\n\t\t\t\t\t\tendValue, endScroll,\n\t\t\t\t\t\t{ onStart, onInterrupt, onComplete } = snap;\n\t\t\t\t\tendValue = snapFunc(naturalEnd, self);\n\t\t\t\t\t_isNumber(endValue) || (endValue = naturalEnd); // in case the function didn't return a number, fall back to using the naturalEnd\n\t\t\t\t\tendScroll = Math.max(0, Math.round(start + endValue * change));\n\t\t\t\t\tif (scroll <= end && scroll >= start && endScroll !== scroll) {\n\t\t\t\t\t\tif (tween && !tween._initted && tween.data <= _abs(endScroll - scroll)) { // there's an overlapping snap! So we must figure out which one is closer and let that tween live.\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (snap.inertia === false) {\n\t\t\t\t\t\t\tchange1 = endValue - progress;\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttweenTo(endScroll, {\n\t\t\t\t\t\t\tduration: snapDurClamp(_abs( (Math.max(_abs(naturalEnd - totalProgress), _abs(endValue - totalProgress)) * 0.185 / velocity / 0.05) || 0)),\n\t\t\t\t\t\t\tease: snap.ease || \"power3\",\n\t\t\t\t\t\t\tdata: _abs(endScroll - scroll), // record the distance so that if another snap tween occurs (conflict) we can prioritize the closest snap.\n\t\t\t\t\t\t\tonInterrupt: () => snapDelayedCall.restart(true) && onInterrupt && onInterrupt(self),\n\t\t\t\t\t\t\tonComplete() {\n\t\t\t\t\t\t\t\tself.update();\n\t\t\t\t\t\t\t\tlastSnap = scrollFunc();\n\t\t\t\t\t\t\t\tif (animation && !isToggle) { // the resolution of the scrollbar is limited, so we should correct the scrubbed animation's playhead at the end to match EXACTLY where it was supposed to snap\n\t\t\t\t\t\t\t\t\tscrubTween ? scrubTween.resetTo(\"totalProgress\", endValue, animation._tTime / animation._tDur) : animation.progress(endValue);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tsnap1 = snap2 = animation && !isToggle ? animation.totalProgress() : self.progress;\n\t\t\t\t\t\t\t\tonSnapComplete && onSnapComplete(self);\n\t\t\t\t\t\t\t\tonComplete && onComplete(self);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}, scroll, change1 * change, endScroll - scroll - change1 * change);\n\t\t\t\t\t\tonStart && onStart(self, tweenTo.tween);\n\t\t\t\t\t}\n\t\t\t\t} else if (self.isActive && lastSnap !== scroll) {\n\t\t\t\t\tsnapDelayedCall.restart(true);\n\t\t\t\t}\n\t\t\t}).pause();\n\t\t}\n\t\tid && (_ids[id] = self);\n\t\ttrigger = self.trigger = _getTarget(trigger || (pin !== true && pin));\n\n\t\t// if a trigger has some kind of scroll-related effect applied that could contaminate the \"y\" or \"x\" position (like a ScrollSmoother effect), we needed a way to temporarily revert it, so we use the stRevert property of the gsCache. It can return another function that we'll call at the end so it can return to its normal state.\n\t\tcustomRevertReturn = trigger && trigger._gsap && trigger._gsap.stRevert;\n\t\tcustomRevertReturn && (customRevertReturn = customRevertReturn(self));\n\n\t\tpin = pin === true ? trigger : _getTarget(pin);\n\t\t_isString(toggleClass) && (toggleClass = {targets: trigger, className: toggleClass});\n\t\tif (pin) {\n\t\t\t(pinSpacing === false || pinSpacing === _margin) || (pinSpacing = !pinSpacing && pin.parentNode && pin.parentNode.style && _getComputedStyle(pin.parentNode).display === \"flex\" ? false : _padding); // if the parent is display: flex, don't apply pinSpacing by default. We should check that pin.parentNode is an element (not shadow dom window)\n\t\t\tself.pin = pin;\n\t\t\tpinCache = gsap.core.getCache(pin);\n\t\t\tif (!pinCache.spacer) { // record the spacer and pinOriginalState on the cache in case someone tries pinning the same element with MULTIPLE ScrollTriggers - we don't want to have multiple spacers or record the \"original\" pin state after it has already been affected by another ScrollTrigger.\n\t\t\t\tif (pinSpacer) {\n\t\t\t\t\tpinSpacer = _getTarget(pinSpacer);\n\t\t\t\t\tpinSpacer && !pinSpacer.nodeType && (pinSpacer = pinSpacer.current || pinSpacer.nativeElement); // for React & Angular\n\t\t\t\t\tpinCache.spacerIsNative = !!pinSpacer;\n\t\t\t\t\tpinSpacer && (pinCache.spacerState = _getState(pinSpacer));\n\t\t\t\t}\n\t\t\t\tpinCache.spacer = spacer = pinSpacer || _doc.createElement(\"div\");\n\t\t\t\tspacer.classList.add(\"pin-spacer\");\n\t\t\t\tid && spacer.classList.add(\"pin-spacer-\" + id);\n\t\t\t\tpinCache.pinState = pinOriginalState = _getState(pin);\n\t\t\t} else {\n\t\t\t\tpinOriginalState = pinCache.pinState;\n\t\t\t}\n\t\t\tvars.force3D !== false && gsap.set(pin, {force3D: true});\n\t\t\tself.spacer = spacer = pinCache.spacer;\n\t\t\tcs = _getComputedStyle(pin);\n\t\t\tspacingStart = cs[pinSpacing + direction.os2];\n\t\t\tpinGetter = gsap.getProperty(pin);\n\t\t\tpinSetter = gsap.quickSetter(pin, direction.a, _px);\n\t\t\t// pin.firstChild && !_maxScroll(pin, direction) && (pin.style.overflow = \"hidden\"); // protects from collapsing margins, but can have unintended consequences as demonstrated here: https://codepen.io/GreenSock/pen/1e42c7a73bfa409d2cf1e184e7a4248d so it was removed in favor of just telling people to set up their CSS to avoid the collapsing margins (overflow: hidden | auto is just one option. Another is border-top: 1px solid transparent).\n\t\t\t_swapPinIn(pin, spacer, cs);\n\t\t\tpinState = _getState(pin);\n\t\t}\n\t\tif (markers) {\n\t\t\tmarkerVars = _isObject(markers) ? _setDefaults(markers, _markerDefaults) : _markerDefaults;\n\t\t\tmarkerStartTrigger = _createMarker(\"scroller-start\", id, scroller, direction, markerVars, 0);\n\t\t\tmarkerEndTrigger = _createMarker(\"scroller-end\", id, scroller, direction, markerVars, 0, markerStartTrigger);\n\t\t\toffset = markerStartTrigger[\"offset\" + direction.op.d2];\n\t\t\tlet content = _getTarget(_getProxyProp(scroller, \"content\") || scroller);\n\t\t\tmarkerStart = this.markerStart = _createMarker(\"start\", id, content, direction, markerVars, offset, 0, containerAnimation);\n\t\t\tmarkerEnd = this.markerEnd = _createMarker(\"end\", id, content, direction, markerVars, offset, 0, containerAnimation);\n\t\t\tcontainerAnimation && (caMarkerSetter = gsap.quickSetter([markerStart, markerEnd], direction.a, _px));\n\t\t\tif ((!useFixedPosition && !(_proxies.length && _getProxyProp(scroller, \"fixedMarkers\") === true))) {\n\t\t\t\t_makePositionable(isViewport ? _body : scroller);\n\t\t\t\tgsap.set([markerStartTrigger, markerEndTrigger], {force3D: true});\n\t\t\t\tmarkerStartSetter = gsap.quickSetter(markerStartTrigger, direction.a, _px);\n\t\t\t\tmarkerEndSetter = gsap.quickSetter(markerEndTrigger, direction.a, _px);\n\t\t\t}\n\t\t}\n\n\t\tif (containerAnimation) {\n\t\t\tlet oldOnUpdate = containerAnimation.vars.onUpdate,\n\t\t\t\toldParams = containerAnimation.vars.onUpdateParams;\n\t\t\tcontainerAnimation.eventCallback(\"onUpdate\", () => {\n\t\t\t\tself.update(0, 0, 1);\n\t\t\t\toldOnUpdate && oldOnUpdate.apply(containerAnimation, oldParams || []);\n\t\t\t});\n\t\t}\n\n\t\tself.previous = () => _triggers[_triggers.indexOf(self) - 1];\n\t\tself.next = () => _triggers[_triggers.indexOf(self) + 1];\n\n\t\tself.revert = (revert, temp) => {\n\t\t\tif (!temp) { return self.kill(true); } // for compatibility with gsap.context() and gsap.matchMedia() which call revert()\n\t\t\tlet r = revert !== false || !self.enabled,\n\t\t\t\tprevRefreshing = _refreshing;\n\t\t\tif (r !== self.isReverted) {\n\t\t\t\tif (r) {\n\t\t\t\t\tprevScroll = Math.max(scrollFunc(), self.scroll.rec || 0); // record the scroll so we can revert later (repositioning/pinning things can affect scroll position). In the static refresh() method, we first record all the scroll positions as a reference.\n\t\t\t\t\tprevProgress = self.progress;\n\t\t\t\t\tprevAnimProgress = animation && animation.progress();\n\t\t\t\t}\n\t\t\t\tmarkerStart && [markerStart, markerEnd, markerStartTrigger, markerEndTrigger].forEach(m => m.style.display = r ? \"none\" : \"block\");\n\t\t\t\tif (r) {\n\t\t\t\t\t_refreshing = self;\n\t\t\t\t\tself.update(r); // make sure the pin is back in its original position so that all the measurements are correct. do this BEFORE swapping the pin out\n\t\t\t\t}\n\t\t\t\tif (pin && (!pinReparent || !self.isActive)) {\n\t\t\t\t\tif (r) {\n\t\t\t\t\t\t_swapPinOut(pin, spacer, pinOriginalState);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t_swapPinIn(pin, spacer, _getComputedStyle(pin), spacerState);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tr || self.update(r); // when we're restoring, the update should run AFTER swapping the pin into its pin-spacer.\n\t\t\t\t_refreshing = prevRefreshing; // restore. We set it to true during the update() so that things fire properly in there.\n\t\t\t\tself.isReverted = r;\n\t\t\t}\n\t\t}\n\n\t\tself.refresh = (soft, force, position, pinOffset) => { // position is typically only defined if it's coming from setPositions() - it's a way to skip the normal parsing. pinOffset is also only from setPositions() and is mostly related to fancy stuff we need to do in ScrollSmoother with effects\n\t\t\tif ((_refreshing || !self.enabled) && !force) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (pin && soft && _lastScrollTime) {\n\t\t\t\t_addListener(ScrollTrigger, \"scrollEnd\", _softRefresh);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t!_refreshingAll && onRefreshInit && onRefreshInit(self);\n\t\t\t_refreshing = self;\n\t\t\tif (tweenTo.tween && !position) { // we skip this if a position is passed in because typically that's from .setPositions() and it's best to allow in-progress snapping to continue.\n\t\t\t\ttweenTo.tween.kill();\n\t\t\t\ttweenTo.tween = 0;\n\t\t\t}\n\t\t\tscrubTween && scrubTween.pause();\n\t\t\tinvalidateOnRefresh && animation && animation.revert({kill: false}).invalidate();\n\t\t\tself.isReverted || self.revert(true, true);\n\t\t\tself._subPinOffset = false; // we'll set this to true in the sub-pins if we find any\n\t\t\tlet size = getScrollerSize(),\n\t\t\t\tscrollerBounds = getScrollerOffsets(),\n\t\t\t\tmax = containerAnimation ? containerAnimation.duration() : _maxScroll(scroller, direction),\n\t\t\t\tisFirstRefresh = change <= 0.01,\n\t\t\t\toffset = 0,\n\t\t\t\totherPinOffset = pinOffset || 0,\n\t\t\t\tparsedEnd = _isObject(position) ? position.end : vars.end,\n\t\t\t\tparsedEndTrigger = vars.endTrigger || trigger,\n\t\t\t\tparsedStart = _isObject(position) ? position.start : (vars.start || (vars.start === 0 || !trigger ? 0 : (pin ? \"0 0\" : \"0 100%\"))),\n\t\t\t\tpinnedContainer = self.pinnedContainer = vars.pinnedContainer && _getTarget(vars.pinnedContainer, self),\n\t\t\t\ttriggerIndex = (trigger && Math.max(0, _triggers.indexOf(self))) || 0,\n\t\t\t\ti = triggerIndex,\n\t\t\t\tcs, bounds, scroll, isVertical, override, curTrigger, curPin, oppositeScroll, initted, revertedPins, forcedOverflow, markerStartOffset, markerEndOffset;\n\t\t\tif (markers && _isObject(position)) { // if we alter the start/end positions with .setPositions(), it generally feeds in absolute NUMBERS which don't convey information about where to line up the markers, so to keep it intuitive, we record how far the trigger positions shift after applying the new numbers and then offset by that much in the opposite direction. We do the same to the associated trigger markers too of course.\n\t\t\t\tmarkerStartOffset = gsap.getProperty(markerStartTrigger, direction.p);\n\t\t\t\tmarkerEndOffset = gsap.getProperty(markerEndTrigger, direction.p);\n\t\t\t}\n\t\t\twhile (i-- > 0) { // user might try to pin the same element more than once, so we must find any prior triggers with the same pin, revert them, and determine how long they're pinning so that we can offset things appropriately. Make sure we revert from last to first so that things \"rewind\" properly.\n\t\t\t\tcurTrigger = _triggers[i];\n\t\t\t\tcurTrigger.end || curTrigger.refresh(0, 1) || (_refreshing = self); // if it's a timeline-based trigger that hasn't been fully initialized yet because it's waiting for 1 tick, just force the refresh() here, otherwise if it contains a pin that's supposed to affect other ScrollTriggers further down the page, they won't be adjusted properly.\n\t\t\t\tcurPin = curTrigger.pin;\n\t\t\t\tif (curPin && (curPin === trigger || curPin === pin || curPin === pinnedContainer) && !curTrigger.isReverted) {\n\t\t\t\t\trevertedPins || (revertedPins = []);\n\t\t\t\t\trevertedPins.unshift(curTrigger); // we'll revert from first to last to make sure things reach their end state properly\n\t\t\t\t\tcurTrigger.revert(true, true);\n\t\t\t\t}\n\t\t\t\tif (curTrigger !== _triggers[i]) { // in case it got removed.\n\t\t\t\t\ttriggerIndex--;\n\t\t\t\t\ti--;\n\t\t\t\t}\n\t\t\t}\n\t\t\t_isFunction(parsedStart) && (parsedStart = parsedStart(self));\n\t\t\tparsedStart = _parseClamp(parsedStart, \"start\", self);\n\t\t\tstart = _parsePosition(parsedStart, trigger, size, direction, scrollFunc(), markerStart, markerStartTrigger, self, scrollerBounds, borderWidth, useFixedPosition, max, containerAnimation, self._startClamp && \"_startClamp\") || (pin ? -0.001 : 0);\n\t\t\t_isFunction(parsedEnd) && (parsedEnd = parsedEnd(self));\n\t\t\tif (_isString(parsedEnd) && !parsedEnd.indexOf(\"+=\")) {\n\t\t\t\tif (~parsedEnd.indexOf(\" \")) {\n\t\t\t\t\tparsedEnd = (_isString(parsedStart) ? parsedStart.split(\" \")[0] : \"\") + parsedEnd;\n\t\t\t\t} else {\n\t\t\t\t\toffset = _offsetToPx(parsedEnd.substr(2), size);\n\t\t\t\t\tparsedEnd = _isString(parsedStart) ? parsedStart : (containerAnimation ? gsap.utils.mapRange(0, containerAnimation.duration(), containerAnimation.scrollTrigger.start, containerAnimation.scrollTrigger.end, start) : start) + offset; // _parsePosition won't factor in the offset if the start is a number, so do it here.\n\t\t\t\t\tparsedEndTrigger = trigger;\n\t\t\t\t}\n\t\t\t}\n\t\t\tparsedEnd = _parseClamp(parsedEnd, \"end\", self);\n\t\t\tend = Math.max(start, _parsePosition(parsedEnd || (parsedEndTrigger ? \"100% 0\" : max), parsedEndTrigger, size, direction, scrollFunc() + offset, markerEnd, markerEndTrigger, self, scrollerBounds, borderWidth, useFixedPosition, max, containerAnimation, self._endClamp && \"_endClamp\")) || -0.001;\n\n\t\t\toffset = 0;\n\t\t\ti = triggerIndex;\n\t\t\twhile (i--) {\n\t\t\t\tcurTrigger = _triggers[i];\n\t\t\t\tcurPin = curTrigger.pin;\n\t\t\t\tif (curPin && curTrigger.start - curTrigger._pinPush <= start && !containerAnimation && curTrigger.end > 0) {\n\t\t\t\t\tcs = curTrigger.end - (self._startClamp ? Math.max(0, curTrigger.start) : curTrigger.start);\n\t\t\t\t\tif (((curPin === trigger && curTrigger.start - curTrigger._pinPush < start) || curPin === pinnedContainer) && isNaN(parsedStart)) { // numeric start values shouldn't be offset at all - treat them as absolute\n\t\t\t\t\t\toffset += cs * (1 - curTrigger.progress);\n\t\t\t\t\t}\n\t\t\t\t\tcurPin === pin && (otherPinOffset += cs);\n\t\t\t\t}\n\t\t\t}\n\t\t\tstart += offset;\n\t\t\tend += offset;\n\t\t\tself._startClamp && (self._startClamp += offset);\n\n\t\t\tif (self._endClamp && !_refreshingAll) {\n\t\t\t\tself._endClamp = end || -0.001;\n\t\t\t\tend = Math.min(end, _maxScroll(scroller, direction));\n\t\t\t}\n\t\t\tchange = (end - start) || ((start -= 0.01) && 0.001);\n\n\t\t\tif (isFirstRefresh) { // on the very first refresh(), the prevProgress couldn't have been accurate yet because the start/end were never calculated, so we set it here. Before 3.11.5, it could lead to an inaccurate scroll position restoration with snapping.\n\t\t\t\tprevProgress = gsap.utils.clamp(0, 1, gsap.utils.normalize(start, end, prevScroll));\n\t\t\t}\n\t\t\tself._pinPush = otherPinOffset;\n\t\t\tif (markerStart && offset) { // offset the markers if necessary\n\t\t\t\tcs = {};\n\t\t\t\tcs[direction.a] = \"+=\" + offset;\n\t\t\t\tpinnedContainer && (cs[direction.p] = \"-=\" + scrollFunc());\n\t\t\t\tgsap.set([markerStart, markerEnd], cs);\n\t\t\t}\n\n\t\t\tif (pin && !(_clampingMax && self.end >= _maxScroll(scroller, direction))) {\n\t\t\t\tcs = _getComputedStyle(pin);\n\t\t\t\tisVertical = direction === _vertical;\n\t\t\t\tscroll = scrollFunc(); // recalculate because the triggers can affect the scroll\n\t\t\t\tpinStart = parseFloat(pinGetter(direction.a)) + otherPinOffset;\n\t\t\t\tif (!max && end > 1) { // makes sure the scroller has a scrollbar, otherwise if something has width: 100%, for example, it would be too big (exclude the scrollbar). See https://gsap.com/forums/topic/25182-scrolltrigger-width-of-page-increase-where-markers-are-set-to-false/\n\t\t\t\t\tforcedOverflow = (isViewport ? (_doc.scrollingElement || _docEl) : scroller).style;\n\t\t\t\t\tforcedOverflow = {style: forcedOverflow, value: forcedOverflow[\"overflow\" + direction.a.toUpperCase()]};\n\t\t\t\t\tif (isViewport && _getComputedStyle(_body)[\"overflow\" + direction.a.toUpperCase()] !== \"scroll\") { // avoid an extra scrollbar if BOTH and have overflow set to \"scroll\"\n\t\t\t\t\t\tforcedOverflow.style[\"overflow\" + direction.a.toUpperCase()] = \"scroll\";\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t_swapPinIn(pin, spacer, cs);\n\t\t\t\tpinState = _getState(pin);\n\t\t\t\t// transforms will interfere with the top/left/right/bottom placement, so remove them temporarily. getBoundingClientRect() factors in transforms.\n\t\t\t\tbounds = _getBounds(pin, true);\n\t\t\t\toppositeScroll = useFixedPosition && _getScrollFunc(scroller, isVertical ? _horizontal : _vertical)();\n\t\t\t\tif (pinSpacing) {\n\t\t\t\t\tspacerState = [pinSpacing + direction.os2, change + otherPinOffset + _px];\n\t\t\t\t\tspacerState.t = spacer;\n\t\t\t\t\ti = (pinSpacing === _padding) ? _getSize(pin, direction) + change + otherPinOffset : 0;\n\t\t\t\t\tif (i) {\n\t\t\t\t\t\tspacerState.push(direction.d, i + _px); // for box-sizing: border-box (must include padding).\n\t\t\t\t\t\tspacer.style.flexBasis !== \"auto\" && (spacer.style.flexBasis = i + _px);\n\t\t\t\t\t}\n\t\t\t\t\t_setState(spacerState);\n\t\t\t\t\tif (pinnedContainer) { // in ScrollTrigger.refresh(), we need to re-evaluate the pinContainer's size because this pinSpacing may stretch it out, but we can't just add the exact distance because depending on layout, it may not push things down or it may only do so partially.\n\t\t\t\t\t\t_triggers.forEach(t => {\n\t\t\t\t\t\t\tif (t.pin === pinnedContainer && t.vars.pinSpacing !== false) {\n\t\t\t\t\t\t\t\tt._subPinOffset = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tuseFixedPosition && scrollFunc(prevScroll);\n\t\t\t\t} else {\n\t\t\t\t\ti = _getSize(pin, direction);\n\t\t\t\t\ti && spacer.style.flexBasis !== \"auto\" && (spacer.style.flexBasis = i + _px);\n\t\t\t\t}\n\t\t\t\tif (useFixedPosition) {\n\t\t\t\t\toverride = {\n\t\t\t\t\t\ttop: (bounds.top + (isVertical ? scroll - start : oppositeScroll)) + _px,\n\t\t\t\t\t\tleft: (bounds.left + (isVertical ? oppositeScroll : scroll - start)) + _px,\n\t\t\t\t\t\tboxSizing: \"border-box\",\n\t\t\t\t\t\tposition: \"fixed\"\n\t\t\t\t\t};\n\t\t\t\t\toverride[_width] = override[\"max\" + _Width] = Math.ceil(bounds.width) + _px;\n\t\t\t\t\toverride[_height] = override[\"max\" + _Height] = Math.ceil(bounds.height) + _px;\n\t\t\t\t\toverride[_margin] = override[_margin + _Top] = override[_margin + _Right] = override[_margin + _Bottom] = override[_margin + _Left] = \"0\";\n\t\t\t\t\toverride[_padding] = cs[_padding];\n\t\t\t\t\toverride[_padding + _Top] = cs[_padding + _Top];\n\t\t\t\t\toverride[_padding + _Right] = cs[_padding + _Right];\n\t\t\t\t\toverride[_padding + _Bottom] = cs[_padding + _Bottom];\n\t\t\t\t\toverride[_padding + _Left] = cs[_padding + _Left];\n\t\t\t\t\tpinActiveState = _copyState(pinOriginalState, override, pinReparent);\n\t\t\t\t\t_refreshingAll && scrollFunc(0);\n\t\t\t\t}\n\t\t\t\tif (animation) { // the animation might be affecting the transform, so we must jump to the end, check the value, and compensate accordingly. Otherwise, when it becomes unpinned, the pinSetter() will get set to a value that doesn't include whatever the animation did.\n\t\t\t\t\tinitted = animation._initted; // if not, we must invalidate() after this step, otherwise it could lock in starting values prematurely.\n\t\t\t\t\t_suppressOverwrites(1);\n\t\t\t\t\tanimation.render(animation.duration(), true, true);\n\t\t\t\t\tpinChange = pinGetter(direction.a) - pinStart + change + otherPinOffset;\n\t\t\t\t\tpinMoves = Math.abs(change - pinChange) > 1;\n\t\t\t\t\tuseFixedPosition && pinMoves && pinActiveState.splice(pinActiveState.length - 2, 2); // transform is the last property/value set in the state Array. Since the animation is controlling that, we should omit it.\n\t\t\t\t\tanimation.render(0, true, true);\n\t\t\t\t\tinitted || animation.invalidate(true);\n\t\t\t\t\tanimation.parent || animation.totalTime(animation.totalTime()); // if, for example, a toggleAction called play() and then refresh() happens and when we render(1) above, it would cause the animation to complete and get removed from its parent, so this makes sure it gets put back in.\n\t\t\t\t\t_suppressOverwrites(0);\n\t\t\t\t} else {\n\t\t\t\t\tpinChange = change\n\t\t\t\t}\n\t\t\t\tforcedOverflow && (forcedOverflow.value ? (forcedOverflow.style[\"overflow\" + direction.a.toUpperCase()] = forcedOverflow.value) : forcedOverflow.style.removeProperty(\"overflow-\" + direction.a));\n\t\t\t} else if (trigger && scrollFunc() && !containerAnimation) { // it may be INSIDE a pinned element, so walk up the tree and look for any elements with _pinOffset to compensate because anything with pinSpacing that's already scrolled would throw off the measurements in getBoundingClientRect()\n\t\t\t\tbounds = trigger.parentNode;\n\t\t\t\twhile (bounds && bounds !== _body) {\n\t\t\t\t\tif (bounds._pinOffset) {\n\t\t\t\t\t\tstart -= bounds._pinOffset;\n\t\t\t\t\t\tend -= bounds._pinOffset;\n\t\t\t\t\t}\n\t\t\t\t\tbounds = bounds.parentNode;\n\t\t\t\t}\n\t\t\t}\n\t\t\trevertedPins && revertedPins.forEach(t => t.revert(false, true));\n\t\t\tself.start = start;\n\t\t\tself.end = end;\n\t\t\tscroll1 = scroll2 = _refreshingAll ? prevScroll : scrollFunc(); // reset velocity\n\t\t\tif (!containerAnimation && !_refreshingAll) {\n\t\t\t\tscroll1 < prevScroll && scrollFunc(prevScroll);\n\t\t\t\tself.scroll.rec = 0;\n\t\t\t}\n\t\t\tself.revert(false, true);\n\t\t\tlastRefresh = _getTime();\n\t\t\tif (snapDelayedCall) {\n\t\t\t\tlastSnap = -1; // just so snapping gets re-enabled, clear out any recorded last value\n\t\t\t\t// self.isActive && scrollFunc(start + change * prevProgress); // previously this line was here to ensure that when snapping kicks in, it's from the previous progress but in some cases that's not desirable, like an all-page ScrollTrigger when new content gets added to the page, that'd totally change the progress.\n\t\t\t\tsnapDelayedCall.restart(true);\n\t\t\t}\n\t\t\t_refreshing = 0;\n\t\t\tanimation && isToggle && (animation._initted || prevAnimProgress) && animation.progress() !== prevAnimProgress && animation.progress(prevAnimProgress || 0, true).render(animation.time(), true, true); // must force a re-render because if saveStyles() was used on the target(s), the styles could have been wiped out during the refresh().\n\t\t\tif (isFirstRefresh || prevProgress !== self.progress || containerAnimation || invalidateOnRefresh || (animation && !animation._initted)) { // ensures that the direction is set properly (when refreshing, progress is set back to 0 initially, then back again to wherever it needs to be) and that callbacks are triggered.\n\t\t\t\tanimation && !isToggle && animation.totalProgress(containerAnimation && start < -0.001 && !prevProgress ? gsap.utils.normalize(start, end, 0) : prevProgress, true); // to avoid issues where animation callbacks like onStart aren't triggered.\n\t\t\t\tself.progress = isFirstRefresh || ((scroll1 - start) / change === prevProgress) ? 0 : prevProgress;\n\t\t\t}\n\t\t\tpin && pinSpacing && (spacer._pinOffset = Math.round(self.progress * pinChange));\n\t\t\tscrubTween && scrubTween.invalidate();\n\n\t\t\tif (!isNaN(markerStartOffset)) { // numbers were passed in for the position which are absolute, so instead of just putting the markers at the very bottom of the viewport, we figure out how far they shifted down (it's safe to assume they were originally positioned in closer relation to the trigger element with values like \"top\", \"center\", a percentage or whatever, so we offset that much in the opposite direction to basically revert them to the relative position thy were at previously.\n\t\t\t\tmarkerStartOffset -= gsap.getProperty(markerStartTrigger, direction.p);\n\t\t\t\tmarkerEndOffset -= gsap.getProperty(markerEndTrigger, direction.p);\n\t\t\t\t_shiftMarker(markerStartTrigger, direction, markerStartOffset);\n\t\t\t\t_shiftMarker(markerStart, direction, markerStartOffset - (pinOffset || 0));\n\t\t\t\t_shiftMarker(markerEndTrigger, direction, markerEndOffset);\n\t\t\t\t_shiftMarker(markerEnd, direction, markerEndOffset - (pinOffset || 0));\n\t\t\t}\n\n\t\t\tisFirstRefresh && !_refreshingAll && self.update(); // edge case - when you reload a page when it's already scrolled down, some browsers fire a \"scroll\" event before DOMContentLoaded, triggering an updateAll(). If we don't update the self.progress as part of refresh(), then when it happens next, it may record prevProgress as 0 when it really shouldn't, potentially causing a callback in an animation to fire again.\n\n\t\t\tif (onRefresh && !_refreshingAll && !executingOnRefresh) { // when refreshing all, we do extra work to correct pinnedContainer sizes and ensure things don't exceed the maxScroll, so we should do all the refreshes at the end after all that work so that the start/end values are corrected.\n\t\t\t\texecutingOnRefresh = true;\n\t\t\t\tonRefresh(self);\n\t\t\t\texecutingOnRefresh = false;\n\t\t\t}\n\t\t};\n\n\t\tself.getVelocity = () => ((scrollFunc() - scroll2) / (_getTime() - _time2) * 1000) || 0;\n\n\t\tself.endAnimation = () => {\n\t\t\t_endAnimation(self.callbackAnimation);\n\t\t\tif (animation) {\n\t\t\t\tscrubTween ? scrubTween.progress(1) : (!animation.paused() ? _endAnimation(animation, animation.reversed()) : isToggle || _endAnimation(animation, self.direction < 0, 1));\n\t\t\t}\n\t\t};\n\n\t\tself.labelToScroll = label => animation && animation.labels && ((start || self.refresh() || start) + (animation.labels[label] / animation.duration()) * change) || 0;\n\n\t\tself.getTrailing = name => {\n\t\t\tlet i = _triggers.indexOf(self),\n\t\t\t\ta = self.direction > 0 ? _triggers.slice(0, i).reverse() : _triggers.slice(i+1);\n\t\t\treturn (_isString(name) ? a.filter(t => t.vars.preventOverlaps === name) : a).filter(t => self.direction > 0 ? t.end <= start : t.start >= end);\n\t\t};\n\n\n\t\tself.update = (reset, recordVelocity, forceFake) => {\n\t\t\tif (containerAnimation && !forceFake && !reset) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlet scroll = _refreshingAll === true ? prevScroll : self.scroll(),\n\t\t\t\tp = reset ? 0 : (scroll - start) / change,\n\t\t\t\tclipped = p < 0 ? 0 : p > 1 ? 1 : p || 0,\n\t\t\t\tprevProgress = self.progress,\n\t\t\t\tisActive, wasActive, toggleState, action, stateChanged, toggled, isAtMax, isTakingAction;\n\t\t\tif (recordVelocity) {\n\t\t\t\tscroll2 = scroll1;\n\t\t\t\tscroll1 = containerAnimation ? scrollFunc() : scroll;\n\t\t\t\tif (snap) {\n\t\t\t\t\tsnap2 = snap1;\n\t\t\t\t\tsnap1 = animation && !isToggle ? animation.totalProgress() : clipped;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// anticipate the pinning a few ticks ahead of time based on velocity to avoid a visual glitch due to the fact that most browsers do scrolling on a separate thread (not synced with requestAnimationFrame).\n\t\t\tif (anticipatePin && pin && !_refreshing && !_startup && _lastScrollTime) {\n\t\t\t\tif (!clipped && start < scroll + ((scroll - scroll2) / (_getTime() - _time2)) * anticipatePin) {\n\t\t\t\t\tclipped = 0.0001;\n\t\t\t\t} else if (clipped === 1 && end > scroll + ((scroll - scroll2) / (_getTime() - _time2)) * anticipatePin) {\n\t\t\t\t\tclipped = 0.9999;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (clipped !== prevProgress && self.enabled) {\n\t\t\t\tisActive = self.isActive = !!clipped && clipped < 1;\n\t\t\t\twasActive = !!prevProgress && prevProgress < 1;\n\t\t\t\ttoggled = isActive !== wasActive;\n\t\t\t\tstateChanged = toggled || !!clipped !== !!prevProgress; // could go from start all the way to end, thus it didn't toggle but it did change state in a sense (may need to fire a callback)\n\t\t\t\tself.direction = clipped > prevProgress ? 1 : -1;\n\t\t\t\tself.progress = clipped;\n\n\t\t\t\tif (stateChanged && !_refreshing) {\n\t\t\t\t\ttoggleState = clipped && !prevProgress ? 0 : clipped === 1 ? 1 : prevProgress === 1 ? 2 : 3; // 0 = enter, 1 = leave, 2 = enterBack, 3 = leaveBack (we prioritize the FIRST encounter, thus if you scroll really fast past the onEnter and onLeave in one tick, it'd prioritize onEnter.\n\t\t\t\t\tif (isToggle) {\n\t\t\t\t\t\taction = (!toggled && toggleActions[toggleState + 1] !== \"none\" && toggleActions[toggleState + 1]) || toggleActions[toggleState]; // if it didn't toggle, that means it shot right past and since we prioritize the \"enter\" action, we should switch to the \"leave\" in this case (but only if one is defined)\n\t\t\t\t\t\tisTakingAction = animation && (action === \"complete\" || action === \"reset\" || action in animation);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tpreventOverlaps && (toggled || isTakingAction) && (isTakingAction || scrub || !animation) && (_isFunction(preventOverlaps) ? preventOverlaps(self) : self.getTrailing(preventOverlaps).forEach(t => t.endAnimation()));\n\n\t\t\t\tif (!isToggle) {\n\t\t\t\t\tif (scrubTween && !_refreshing && !_startup) {\n\t\t\t\t\t\t(scrubTween._dp._time - scrubTween._start !== scrubTween._time) && scrubTween.render(scrubTween._dp._time - scrubTween._start); // if there's a scrub on both the container animation and this one (or a ScrollSmoother), the update order would cause this one not to have rendered yet, so it wouldn't make any progress before we .restart() it heading toward the new progress so it'd appear stuck thus we force a render here.\n\t\t\t\t\t\tif (scrubTween.resetTo) {\n\t\t\t\t\t\t\tscrubTween.resetTo(\"totalProgress\", clipped, animation._tTime / animation._tDur);\n\t\t\t\t\t\t} else { // legacy support (courtesy), before 3.10.0\n\t\t\t\t\t\t\tscrubTween.vars.totalProgress = clipped;\n\t\t\t\t\t\t\tscrubTween.invalidate().restart();\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (animation) {\n\t\t\t\t\t\tanimation.totalProgress(clipped, !!(_refreshing && (lastRefresh || reset)));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (pin) {\n\t\t\t\t\treset && pinSpacing && (spacer.style[pinSpacing + direction.os2] = spacingStart);\n\t\t\t\t\tif (!useFixedPosition) {\n\t\t\t\t\t\tpinSetter(_round(pinStart + pinChange * clipped));\n\t\t\t\t\t} else if (stateChanged) {\n\t\t\t\t\t\tisAtMax = !reset && clipped > prevProgress && end + 1 > scroll && scroll + 1 >= _maxScroll(scroller, direction); // if it's at the VERY end of the page, don't switch away from position: fixed because it's pointless and it could cause a brief flash when the user scrolls back up (when it gets pinned again)\n\t\t\t\t\t\tif (pinReparent) {\n\t\t\t\t\t\t\tif (!reset && (isActive || isAtMax)) {\n\t\t\t\t\t\t\t\tlet bounds = _getBounds(pin, true),\n\t\t\t\t\t\t\t\t\toffset = scroll - start;\n\t\t\t\t\t\t\t\t_reparent(pin, _body, (bounds.top + (direction === _vertical ? offset : 0)) + _px, (bounds.left + (direction === _vertical ? 0 : offset)) + _px);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t_reparent(pin, spacer);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t_setState(isActive || isAtMax ? pinActiveState : pinState);\n\t\t\t\t\t\t(pinMoves && clipped < 1 && isActive) || pinSetter(pinStart + (clipped === 1 && !isAtMax ? pinChange : 0));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsnap && !tweenTo.tween && !_refreshing && !_startup && snapDelayedCall.restart(true);\n\t\t\t\ttoggleClass && (toggled || (once && clipped && (clipped < 1 || !_limitCallbacks))) && _toArray(toggleClass.targets).forEach(el => el.classList[isActive || once ? \"add\" : \"remove\"](toggleClass.className)); // classes could affect positioning, so do it even if reset or refreshing is true.\n\t\t\t\tonUpdate && !isToggle && !reset && onUpdate(self);\n\t\t\t\tif (stateChanged && !_refreshing) {\n\t\t\t\t\tif (isToggle) {\n\t\t\t\t\t\tif (isTakingAction) {\n\t\t\t\t\t\t\tif (action === \"complete\") {\n\t\t\t\t\t\t\t\tanimation.pause().totalProgress(1);\n\t\t\t\t\t\t\t} else if (action === \"reset\") {\n\t\t\t\t\t\t\t\tanimation.restart(true).pause();\n\t\t\t\t\t\t\t} else if (action === \"restart\") {\n\t\t\t\t\t\t\t\tanimation.restart(true);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tanimation[action]();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonUpdate && onUpdate(self);\n\t\t\t\t\t}\n\t\t\t\t\tif (toggled || !_limitCallbacks) { // on startup, the page could be scrolled and we don't want to fire callbacks that didn't toggle. For example onEnter shouldn't fire if the ScrollTrigger isn't actually entered.\n\t\t\t\t\t\tonToggle && toggled && _callback(self, onToggle);\n\t\t\t\t\t\tcallbacks[toggleState] && _callback(self, callbacks[toggleState]);\n\t\t\t\t\t\tonce && (clipped === 1 ? self.kill(false, 1) : (callbacks[toggleState] = 0)); // a callback shouldn't be called again if once is true.\n\t\t\t\t\t\tif (!toggled) { // it's possible to go completely past, like from before the start to after the end (or vice-versa) in which case BOTH callbacks should be fired in that order\n\t\t\t\t\t\t\ttoggleState = clipped === 1 ? 1 : 3;\n\t\t\t\t\t\t\tcallbacks[toggleState] && _callback(self, callbacks[toggleState]);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (fastScrollEnd && !isActive && Math.abs(self.getVelocity()) > (_isNumber(fastScrollEnd) ? fastScrollEnd : 2500)) {\n\t\t\t\t\t\t_endAnimation(self.callbackAnimation);\n\t\t\t\t\t\tscrubTween ? scrubTween.progress(1) : _endAnimation(animation, action === \"reverse\" ? 1 : !clipped, 1);\n\t\t\t\t\t}\n\t\t\t\t} else if (isToggle && onUpdate && !_refreshing) {\n\t\t\t\t\tonUpdate(self);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// update absolutely-positioned markers (only if the scroller isn't the viewport)\n\t\t\tif (markerEndSetter) {\n\t\t\t\tlet n = containerAnimation ? scroll / containerAnimation.duration() * (containerAnimation._caScrollDist || 0) : scroll;\n\t\t\t\tmarkerStartSetter(n + (markerStartTrigger._isFlipped ? 1 : 0));\n\t\t\t\tmarkerEndSetter(n);\n\t\t\t}\n\t\t\tcaMarkerSetter && caMarkerSetter(-scroll / containerAnimation.duration() * (containerAnimation._caScrollDist || 0));\n\t\t};\n\n\t\tself.enable = (reset, refresh) => {\n\t\t\tif (!self.enabled) {\n\t\t\t\tself.enabled = true;\n\t\t\t\t_addListener(scroller, \"resize\", _onResize);\n\t\t\t\tisViewport || _addListener(scroller, \"scroll\", _onScroll);\n\t\t\t\tonRefreshInit && _addListener(ScrollTrigger, \"refreshInit\", onRefreshInit);\n\t\t\t\tif (reset !== false) {\n\t\t\t\t\tself.progress = prevProgress = 0;\n\t\t\t\t\tscroll1 = scroll2 = lastSnap = scrollFunc();\n\t\t\t\t}\n\t\t\t\trefresh !== false && self.refresh();\n\t\t\t}\n\t\t};\n\n\t\tself.getTween = snap => snap && tweenTo ? tweenTo.tween : scrubTween;\n\n\t\tself.setPositions = (newStart, newEnd, keepClamp, pinOffset) => { // doesn't persist after refresh()! Intended to be a way to override values that were set during refresh(), like you could set it in onRefresh()\n\t\t\tif (containerAnimation) { // convert ratios into scroll positions. Remember, start/end values on ScrollTriggers that have a containerAnimation refer to the time (in seconds), NOT scroll positions.\n\t\t\t\tlet st = containerAnimation.scrollTrigger,\n\t\t\t\t\tduration = containerAnimation.duration(),\n\t\t\t\t\tchange = st.end - st.start;\n\t\t\t\tnewStart = st.start + change * newStart / duration;\n\t\t\t\tnewEnd = st.start + change * newEnd / duration;\n\t\t\t}\n\t\t\tself.refresh(false, false, {start: _keepClamp(newStart, keepClamp && !!self._startClamp), end: _keepClamp(newEnd, keepClamp && !!self._endClamp)}, pinOffset);\n\t\t\tself.update();\n\t\t};\n\n\t\tself.adjustPinSpacing = amount => {\n\t\t\tif (spacerState && amount) {\n\t\t\t\tlet i = spacerState.indexOf(direction.d) + 1;\n\t\t\t\tspacerState[i] = (parseFloat(spacerState[i]) + amount) + _px;\n\t\t\t\tspacerState[1] = (parseFloat(spacerState[1]) + amount) + _px;\n\t\t\t\t_setState(spacerState);\n\t\t\t}\n\t\t};\n\n\t\tself.disable = (reset, allowAnimation) => {\n\t\t\tif (self.enabled) {\n\t\t\t\treset !== false && self.revert(true, true);\n\t\t\t\tself.enabled = self.isActive = false;\n\t\t\t\tallowAnimation || (scrubTween && scrubTween.pause());\n\t\t\t\tprevScroll = 0;\n\t\t\t\tpinCache && (pinCache.uncache = 1);\n\t\t\t\tonRefreshInit && _removeListener(ScrollTrigger, \"refreshInit\", onRefreshInit);\n\t\t\t\tif (snapDelayedCall) {\n\t\t\t\t\tsnapDelayedCall.pause();\n\t\t\t\t\ttweenTo.tween && tweenTo.tween.kill() && (tweenTo.tween = 0);\n\t\t\t\t}\n\t\t\t\tif (!isViewport) {\n\t\t\t\t\tlet i = _triggers.length;\n\t\t\t\t\twhile (i--) {\n\t\t\t\t\t\tif (_triggers[i].scroller === scroller && _triggers[i] !== self) {\n\t\t\t\t\t\t\treturn; //don't remove the listeners if there are still other triggers referencing it.\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t_removeListener(scroller, \"resize\", _onResize);\n\t\t\t\t\tisViewport || _removeListener(scroller, \"scroll\", _onScroll);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tself.kill = (revert, allowAnimation) => {\n\t\t\tself.disable(revert, allowAnimation);\n\t\t\tscrubTween && !allowAnimation && scrubTween.kill();\n\t\t\tid && (delete _ids[id]);\n\t\t\tlet i = _triggers.indexOf(self);\n\t\t\ti >= 0 && _triggers.splice(i, 1);\n\t\t\ti === _i && _direction > 0 && _i--; // if we're in the middle of a refresh() or update(), splicing would cause skips in the index, so adjust...\n\n\t\t\t// if no other ScrollTrigger instances of the same scroller are found, wipe out any recorded scroll position. Otherwise, in a single page application, for example, it could maintain scroll position when it really shouldn't.\n\t\t\ti = 0;\n\t\t\t_triggers.forEach(t => t.scroller === self.scroller && (i = 1));\n\t\t\ti || _refreshingAll || (self.scroll.rec = 0);\n\n\t\t\tif (animation) {\n\t\t\t\tanimation.scrollTrigger = null;\n\t\t\t\trevert && animation.revert({kill: false});\n\t\t\t\tallowAnimation || animation.kill();\n\t\t\t}\n\t\t\tmarkerStart && [markerStart, markerEnd, markerStartTrigger, markerEndTrigger].forEach(m => m.parentNode && m.parentNode.removeChild(m));\n\t\t\t_primary === self && (_primary = 0);\n\t\t\tif (pin) {\n\t\t\t\tpinCache && (pinCache.uncache = 1);\n\t\t\t\ti = 0;\n\t\t\t\t_triggers.forEach(t => t.pin === pin && i++);\n\t\t\t\ti || (pinCache.spacer = 0); // if there aren't any more ScrollTriggers with the same pin, remove the spacer, otherwise it could be contaminated with old/stale values if the user re-creates a ScrollTrigger for the same element.\n\t\t\t}\n\t\t\tvars.onKill && vars.onKill(self);\n\t\t};\n\n\t\t_triggers.push(self);\n\t\tself.enable(false, false);\n\t\tcustomRevertReturn && customRevertReturn(self);\n\n\t\tif (animation && animation.add && !change) { // if the animation is a timeline, it may not have been populated yet, so it wouldn't render at the proper place on the first refresh(), thus we should schedule one for the next tick. If \"change\" is defined, we know it must be re-enabling, thus we can refresh() right away.\n\t\t\tlet updateFunc = self.update; // some browsers may fire a scroll event BEFORE a tick elapses and/or the DOMContentLoaded fires. So there's a chance update() will be called BEFORE a refresh() has happened on a Timeline-attached ScrollTrigger which means the start/end won't be calculated yet. We don't want to add conditional logic inside the update() method (like check to see if end is defined and if not, force a refresh()) because that's a function that gets hit a LOT (performance). So we swap out the real update() method for this one that'll re-attach it the first time it gets called and of course forces a refresh().\n\t\t\tself.update = () => {\n\t\t\t\tself.update = updateFunc;\n\t\t\t\t_scrollers.cache++; // otherwise a cached scroll position may get used in the refresh() in a very rare scenario, like if ScrollTriggers are created inside a DOMContentLoaded event and the queued requestAnimationFrame() fires beforehand. See https://gsap.com/community/forums/topic/41267-scrolltrigger-breaks-on-refresh-when-using-domcontentloaded/\n\t\t\t\tstart || end || self.refresh();\n\t\t\t};\n\t\t\tgsap.delayedCall(0.01, self.update);\n\t\t\tchange = 0.01;\n\t\t\tstart = end = 0;\n\t\t} else {\n\t\t\tself.refresh();\n\t\t}\n\t\tpin && _queueRefreshAll(); // pinning could affect the positions of other things, so make sure we queue a full refresh()\n\t}\n\n\n\tstatic register(core) {\n\t\tif (!_coreInitted) {\n\t\t\tgsap = core || _getGSAP();\n\t\t\t_windowExists() && window.document && ScrollTrigger.enable();\n\t\t\t_coreInitted = _enabled;\n\t\t}\n\t\treturn _coreInitted;\n\t}\n\n\tstatic defaults(config) {\n\t\tif (config) {\n\t\t\tfor (let p in config) {\n\t\t\t\t_defaults[p] = config[p];\n\t\t\t}\n\t\t}\n\t\treturn _defaults;\n\t}\n\n\tstatic disable(reset, kill) {\n\t\t_enabled = 0;\n\t\t_triggers.forEach(trigger => trigger[kill ? \"kill\" : \"disable\"](reset));\n\t\t_removeListener(_win, \"wheel\", _onScroll);\n\t\t_removeListener(_doc, \"scroll\", _onScroll);\n\t\tclearInterval(_syncInterval);\n\t\t_removeListener(_doc, \"touchcancel\", _passThrough);\n\t\t_removeListener(_body, \"touchstart\", _passThrough);\n\t\t_multiListener(_removeListener, _doc, \"pointerdown,touchstart,mousedown\", _pointerDownHandler);\n\t\t_multiListener(_removeListener, _doc, \"pointerup,touchend,mouseup\", _pointerUpHandler);\n\t\t_resizeDelay.kill();\n\t\t_iterateAutoRefresh(_removeListener);\n\t\tfor (let i = 0; i < _scrollers.length; i+=3) {\n\t\t\t_wheelListener(_removeListener, _scrollers[i], _scrollers[i+1]);\n\t\t\t_wheelListener(_removeListener, _scrollers[i], _scrollers[i+2]);\n\t\t}\n\t}\n\n\tstatic enable() {\n\t\t_win = window;\n\t\t_doc = document;\n\t\t_docEl = _doc.documentElement;\n\t\t_body = _doc.body;\n\t\tif (gsap) {\n\t\t\t_toArray = gsap.utils.toArray;\n\t\t\t_clamp = gsap.utils.clamp;\n\t\t\t_context = gsap.core.context || _passThrough;\n\t\t\t_suppressOverwrites = gsap.core.suppressOverwrites || _passThrough;\n\t\t\t_scrollRestoration = _win.history.scrollRestoration || \"auto\";\n\t\t\t_lastScroll = _win.pageYOffset || 0;\n\t\t\tgsap.core.globals(\"ScrollTrigger\", ScrollTrigger); // must register the global manually because in Internet Explorer, functions (classes) don't have a \"name\" property.\n\t\t\tif (_body) {\n\t\t\t\t_enabled = 1;\n\t\t\t\t_div100vh = document.createElement(\"div\"); // to solve mobile browser address bar show/hide resizing, we shouldn't rely on window.innerHeight. Instead, use a
with its height set to 100vh and measure that since that's what the scrolling is based on anyway and it's not affected by address bar showing/hiding.\n\t\t\t\t_div100vh.style.height = \"100vh\";\n\t\t\t\t_div100vh.style.position = \"absolute\";\n\t\t\t\t_refresh100vh();\n\t\t\t\t_rafBugFix();\n\t\t\t\tObserver.register(gsap);\n\t\t\t\t// isTouch is 0 if no touch, 1 if ONLY touch, and 2 if it can accommodate touch but also other types like mouse/pointer.\n\t\t\t\tScrollTrigger.isTouch = Observer.isTouch;\n\t\t\t\t_fixIOSBug = Observer.isTouch && /(iPad|iPhone|iPod|Mac)/g.test(navigator.userAgent); // since 2017, iOS has had a bug that causes event.clientX/Y to be inaccurate when a scroll occurs, thus we must alternate ignoring every other touchmove event to work around it. See https://bugs.webkit.org/show_bug.cgi?id=181954 and https://codepen.io/GreenSock/pen/ExbrPNa/087cef197dc35445a0951e8935c41503\n\t\t\t\t_ignoreMobileResize = Observer.isTouch === 1;\n\t\t\t\t_addListener(_win, \"wheel\", _onScroll); // mostly for 3rd party smooth scrolling libraries.\n\t\t\t\t_root = [_win, _doc, _docEl, _body];\n\t\t\t\tif (gsap.matchMedia) {\n\t\t\t\t\tScrollTrigger.matchMedia = vars => {\n\t\t\t\t\t\tlet mm = gsap.matchMedia(),\n\t\t\t\t\t\t\tp;\n\t\t\t\t\t\tfor (p in vars) {\n\t\t\t\t\t\t\tmm.add(p, vars[p]);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn mm;\n\t\t\t\t\t};\n\t\t\t\t\tgsap.addEventListener(\"matchMediaInit\", () => _revertAll());\n\t\t\t\t\tgsap.addEventListener(\"matchMediaRevert\", () => _revertRecorded());\n\t\t\t\t\tgsap.addEventListener(\"matchMedia\", () => {\n\t\t\t\t\t\t_refreshAll(0, 1);\n\t\t\t\t\t\t_dispatch(\"matchMedia\");\n\t\t\t\t\t});\n\t\t\t\t\tgsap.matchMedia().add(\"(orientation: portrait)\", () => { // when orientation changes, we should take new base measurements for the ignoreMobileResize feature.\n\t\t\t\t\t\t_setBaseDimensions();\n\t\t\t\t\t\treturn _setBaseDimensions;\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tconsole.warn(\"Requires GSAP 3.11.0 or later\");\n\t\t\t\t}\n\t\t\t\t_setBaseDimensions();\n\t\t\t\t_addListener(_doc, \"scroll\", _onScroll); // some browsers (like Chrome), the window stops dispatching scroll events on the window if you scroll really fast, but it's consistent on the document!\n\t\t\t\tlet bodyHasStyle = _body.hasAttribute(\"style\"),\n\t\t\t\t\tbodyStyle = _body.style,\n\t\t\t\t\tborder = bodyStyle.borderTopStyle,\n\t\t\t\t\tAnimationProto = gsap.core.Animation.prototype,\n\t\t\t\t\tbounds, i;\n\t\t\t\tAnimationProto.revert || Object.defineProperty(AnimationProto, \"revert\", { value: function() { return this.time(-0.01, true); }}); // only for backwards compatibility (Animation.revert() was added after 3.10.4)\n\t\t\t\tbodyStyle.borderTopStyle = \"solid\"; // works around an issue where a margin of a child element could throw off the bounds of the _body, making it seem like there's a margin when there actually isn't. The border ensures that the bounds are accurate.\n\t\t\t\tbounds = _getBounds(_body);\n\t\t\t\t_vertical.m = Math.round(bounds.top + _vertical.sc()) || 0; // accommodate the offset of the caused by margins and/or padding\n\t\t\t\t_horizontal.m = Math.round(bounds.left + _horizontal.sc()) || 0;\n\t\t\t\tborder ? (bodyStyle.borderTopStyle = border) : bodyStyle.removeProperty(\"border-top-style\");\n\t\t\t\tif (!bodyHasStyle) { // SSR frameworks like Next.js complain if this attribute gets added.\n\t\t\t\t\t_body.setAttribute(\"style\", \"\"); // it's not enough to just removeAttribute() - we must first set it to empty, otherwise Next.js complains.\n\t\t\t\t\t_body.removeAttribute(\"style\");\n\t\t\t\t}\n\t\t\t\t// TODO: (?) maybe move to leveraging the velocity mechanism in Observer and skip intervals.\n\t\t\t\t_syncInterval = setInterval(_sync, 250);\n\t\t\t\tgsap.delayedCall(0.5, () => _startup = 0);\n\t\t\t\t_addListener(_doc, \"touchcancel\", _passThrough); // some older Android devices intermittently stop dispatching \"touchmove\" events if we don't listen for \"touchcancel\" on the document.\n\t\t\t\t_addListener(_body, \"touchstart\", _passThrough); //works around Safari bug: https://gsap.com/forums/topic/21450-draggable-in-iframe-on-mobile-is-buggy/\n\t\t\t\t_multiListener(_addListener, _doc, \"pointerdown,touchstart,mousedown\", _pointerDownHandler);\n\t\t\t\t_multiListener(_addListener, _doc, \"pointerup,touchend,mouseup\", _pointerUpHandler);\n\t\t\t\t_transformProp = gsap.utils.checkPrefix(\"transform\");\n\t\t\t\t_stateProps.push(_transformProp);\n\t\t\t\t_coreInitted = _getTime();\n\t\t\t\t_resizeDelay = gsap.delayedCall(0.2, _refreshAll).pause();\n\t\t\t\t_autoRefresh = [_doc, \"visibilitychange\", () => {\n\t\t\t\t\tlet w = _win.innerWidth,\n\t\t\t\t\t\th = _win.innerHeight;\n\t\t\t\t\tif (_doc.hidden) {\n\t\t\t\t\t\t_prevWidth = w;\n\t\t\t\t\t\t_prevHeight = h;\n\t\t\t\t\t} else if (_prevWidth !== w || _prevHeight !== h) {\n\t\t\t\t\t\t_onResize();\n\t\t\t\t\t}\n\t\t\t\t}, _doc, \"DOMContentLoaded\", _refreshAll, _win, \"load\", _refreshAll, _win, \"resize\", _onResize];\n\t\t\t\t_iterateAutoRefresh(_addListener);\n\t\t\t\t_triggers.forEach(trigger => trigger.enable(0, 1));\n\t\t\t\tfor (i = 0; i < _scrollers.length; i+=3) {\n\t\t\t\t\t_wheelListener(_removeListener, _scrollers[i], _scrollers[i+1]);\n\t\t\t\t\t_wheelListener(_removeListener, _scrollers[i], _scrollers[i+2]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic config(vars) {\n\t\t(\"limitCallbacks\" in vars) && (_limitCallbacks = !!vars.limitCallbacks);\n\t\tlet ms = vars.syncInterval;\n\t\tms && clearInterval(_syncInterval) || ((_syncInterval = ms) && setInterval(_sync, ms));\n\t\t(\"ignoreMobileResize\" in vars) && (_ignoreMobileResize = ScrollTrigger.isTouch === 1 && vars.ignoreMobileResize);\n\t\tif (\"autoRefreshEvents\" in vars) {\n\t\t\t_iterateAutoRefresh(_removeListener) || _iterateAutoRefresh(_addListener, vars.autoRefreshEvents || \"none\");\n\t\t\t_ignoreResize = (vars.autoRefreshEvents + \"\").indexOf(\"resize\") === -1;\n\t\t}\n\t}\n\n\tstatic scrollerProxy(target, vars) {\n\t\tlet t = _getTarget(target),\n\t\t\ti = _scrollers.indexOf(t),\n\t\t\tisViewport = _isViewport(t);\n\t\tif (~i) {\n\t\t\t_scrollers.splice(i, isViewport ? 6 : 2);\n\t\t}\n\t\tif (vars) {\n\t\t\tisViewport ? _proxies.unshift(_win, vars, _body, vars, _docEl, vars) : _proxies.unshift(t, vars);\n\t\t}\n\t}\n\n\tstatic clearMatchMedia(query) {\n\t\t_triggers.forEach(t => t._ctx && t._ctx.query === query && t._ctx.kill(true, true));\n\t}\n\n\tstatic isInViewport(element, ratio, horizontal) {\n\t\tlet bounds = (_isString(element) ? _getTarget(element) : element).getBoundingClientRect(),\n\t\t\toffset = bounds[horizontal ? _width : _height] * ratio || 0;\n\t\treturn horizontal ? bounds.right - offset > 0 && bounds.left + offset < _win.innerWidth : bounds.bottom - offset > 0 && bounds.top + offset < _win.innerHeight;\n\t}\n\n\tstatic positionInViewport(element, referencePoint, horizontal) {\n\t\t_isString(element) && (element = _getTarget(element));\n\t\tlet bounds = element.getBoundingClientRect(),\n\t\t\tsize = bounds[horizontal ? _width : _height],\n\t\t\toffset = referencePoint == null ? size / 2 : ((referencePoint in _keywords) ? _keywords[referencePoint] * size : ~referencePoint.indexOf(\"%\") ? parseFloat(referencePoint) * size / 100 : parseFloat(referencePoint) || 0);\n\t\treturn horizontal ? (bounds.left + offset) / _win.innerWidth : (bounds.top + offset) / _win.innerHeight;\n\t}\n\n\tstatic killAll(allowListeners) {\n\t\t_triggers.slice(0).forEach(t => t.vars.id !== \"ScrollSmoother\" && t.kill());\n\t\tif (allowListeners !== true) {\n\t\t\tlet listeners = _listeners.killAll || [];\n\t\t\t_listeners = {};\n\t\t\tlisteners.forEach(f => f());\n\t\t}\n\t}\n\n}\n\nScrollTrigger.version = \"3.12.7\";\nScrollTrigger.saveStyles = targets => targets ? _toArray(targets).forEach(target => { // saved styles are recorded in a consecutive alternating Array, like [element, cssText, transform attribute, cache, matchMedia, ...]\n\tif (target && target.style) {\n\t\tlet i = _savedStyles.indexOf(target);\n\t\ti >= 0 && _savedStyles.splice(i, 5);\n\t\t_savedStyles.push(target, target.style.cssText, target.getBBox && target.getAttribute(\"transform\"), gsap.core.getCache(target), _context());\n\t}\n}) : _savedStyles;\nScrollTrigger.revert = (soft, media) => _revertAll(!soft, media);\nScrollTrigger.create = (vars, animation) => new ScrollTrigger(vars, animation);\nScrollTrigger.refresh = safe => safe ? _onResize(true) : (_coreInitted || ScrollTrigger.register()) && _refreshAll(true);\nScrollTrigger.update = force => ++_scrollers.cache && _updateAll(force === true ? 2 : 0);\nScrollTrigger.clearScrollMemory = _clearScrollMemory;\nScrollTrigger.maxScroll = (element, horizontal) => _maxScroll(element, horizontal ? _horizontal : _vertical);\nScrollTrigger.getScrollFunc = (element, horizontal) => _getScrollFunc(_getTarget(element), horizontal ? _horizontal : _vertical);\nScrollTrigger.getById = id => _ids[id];\nScrollTrigger.getAll = () => _triggers.filter(t => t.vars.id !== \"ScrollSmoother\"); // it's common for people to ScrollTrigger.getAll(t => t.kill()) on page routes, for example, and we don't want it to ruin smooth scrolling by killing the main ScrollSmoother one.\nScrollTrigger.isScrolling = () => !!_lastScrollTime;\nScrollTrigger.snapDirectional = _snapDirectional;\nScrollTrigger.addEventListener = (type, callback) => {\n\tlet a = _listeners[type] || (_listeners[type] = []);\n\t~a.indexOf(callback) || a.push(callback);\n};\nScrollTrigger.removeEventListener = (type, callback) => {\n\tlet a = _listeners[type],\n\t\ti = a && a.indexOf(callback);\n\ti >= 0 && a.splice(i, 1);\n};\nScrollTrigger.batch = (targets, vars) => {\n\tlet result = [],\n\t\tvarsCopy = {},\n\t\tinterval = vars.interval || 0.016,\n\t\tbatchMax = vars.batchMax || 1e9,\n\t\tproxyCallback = (type, callback) => {\n\t\t\tlet elements = [],\n\t\t\t\ttriggers = [],\n\t\t\t\tdelay = gsap.delayedCall(interval, () => {callback(elements, triggers); elements = []; triggers = [];}).pause();\n\t\t\treturn self => {\n\t\t\t\telements.length || delay.restart(true);\n\t\t\t\telements.push(self.trigger);\n\t\t\t\ttriggers.push(self);\n\t\t\t\tbatchMax <= elements.length && delay.progress(1);\n\t\t\t};\n\t\t},\n\t\tp;\n\tfor (p in vars) {\n\t\tvarsCopy[p] = (p.substr(0, 2) === \"on\" && _isFunction(vars[p]) && p !== \"onRefreshInit\") ? proxyCallback(p, vars[p]) : vars[p];\n\t}\n\tif (_isFunction(batchMax)) {\n\t\tbatchMax = batchMax();\n\t\t_addListener(ScrollTrigger, \"refresh\", () => batchMax = vars.batchMax());\n\t}\n\t_toArray(targets).forEach(target => {\n\t\tlet config = {};\n\t\tfor (p in varsCopy) {\n\t\t\tconfig[p] = varsCopy[p];\n\t\t}\n\t\tconfig.trigger = target;\n\t\tresult.push(ScrollTrigger.create(config));\n\t});\n\treturn result;\n}\n\n\n// to reduce file size. clamps the scroll and also returns a duration multiplier so that if the scroll gets chopped shorter, the duration gets curtailed as well (otherwise if you're very close to the top of the page, for example, and swipe up really fast, it'll suddenly slow down and take a long time to reach the top).\nlet _clampScrollAndGetDurationMultiplier = (scrollFunc, current, end, max) => {\n\t\tcurrent > max ? scrollFunc(max) : current < 0 && scrollFunc(0);\n\t\treturn end > max ? (max - current) / (end - current) : end < 0 ? current / (current - end) : 1;\n\t},\n\t_allowNativePanning = (target, direction) => {\n\t\tif (direction === true) {\n\t\t\ttarget.style.removeProperty(\"touch-action\");\n\t\t} else {\n\t\t\ttarget.style.touchAction = direction === true ? \"auto\" : direction ? \"pan-\" + direction + (Observer.isTouch ? \" pinch-zoom\" : \"\") : \"none\"; // note: Firefox doesn't support it pinch-zoom properly, at least in addition to a pan-x or pan-y.\n\t\t}\n\t\ttarget === _docEl && _allowNativePanning(_body, direction);\n\t},\n\t_overflow = {auto: 1, scroll: 1},\n\t_nestedScroll = ({event, target, axis}) => {\n\t\tlet node = (event.changedTouches ? event.changedTouches[0] : event).target,\n\t\t\tcache = node._gsap || gsap.core.getCache(node),\n\t\t\ttime = _getTime(), cs;\n\t\tif (!cache._isScrollT || time - cache._isScrollT > 2000) { // cache for 2 seconds to improve performance.\n\t\t\twhile (node && node !== _body && ((node.scrollHeight <= node.clientHeight && node.scrollWidth <= node.clientWidth) || !(_overflow[(cs = _getComputedStyle(node)).overflowY] || _overflow[cs.overflowX]))) node = node.parentNode;\n\t\t\tcache._isScroll = node && node !== target && !_isViewport(node) && (_overflow[(cs = _getComputedStyle(node)).overflowY] || _overflow[cs.overflowX]);\n\t\t\tcache._isScrollT = time;\n\t\t}\n\t\tif (cache._isScroll || axis === \"x\") {\n\t\t\tevent.stopPropagation();\n\t\t\tevent._gsapAllow = true;\n\t\t}\n\t},\n\t// capture events on scrollable elements INSIDE the and allow those by calling stopPropagation() when we find a scrollable ancestor\n\t_inputObserver = (target, type, inputs, nested) => Observer.create({\n\t\ttarget: target,\n\t\tcapture: true,\n\t\tdebounce: false,\n\t\tlockAxis: true,\n\t\ttype: type,\n\t\tonWheel: (nested = nested && _nestedScroll),\n\t\tonPress: nested,\n\t\tonDrag: nested,\n\t\tonScroll: nested,\n\t\tonEnable: () => inputs && _addListener(_doc, Observer.eventTypes[0], _captureInputs, false, true),\n\t\tonDisable: () => _removeListener(_doc, Observer.eventTypes[0], _captureInputs, true)\n\t}),\n\t_inputExp = /(input|label|select|textarea)/i,\n\t_inputIsFocused,\n\t_captureInputs = e => {\n\t\tlet isInput = _inputExp.test(e.target.tagName);\n\t\tif (isInput || _inputIsFocused) {\n\t\t\te._gsapAllow = true;\n\t\t\t_inputIsFocused = isInput;\n\t\t}\n\t},\n\t_getScrollNormalizer = vars => {\n\t\t_isObject(vars) || (vars = {});\n\t\tvars.preventDefault = vars.isNormalizer = vars.allowClicks = true;\n\t\tvars.type || (vars.type = \"wheel,touch\");\n\t\tvars.debounce = !!vars.debounce;\n\t\tvars.id = vars.id || \"normalizer\";\n\t\tlet {normalizeScrollX, momentum, allowNestedScroll, onRelease} = vars,\n\t\t\tself, maxY,\n\t\t\ttarget = _getTarget(vars.target) || _docEl,\n\t\t\tsmoother = gsap.core.globals().ScrollSmoother,\n\t\t\tsmootherInstance = smoother && smoother.get(),\n\t\t\tcontent = _fixIOSBug && ((vars.content && _getTarget(vars.content)) || (smootherInstance && vars.content !== false && !smootherInstance.smooth() && smootherInstance.content())),\n\t\t\tscrollFuncY = _getScrollFunc(target, _vertical),\n\t\t\tscrollFuncX = _getScrollFunc(target, _horizontal),\n\t\t\tscale = 1,\n\t\t\tinitialScale = (Observer.isTouch && _win.visualViewport ? _win.visualViewport.scale * _win.visualViewport.width : _win.outerWidth) / _win.innerWidth,\n\t\t\twheelRefresh = 0,\n\t\t\tresolveMomentumDuration = _isFunction(momentum) ? () => momentum(self) : () => momentum || 2.8,\n\t\t\tlastRefreshID, skipTouchMove,\n\t\t\tinputObserver = _inputObserver(target, vars.type, true, allowNestedScroll),\n\t\t\tresumeTouchMove = () => skipTouchMove = false,\n\t\t\tscrollClampX = _passThrough,\n\t\t\tscrollClampY = _passThrough,\n\t\t\tupdateClamps = () => {\n\t\t\t\tmaxY = _maxScroll(target, _vertical);\n\t\t\t\tscrollClampY = _clamp(_fixIOSBug ? 1 : 0, maxY);\n\t\t\t\tnormalizeScrollX && (scrollClampX = _clamp(0, _maxScroll(target, _horizontal)));\n\t\t\t\tlastRefreshID = _refreshID;\n\t\t\t},\n\t\t\tremoveContentOffset = () => {\n\t\t\t\tcontent._gsap.y = _round(parseFloat(content._gsap.y) + scrollFuncY.offset) + \"px\";\n\t\t\t\tcontent.style.transform = \"matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, \" + parseFloat(content._gsap.y) + \", 0, 1)\";\n\t\t\t\tscrollFuncY.offset = scrollFuncY.cacheID = 0;\n\t\t\t},\n\t\t\tignoreDrag = () => {\n\t\t\t\tif (skipTouchMove) {\n\t\t\t\t\trequestAnimationFrame(resumeTouchMove);\n\t\t\t\t\tlet offset = _round(self.deltaY / 2),\n\t\t\t\t\t\tscroll = scrollClampY(scrollFuncY.v - offset);\n\t\t\t\t\tif (content && scroll !== scrollFuncY.v + scrollFuncY.offset) {\n\t\t\t\t\t\tscrollFuncY.offset = scroll - scrollFuncY.v;\n\t\t\t\t\t\tlet y = _round((parseFloat(content && content._gsap.y) || 0) - scrollFuncY.offset);\n\t\t\t\t\t\tcontent.style.transform = \"matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, \" + y + \", 0, 1)\";\n\t\t\t\t\t\tcontent._gsap.y = y + \"px\";\n\t\t\t\t\t\tscrollFuncY.cacheID = _scrollers.cache;\n\t\t\t\t\t\t_updateAll();\n\t\t\t\t\t}\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tscrollFuncY.offset && removeContentOffset();\n\t\t\t\tskipTouchMove = true;\n\t\t\t},\n\t\t\ttween, startScrollX, startScrollY, onStopDelayedCall,\n\t\t\tonResize = () => { // if the window resizes, like on an iPhone which Apple FORCES the address bar to show/hide even if we event.preventDefault(), it may be scrolling too far now that the address bar is showing, so we must dynamically adjust the momentum tween.\n\t\t\t\tupdateClamps();\n\t\t\t\tif (tween.isActive() && tween.vars.scrollY > maxY) {\n\t\t\t\t\tscrollFuncY() > maxY ? tween.progress(1) && scrollFuncY(maxY) : tween.resetTo(\"scrollY\", maxY);\n\t\t\t\t}\n\t\t\t};\n\t\tcontent && gsap.set(content, {y: \"+=0\"}); // to ensure there's a cache (element._gsap)\n\t\tvars.ignoreCheck = e => (_fixIOSBug && e.type === \"touchmove\" && ignoreDrag(e)) || (scale > 1.05 && e.type !== \"touchstart\") || self.isGesturing || (e.touches && e.touches.length > 1);\n\t\tvars.onPress = () => {\n\t\t\tskipTouchMove = false;\n\t\t\tlet prevScale = scale;\n\t\t\tscale = _round(((_win.visualViewport && _win.visualViewport.scale) || 1) / initialScale);\n\t\t\ttween.pause();\n\t\t\tprevScale !== scale && _allowNativePanning(target, scale > 1.01 ? true : normalizeScrollX ? false : \"x\");\n\t\t\tstartScrollX = scrollFuncX();\n\t\t\tstartScrollY = scrollFuncY();\n\t\t\tupdateClamps();\n\t\t\tlastRefreshID = _refreshID;\n\t\t}\n\t\tvars.onRelease = vars.onGestureStart = (self, wasDragging) => {\n\t\t\tscrollFuncY.offset && removeContentOffset();\n\t\t\tif (!wasDragging) {\n\t\t\t\tonStopDelayedCall.restart(true);\n\t\t\t} else {\n\t\t\t\t_scrollers.cache++; // make sure we're pulling the non-cached value\n\t\t\t\t// alternate algorithm: durX = Math.min(6, Math.abs(self.velocityX / 800)),\tdur = Math.max(durX, Math.min(6, Math.abs(self.velocityY / 800))); dur = dur * (0.4 + (1 - _power4In(dur / 6)) * 0.6)) * (momentumSpeed || 1)\n\t\t\t\tlet dur = resolveMomentumDuration(),\n\t\t\t\t\tcurrentScroll, endScroll;\n\t\t\t\tif (normalizeScrollX) {\n\t\t\t\t\tcurrentScroll = scrollFuncX();\n\t\t\t\t\tendScroll = currentScroll + (dur * 0.05 * -self.velocityX) / 0.227; // the constant .227 is from power4(0.05). velocity is inverted because scrolling goes in the opposite direction.\n\t\t\t\t\tdur *= _clampScrollAndGetDurationMultiplier(scrollFuncX, currentScroll, endScroll, _maxScroll(target, _horizontal));\n\t\t\t\t\ttween.vars.scrollX = scrollClampX(endScroll);\n\t\t\t\t}\n\t\t\t\tcurrentScroll = scrollFuncY();\n\t\t\t\tendScroll = currentScroll + (dur * 0.05 * -self.velocityY) / 0.227; // the constant .227 is from power4(0.05)\n\t\t\t\tdur *= _clampScrollAndGetDurationMultiplier(scrollFuncY, currentScroll, endScroll, _maxScroll(target, _vertical));\n\t\t\t\ttween.vars.scrollY = scrollClampY(endScroll);\n\t\t\t\ttween.invalidate().duration(dur).play(0.01);\n\t\t\t\tif (_fixIOSBug && tween.vars.scrollY >= maxY || currentScroll >= maxY-1) { // iOS bug: it'll show the address bar but NOT fire the window \"resize\" event until the animation is done but we must protect against overshoot so we leverage an onUpdate to do so.\n\t\t\t\t\tgsap.to({}, {onUpdate: onResize, duration: dur});\n\t\t\t\t}\n\t\t\t}\n\t\t\tonRelease && onRelease(self);\n\t\t};\n\t\tvars.onWheel = () => {\n\t\t\ttween._ts && tween.pause();\n\t\t\tif (_getTime() - wheelRefresh > 1000) { // after 1 second, refresh the clamps otherwise that'll only happen when ScrollTrigger.refresh() is called or for touch-scrolling.\n\t\t\t\tlastRefreshID = 0;\n\t\t\t\twheelRefresh = _getTime();\n\t\t\t}\n\t\t};\n\t\tvars.onChange = (self, dx, dy, xArray, yArray) => {\n\t\t\t_refreshID !== lastRefreshID && updateClamps();\n\t\t\tdx && normalizeScrollX && scrollFuncX(scrollClampX(xArray[2] === dx ? startScrollX + (self.startX - self.x) : scrollFuncX() + dx - xArray[1])); // for more precision, we track pointer/touch movement from the start, otherwise it'll drift.\n\t\t\tif (dy) {\n\t\t\t\tscrollFuncY.offset && removeContentOffset();\n\t\t\t\tlet isTouch = yArray[2] === dy,\n\t\t\t\t\ty = isTouch ? startScrollY + self.startY - self.y : scrollFuncY() + dy - yArray[1],\n\t\t\t\t\tyClamped = scrollClampY(y);\n\t\t\t\tisTouch && y !== yClamped && (startScrollY += yClamped - y);\n\t\t\t\tscrollFuncY(yClamped);\n\t\t\t}\n\t\t\t(dy || dx) && _updateAll();\n\t\t};\n\t\tvars.onEnable = () => {\n\t\t\t_allowNativePanning(target, normalizeScrollX ? false : \"x\");\n\t\t\tScrollTrigger.addEventListener(\"refresh\", onResize);\n\t\t\t_addListener(_win, \"resize\", onResize);\n\t\t\tif (scrollFuncY.smooth) {\n\t\t\t\tscrollFuncY.target.style.scrollBehavior = \"auto\";\n\t\t\t\tscrollFuncY.smooth = scrollFuncX.smooth = false;\n\t\t\t}\n\t\t\tinputObserver.enable();\n\t\t};\n\t\tvars.onDisable = () => {\n\t\t\t_allowNativePanning(target, true);\n\t\t\t_removeListener(_win, \"resize\", onResize);\n\t\t\tScrollTrigger.removeEventListener(\"refresh\", onResize);\n\t\t\tinputObserver.kill();\n\t\t};\n\t\tvars.lockAxis = vars.lockAxis !== false;\n\t\tself = new Observer(vars);\n\t\tself.iOS = _fixIOSBug; // used in the Observer getCachedScroll() function to work around an iOS bug that wreaks havoc with TouchEvent.clientY if we allow scroll to go all the way back to 0.\n\t\t_fixIOSBug && !scrollFuncY() && scrollFuncY(1); // iOS bug causes event.clientY values to freak out (wildly inaccurate) if the scroll position is exactly 0.\n\t\t_fixIOSBug && gsap.ticker.add(_passThrough); // prevent the ticker from sleeping\n\t\tonStopDelayedCall = self._dc;\n\t\ttween = gsap.to(self, {ease: \"power4\", paused: true, inherit: false, scrollX: normalizeScrollX ? \"+=0.1\" : \"+=0\", scrollY: \"+=0.1\", modifiers: {scrollY: _interruptionTracker(scrollFuncY, scrollFuncY(), () => tween.pause())\t}, onUpdate: _updateAll, onComplete: onStopDelayedCall.vars.onComplete}); // we need the modifier to sense if the scroll position is altered outside of the momentum tween (like with a scrollTo tween) so we can pause() it to prevent conflicts.\n\t\treturn self;\n\t};\n\nScrollTrigger.sort = func => {\n\tif (_isFunction(func)) {\n\t\treturn _triggers.sort(func);\n\t}\n\tlet scroll = _win.pageYOffset || 0;\n\tScrollTrigger.getAll().forEach(t => t._sortY = t.trigger ? scroll + t.trigger.getBoundingClientRect().top : t.start + _win.innerHeight);\n\treturn _triggers.sort(func || ((a, b) => (a.vars.refreshPriority || 0) * -1e6 + (a.vars.containerAnimation ? 1e6 : a._sortY) - ((b.vars.containerAnimation ? 1e6 : b._sortY) + (b.vars.refreshPriority || 0) * -1e6))); // anything with a containerAnimation should refresh last.\n}\nScrollTrigger.observe = vars => new Observer(vars);\nScrollTrigger.normalizeScroll = vars => {\n\tif (typeof(vars) === \"undefined\") {\n\t\treturn _normalizer;\n\t}\n\tif (vars === true && _normalizer) {\n\t\treturn _normalizer.enable();\n\t}\n\tif (vars === false) {\n\t\t_normalizer && _normalizer.kill();\n\t\t_normalizer = vars;\n\t\treturn;\n\t}\n\tlet normalizer = vars instanceof Observer ? vars : _getScrollNormalizer(vars);\n\t_normalizer && _normalizer.target === normalizer.target && _normalizer.kill();\n\t_isViewport(normalizer.target) && (_normalizer = normalizer);\n\treturn normalizer;\n};\n\n\nScrollTrigger.core = { // smaller file size way to leverage in ScrollSmoother and Observer\n\t_getVelocityProp,\n\t_inputObserver,\n\t_scrollers,\n\t_proxies,\n\tbridge: {\n\t\t// when normalizeScroll sets the scroll position (ss = setScroll)\n\t\tss: () => {\n\t\t\t_lastScrollTime || _dispatch(\"scrollStart\");\n\t\t\t_lastScrollTime = _getTime();\n\t\t},\n\t\t// a way to get the _refreshing value in Observer\n\t\tref: () => _refreshing\n\t}\n};\n\n_getGSAP() && gsap.registerPlugin(ScrollTrigger);\n\nexport { ScrollTrigger as default };"],"names":["_getGSAP","gsap","window","registerPlugin","_getProxyProp","element","property","_proxies","indexOf","_isViewport","el","_root","_addListener","type","func","passive","capture","addEventListener","_removeListener","removeEventListener","_onScroll","_normalizer","isPressed","_scrollers","cache","_scrollCacheFunc","f","doNotCache","cachingFunc","value","_startup","_win","history","scrollRestoration","isNormalizing","v","Math","round","iOS","cacheID","_bridge","offset","_getTarget","t","self","_ctx","selector","utils","toArray","config","nullTargetWarn","console","warn","_getScrollFunc","s","sc","_doc","scrollingElement","_docEl","i","_vertical","push","prev","arguments","length","target","smooth","getProperty","_getVelocityProp","minTimeRefresh","useDelta","update","force","_getTime","min","t1","v2","v1","t2","dropToZeroTime","max","reset","getVelocity","latestValue","tOld","vOld","_getEvent","e","preventDefault","_gsapAllow","changedTouches","_getAbsoluteMax","a","abs","_setScrollTrigger","ScrollTrigger","core","globals","_integrate","data","bridge","scrollers","proxies","name","_initCore","_coreInitted","document","body","documentElement","_body","clamp","_context","context","_pointerType","_isTouch","Observer","isTouch","matchMedia","matches","navigator","maxTouchPoints","msMaxTouchPoints","_eventTypes","eventTypes","split","setTimeout","_observers","Date","now","_scrollLeft","_scrollTop","_horizontal","p","p2","os","os2","d","d2","scrollTo","pageXOffset","op","pageYOffset","init","vars","tolerance","dragMinimum","lineHeight","debounce","onStop","onStopDelay","ignore","wheelSpeed","event","onDragStart","onDragEnd","onDrag","onPress","onRelease","onRight","onLeft","onUp","onDown","onChangeX","onChangeY","onChange","onToggleX","onToggleY","onHover","onHoverEnd","onMove","ignoreCheck","isNormalizer","onGestureStart","onGestureEnd","onWheel","onEnable","onDisable","onClick","scrollSpeed","allowClicks","lockAxis","onLockAxis","clickCapture","onClickTime","_ignoreCheck","isPointerOrTouch","limitToTouch","pointerType","dx","deltaX","dy","deltaY","changedX","changedY","prevDeltaX","prevDeltaY","moved","dragged","locked","wheeled","id","onDelta","x","y","index","_vx","_vy","requestAnimationFrame","onTouchOrPointerDelta","axis","_onDrag","clientX","clientY","isDragging","startX","startY","_onGestureStart","touches","isGesturing","_onGestureEnd","onScroll","scrollFuncX","scrollFuncY","scrollX","scrollY","onStopDelayedCall","restart","_onWheel","multiplier","deltaMode","innerHeight","_onMove","_onHover","_onHoverEnd","_onClick","parseFloat","getComputedStyle","this","isViewport","ownerDoc","ownerDocument","_onPress","button","pause","_onRelease","isTrackingDrag","isNaN","wasDragging","isDragNotClick","eventData","delayedCall","defaultPrevented","click","createEvent","syntheticEvent","initMouseEvent","screenX","screenY","dispatchEvent","_dc","onStopFunc","enable","isEnabled","disable","filter","o","kill","revert","splice","version","create","register","getAll","slice","getById","_parseClamp","_isString","substr","_keepClamp","_pointerDownHandler","_pointerIsDown","_pointerUpHandler","_passThrough","_round","_windowExists","_getViewportDimension","dimensionProperty","_100vh","_getBoundsFunc","_winOffsets","width","innerWidth","height","_getBounds","_maxScroll","_iterateAutoRefresh","events","_autoRefresh","_isFunction","_isNumber","_isObject","_endAnimation","animation","reversed","progress","_callback","enabled","result","add","totalTime","callbackAnimation","_getComputedStyle","_setDefaults","obj","defaults","_getSize","_getLabelRatioArray","timeline","labels","duration","_snapDirectional","snapIncrementOrArray","snap","Array","isArray","sort","b","direction","threshold","snapped","_multiListener","types","callback","forEach","nonPassive","_wheelListener","scrollFunc","wheelHandler","_offsetToPx","size","eqIndex","relative","charAt","_keywords","_createMarker","container","matchWidthEl","containerAnimation","startColor","endColor","fontSize","indent","fontWeight","createElement","useFixedPosition","isScroller","parent","isStart","color","css","_right","_bottom","offsetWidth","_isStart","setAttribute","style","cssText","innerText","children","insertBefore","appendChild","_offset","_positionMarker","_sync","_lastScrollTime","_rafID","_updateAll","clientWidth","_dispatch","_setBaseDimensions","_baseScreenWidth","_baseScreenHeight","_onResize","_refreshing","_ignoreResize","fullscreenElement","webkitFullscreenElement","_ignoreMobileResize","_resizeDelay","_softRefresh","_refreshAll","_revertRecorded","media","_savedStyles","query","getBBox","uncache","_revertAll","trigger","_i","_triggers","_isReverted","_clearScrollMemory","_refreshingAll","rec","_scrollRestoration","_refresh100vh","_div100vh","offsetHeight","removeChild","_hideAllMarkers","hide","_toArray","display","_swapPinIn","pin","spacer","cs","spacerState","_gsap","swappedIn","_propNamesToCopy","spacerStyle","pinStyle","position","flexBasis","overflow","boxSizing","_width","_px","_height","_padding","_margin","_setState","parentNode","_getState","l","_stateProps","state","_parsePosition","scrollerSize","scroll","marker","markerScroller","scrollerBounds","borderWidth","scrollerMax","clampZeroProp","p1","time","seek","mapRange","scrollTrigger","start","end","bounds","localOffset","globalOffset","offsets","left","top","removeProperty","m","_caScrollDist","_reparent","_stOrig","_prefixExp","test","getCache","_interruptionTracker","getValueFunc","initialValue","onInterrupt","last1","last2","current","_shiftMarker","set","_getTweenCreator","scroller","getTween","change1","change2","tween","onComplete","modifiers","getScroll","checkForInterruption","prop","inherit","ratio","onUpdate","call","to","_clamp","_time2","_syncInterval","_transformProp","_prevWidth","_prevHeight","_sort","_suppressOverwrites","_fixIOSBug","_clampingMax","_limitCallbacks","_queueRefreshID","_primary","_time1","_enabled","_abs","_Right","_Left","_Top","_Bottom","_Width","_Height","withoutTransforms","xPercent","yPercent","rotation","rotationX","rotationY","scale","skewX","skewY","getBoundingClientRect","_markerDefaults","_defaults","toggleActions","anticipatePin","center","bottom","right","flipped","side","oppositeSide","_isFlipped","_ids","_listeners","_emptyArray","map","_refreshID","skipRevert","isRefreshing","refreshInits","scrollBehavior","refresh","_subPinOffset","horizontal","original","adjustPinSpacing","_dir","endClamp","_endClamp","startClamp","_startClamp","setPositions","render","onRefresh","_lastScroll","_direction","isUpdating","recordVelocity","concat","_capsExp","replace","toLowerCase","tweenTo","pinCache","snapFunc","scroll1","scroll2","markerStart","markerEnd","markerStartTrigger","markerEndTrigger","markerVars","executingOnRefresh","change","pinOriginalState","pinActiveState","pinState","pinGetter","pinSetter","pinStart","pinChange","spacingStart","markerStartSetter","pinMoves","markerEndSetter","snap1","snap2","scrubTween","scrubSmooth","snapDurClamp","snapDelayedCall","prevScroll","prevAnimProgress","caMarkerSetter","customRevertReturn","nodeType","toggleClass","onToggle","scrub","pinSpacing","invalidateOnRefresh","onScrubComplete","onSnapComplete","once","pinReparent","pinSpacer","fastScrollEnd","preventOverlaps","isToggle","scrollerCache","pinType","callbacks","onEnter","onLeave","onEnterBack","onLeaveBack","markers","onRefreshInit","getScrollerSize","_getSizeFunc","getScrollerOffsets","_getOffsetsFunc","lastSnap","lastRefresh","prevProgress","bind","refreshPriority","tweenScroll","scrubDuration","ease","totalProgress","paused","lazy","_initted","isReverted","immediateRender","snapTo","_getClosestLabel","_getLabelAtDirection","st","directional","delay","refreshedRecently","isActive","endValue","endScroll","velocity","naturalEnd","inertia","onStart","resetTo","_tTime","_tDur","stRevert","targets","className","nativeElement","spacerIsNative","classList","force3D","quickSetter","content","_makePositionable","oldOnUpdate","oldParams","onUpdateParams","eventCallback","apply","previous","next","temp","r","prevRefreshing","_swapPinOut","soft","pinOffset","invalidate","isVertical","override","curTrigger","curPin","oppositeScroll","initted","revertedPins","forcedOverflow","markerStartOffset","markerEndOffset","isFirstRefresh","otherPinOffset","parsedEnd","parsedEndTrigger","endTrigger","parsedStart","pinnedContainer","triggerIndex","unshift","_pinPush","normalize","_pinOffset","toUpperCase","ceil","_copyState","omitOffsets","endAnimation","labelToScroll","label","getTrailing","reverse","forceFake","toggleState","action","stateChanged","toggled","isAtMax","isTakingAction","clipped","_dp","_time","_start","n","newStart","newEnd","keepClamp","amount","allowAnimation","onKill","updateFunc","_queueRefreshAll","clearInterval","suppressOverwrites","_rafBugFix","userAgent","mm","bodyHasStyle","hasAttribute","bodyStyle","border","borderTopStyle","AnimationProto","Animation","prototype","Object","defineProperty","removeAttribute","setInterval","checkPrefix","w","h","hidden","limitCallbacks","ms","syncInterval","ignoreMobileResize","autoRefreshEvents","scrollerProxy","clearMatchMedia","isInViewport","positionInViewport","referencePoint","killAll","allowListeners","listeners","saveStyles","getAttribute","safe","clearScrollMemory","maxScroll","getScrollFunc","isScrolling","snapDirectional","batch","proxyCallback","elements","triggers","interval","batchMax","varsCopy","_clampScrollAndGetDurationMultiplier","_allowNativePanning","touchAction","_nestedScroll","node","_isScrollT","scrollHeight","clientHeight","scrollWidth","_overflow","overflowY","overflowX","_isScroll","stopPropagation","_inputObserver","inputs","nested","_captureInputs","_getScrollNormalizer","resumeTouchMove","skipTouchMove","updateClamps","maxY","scrollClampY","normalizeScrollX","scrollClampX","lastRefreshID","removeContentOffset","transform","onResize","startScrollX","startScrollY","momentum","allowNestedScroll","smoother","ScrollSmoother","smootherInstance","get","initialScale","visualViewport","outerWidth","wheelRefresh","resolveMomentumDuration","inputObserver","ignoreDrag","prevScale","currentScroll","dur","velocityX","velocityY","play","_ts","xArray","yArray","yClamped","ticker","_inputIsFocused","auto","_inputExp","isInput","tagName","_sortY","observe","normalizeScroll","normalizer","ss","ref"],"mappings":";;;;;;;;;mYAYY,SAAXA,WAAiBC,IAA4B,oBAAZC,SAA4BD,GAAOC,OAAOD,OAASA,GAAKE,gBAAkBF,GAkB3F,SAAhBG,EAAiBC,EAASC,UAAcC,GAASC,QAAQH,IAAYE,GAASA,GAASC,QAAQH,GAAW,GAAGC,GAC/F,SAAdG,EAAcC,YAASC,EAAMH,QAAQE,GACtB,SAAfE,EAAgBP,EAASQ,EAAMC,EAAMC,EAASC,UAAYX,EAAQY,iBAAiBJ,EAAMC,EAAM,CAACC,SAAqB,IAAZA,EAAmBC,UAAWA,IACrH,SAAlBE,EAAmBb,EAASQ,EAAMC,EAAME,UAAYX,EAAQc,oBAAoBN,EAAMC,IAAQE,GAGlF,SAAZI,WAAmBC,IAAeA,GAAYC,WAAcC,GAAWC,QACpD,SAAnBC,EAAoBC,EAAGC,GACJ,SAAdC,GAAcC,MACbA,GAAmB,IAAVA,EAAa,CACzBC,IAAaC,GAAKC,QAAQC,kBAAoB,cAC1CC,EAAgBb,IAAeA,GAAYC,UAC/CO,EAAQD,GAAYO,EAAIC,KAAKC,MAAMR,KAAWR,IAAeA,GAAYiB,IAAM,EAAI,GACnFZ,EAAEG,GACFD,GAAYW,QAAUhB,GAAWC,MACjCU,GAAiBM,EAAQ,KAAMX,QACrBF,GAAcJ,GAAWC,QAAUI,GAAYW,SAAWC,EAAQ,UAC5EZ,GAAYW,QAAUhB,GAAWC,MACjCI,GAAYO,EAAIT,YAEVE,GAAYO,EAAIP,GAAYa,cAEpCb,GAAYa,OAAS,EACdf,GAAKE,GAIA,SAAbc,EAAcC,EAAGC,UAAWA,GAAQA,EAAKC,MAAQD,EAAKC,KAAKC,UAAa7C,GAAK8C,MAAMC,SAASL,GAAG,KAAqB,iBAAPA,IAAoD,IAAjC1C,GAAKgD,SAASC,eAA2BC,QAAQC,KAAK,qBAAsBT,GAAK,MAEhM,SAAjBU,EAAkBhD,SAAUiD,IAAAA,EAAGC,IAAAA,GAC9B9C,EAAYJ,KAAaA,EAAUmD,GAAKC,kBAAoBC,QACxDC,EAAIpC,GAAWf,QAAQH,GAC1BoC,EAASc,IAAOK,GAAUL,GAAK,EAAI,GAClCI,IAAMA,EAAIpC,GAAWsC,KAAKxD,GAAW,GACvCkB,GAAWoC,EAAIlB,IAAW7B,EAAaP,EAAS,SAAUe,OACtD0C,EAAOvC,GAAWoC,EAAIlB,GACzB3B,EAAOgD,IAASvC,GAAWoC,EAAIlB,GAAUhB,EAAiBrB,EAAcC,EAASiD,IAAI,KAAU7C,EAAYJ,GAAWkD,EAAK9B,EAAiB,SAASI,UAAgBkC,UAAUC,OAAU3D,EAAQiD,GAAKzB,EAASxB,EAAQiD,cACxNxC,EAAKmD,OAAS5D,EACdyD,IAAShD,EAAKoD,OAAyD,WAAhDjE,GAAKkE,YAAY9D,EAAS,mBAC1CS,EAEW,SAAnBsD,EAAoBvC,EAAOwC,EAAgBC,GAOhC,SAATC,GAAU1C,EAAO2C,OACZ7B,EAAI8B,KACJD,GAAkBE,EAAT/B,EAAIgC,GAChBC,EAAKC,EACLA,EAAKhD,EACLiD,EAAKH,EACLA,EAAKhC,GACK2B,EACVO,GAAMhD,EAENgD,EAAKD,GAAM/C,EAAQ+C,IAAOjC,EAAImC,IAAOH,EAAKG,OAhBzCD,EAAKhD,EACR+C,EAAK/C,EACL8C,EAAKF,KACLK,EAAKH,EACLD,EAAML,GAAkB,GACxBU,EAAiB3C,KAAK4C,IAAI,IAAW,EAANN,SAsBzB,CAACH,OAAAA,GAAQU,MARP,SAARA,QAAgBL,EAAKC,EAAKP,EAAW,EAAIO,EAAIC,EAAKH,EAAK,GAQjCO,YAPR,SAAdA,YAAcC,OACTC,EAAON,EACVO,EAAOT,EACPjC,EAAI8B,YACJU,GAA+B,IAAhBA,GAAsBA,IAAgBN,GAAMN,GAAOY,GAC3DR,IAAOG,GAAeC,EAATpC,EAAImC,EAAuB,GAAKD,GAAMP,EAAWe,GAAQA,MAAWf,EAAW3B,EAAIgC,GAAMS,GAAQ,MAI7G,SAAZE,EAAaC,EAAGC,UACfA,IAAmBD,EAAEE,YAAcF,EAAEC,iBAC9BD,EAAEG,eAAiBH,EAAEG,eAAe,GAAKH,EAE/B,SAAlBI,EAAkBC,OACbZ,EAAM5C,KAAK4C,UAAL5C,KAAYwD,GACrBlB,EAAMtC,KAAKsC,UAALtC,KAAYwD,UACZxD,KAAKyD,IAAIb,IAAQ5C,KAAKyD,IAAInB,GAAOM,EAAMN,EAE3B,SAApBoB,KACCC,GAAgB9F,GAAK+F,KAAKC,UAAUF,gBACnBA,GAAcC,MA7FnB,SAAbE,iBACKF,EAAOD,GAAcC,KACxBG,EAAOH,EAAKI,QAAU,GACtBC,EAAYL,EAAKzE,WACjB+E,EAAUN,EAAKzF,SAChB8F,EAAUxC,WAAVwC,EAAkB9E,IAClB+E,EAAQzC,WAARyC,EAAgB/F,IAChBgB,GAAa8E,EACb9F,GAAW+F,EACX9D,EAAU,iBAAC+D,EAAM1E,UAAUsE,EAAKI,GAAM1E,IAoFCqE,GAE5B,SAAZM,EAAYR,UACX/F,GAAO+F,GAAQhG,KACVyG,IAAgBxG,IAA6B,oBAAdyG,UAA6BA,SAASC,OACzE5E,GAAO7B,OAEPwD,IADAF,GAAOkD,UACOE,gBACdC,GAAQrD,GAAKmD,KACbhG,EAAQ,CAACoB,GAAMyB,GAAME,GAAQmD,IACpB5G,GAAK8C,MAAM+D,MACpBC,GAAW9G,GAAK+F,KAAKgB,SAAW,aAChCC,GAAe,mBAAoBJ,GAAQ,UAAY,QAEvDK,GAAWC,EAASC,QAAUrF,GAAKsF,YAActF,GAAKsF,WAAW,oCAAoCC,QAAU,EAAK,iBAAkBvF,IAAmC,EAA3BwF,UAAUC,gBAAmD,EAA7BD,UAAUE,iBAAwB,EAAI,EACpNC,GAAcP,EAASQ,YAAc,iBAAkBjE,GAAS,4CAAgD,kBAAmBA,GAAkD,kDAAxC,uCAA2FkE,MAAM,KAC9OC,WAAW,kBAAM/F,EAAW,GAAG,KAC/BgE,IACAW,GAAe,GAETA,GAzHT,IAAIxG,GAAMwG,GAAsB1E,GAAMyB,GAAME,GAAQmD,GAAOK,GAAUD,GAAclB,GAAepF,EAAOU,GAAaqG,GAAaX,GAElIjF,EAAW,EACXgG,GAAa,GACbvG,GAAa,GACbhB,GAAW,GACXkE,GAAWsD,KAAKC,IAChBxF,EAAU,iBAAC+D,EAAM1E,UAAUA,GAgB3BoG,EAAc,aACdC,EAAa,YAoBbC,GAAc,CAAC7E,EAAG2E,EAAaG,EAAG,OAAQC,GAAI,OAAQC,GAAI,QAASC,IAAK,QAASC,EAAG,QAASC,GAAI,QAAS7C,EAAG,IAAKrC,GAAI9B,EAAiB,SAASI,UAAgBkC,UAAUC,OAASjC,GAAK2G,SAAS7G,EAAO+B,GAAUL,MAAQxB,GAAK4G,aAAenF,GAAKyE,IAAgBvE,GAAOuE,IAAgBpB,GAAMoB,IAAgB,KAChTrE,GAAY,CAACN,EAAG4E,EAAYE,EAAG,MAAOC,GAAI,MAAOC,GAAI,SAAUC,IAAK,SAAUC,EAAG,SAAUC,GAAI,SAAU7C,EAAG,IAAKgD,GAAIT,GAAa5E,GAAI9B,EAAiB,SAASI,UAAgBkC,UAAUC,OAASjC,GAAK2G,SAASP,GAAY5E,KAAM1B,GAASE,GAAK8G,aAAerF,GAAK0E,IAAexE,GAAOwE,IAAerB,GAAMqB,IAAe,KA+EhUC,GAAYS,GAAKhF,GACjBrC,GAAWC,MAAQ,MAEN2F,sBAKZ2B,KAAA,cAAKC,GACJtC,IAAgBD,EAAUvG,KAASkD,QAAQC,KAAK,wCAChD2C,IAAiBD,QACZkD,EAA6bD,EAA7bC,UAAWC,EAAkbF,EAAlbE,YAAapI,EAAqakI,EAAralI,KAAMoD,EAA+Z8E,EAA/Z9E,OAAQiF,EAAuZH,EAAvZG,WAAYC,EAA2YJ,EAA3YI,SAAU3D,EAAiYuD,EAAjYvD,eAAgB4D,EAAiXL,EAAjXK,OAAQC,EAAyWN,EAAzWM,YAAaC,EAA4VP,EAA5VO,OAAQC,EAAoVR,EAApVQ,WAAYC,EAAwUT,EAAxUS,MAAOC,EAAiUV,EAAjUU,YAAaC,EAAoTX,EAApTW,UAAWC,EAAySZ,EAAzSY,OAAQC,EAAiSb,EAAjSa,QAASC,EAAwRd,EAAxRc,UAAWC,EAA6Qf,EAA7Qe,QAASC,EAAoQhB,EAApQgB,OAAQC,EAA4PjB,EAA5PiB,KAAMC,EAAsPlB,EAAtPkB,OAAQC,EAA8OnB,EAA9OmB,UAAWC,EAAmOpB,EAAnOoB,UAAWC,EAAwNrB,EAAxNqB,SAAUC,EAA8MtB,EAA9MsB,UAAWC,EAAmMvB,EAAnMuB,UAAWC,EAAwLxB,EAAxLwB,QAASC,EAA+KzB,EAA/KyB,WAAYC,EAAmK1B,EAAnK0B,OAAQC,EAA2J3B,EAA3J2B,YAAaC,EAA8I5B,EAA9I4B,aAAcC,EAAgI7B,EAAhI6B,eAAgBC,EAAgH9B,EAAhH8B,aAAcC,EAAkG/B,EAAlG+B,QAASC,EAAyFhC,EAAzFgC,SAAUC,EAA+EjC,EAA/EiC,UAAWC,EAAoElC,EAApEkC,QAASC,EAA2DnC,EAA3DmC,YAAalK,EAA8C+H,EAA9C/H,QAASmK,EAAqCpC,EAArCoC,YAAaC,EAAwBrC,EAAxBqC,SAAUC,EAActC,EAAdsC,WA0Bpa,SAAfC,YAAqBC,GAAc9G,KACpB,SAAf+G,GAAgBjG,EAAGkG,UAAsB7I,GAAK4G,MAAQjE,IAAO+D,IAAWA,EAAO9I,QAAQ+E,EAAEtB,SAAawH,GAAoBC,IAAkC,UAAlBnG,EAAEoG,aAA6BjB,GAAeA,EAAYnF,EAAGkG,GAO9L,SAATlH,SACKqH,EAAKhJ,GAAKiJ,OAASlG,EAAgBkG,IACtCC,EAAKlJ,GAAKmJ,OAASpG,EAAgBoG,IACnCC,EAAW5J,KAAKyD,IAAI+F,IAAO5C,EAC3BiD,EAAW7J,KAAKyD,IAAIiG,IAAO9C,EAC5BoB,IAAa4B,GAAYC,IAAa7B,EAASxH,GAAMgJ,EAAIE,EAAID,GAAQE,IACjEC,IACHlC,GAAyB,EAAdlH,GAAKiJ,QAAc/B,EAAQlH,IACtCmH,GAAUnH,GAAKiJ,OAAS,GAAK9B,EAAOnH,IACpCsH,GAAaA,EAAUtH,IACvByH,GAAezH,GAAKiJ,OAAS,GAAQK,GAAa,GAAO7B,EAAUzH,IACnEsJ,GAAatJ,GAAKiJ,OAClBA,GAAO,GAAKA,GAAO,GAAKA,GAAO,GAAK,GAEjCI,IACHhC,GAAwB,EAAdrH,GAAKmJ,QAAc9B,EAAOrH,IACpCoH,GAAQpH,GAAKmJ,OAAS,GAAK/B,EAAKpH,IAChCuH,GAAaA,EAAUvH,IACvB0H,GAAe1H,GAAKmJ,OAAS,GAAQI,GAAa,GAAO7B,EAAU1H,IACnEuJ,GAAavJ,GAAKmJ,OAClBA,GAAO,GAAKA,GAAO,GAAKA,GAAO,GAAK,IAEjCK,IAASC,MACZ5B,GAAUA,EAAO7H,IACbyJ,KACH5C,GAA2B,IAAZ4C,IAAiB5C,EAAY7G,IAC5C+G,GAAUA,EAAO/G,IACjByJ,GAAU,GAEXD,IAAQ,GAETE,MAAYA,IAAS,IAAUjB,GAAcA,EAAWzI,IACpD2J,KACHzB,EAAQlI,IACR2J,IAAU,GAEXC,GAAK,EAEI,SAAVC,GAAWC,EAAGC,EAAGC,GAChBf,GAAOe,IAAUF,EACjBX,GAAOa,IAAUD,EACjB/J,GAAKiK,IAAItI,OAAOmI,GAChB9J,GAAKkK,IAAIvI,OAAOoI,GAChBxD,EAAkBqD,GAAPA,IAAYO,sBAAsBxI,IAAWA,KAEjC,SAAxByI,GAAyBN,EAAGC,GACvBvB,IAAa6B,KAChBrK,GAAKqK,KAAOA,GAAO7K,KAAKyD,IAAI6G,GAAKtK,KAAKyD,IAAI8G,GAAK,IAAM,IACrDL,IAAS,GAEG,MAATW,KACHpB,GAAO,IAAMa,EACb9J,GAAKiK,IAAItI,OAAOmI,GAAG,IAEP,MAATO,KACHlB,GAAO,IAAMY,EACb/J,GAAKkK,IAAIvI,OAAOoI,GAAG,IAEpBxD,EAAkBqD,GAAPA,IAAYO,sBAAsBxI,IAAWA,KAE/C,SAAV2I,GAAU3H,OACLiG,GAAajG,EAAG,QAEhBmH,GADJnH,EAAID,EAAUC,EAAGC,IACP2H,QACTR,EAAIpH,EAAE6H,QACNxB,EAAKc,EAAI9J,GAAK8J,EACdZ,EAAKa,EAAI/J,GAAK+J,EACdU,EAAazK,GAAKyK,WACnBzK,GAAK8J,EAAIA,EACT9J,GAAK+J,EAAIA,GACLU,IAAgBzB,GAAME,KAAQ1J,KAAKyD,IAAIjD,GAAK0K,OAASZ,IAAMzD,GAAe7G,KAAKyD,IAAIjD,GAAK2K,OAASZ,IAAM1D,MAC1GoD,GAAUgB,EAAa,EAAI,EAC3BA,IAAezK,GAAKyK,YAAa,GACjCL,GAAsBpB,EAAIE,KAiDV,SAAlB0B,GAAkBjI,UAAKA,EAAEkI,SAA8B,EAAnBlI,EAAEkI,QAAQzJ,SAAepB,GAAK8K,aAAc,IAAS9C,EAAerF,EAAG3C,GAAKyK,YAChG,SAAhBM,YAAuB/K,GAAK8K,aAAc,IAAU7C,EAAajI,IACtD,SAAXgL,GAAWrI,OACNiG,GAAajG,QACbmH,EAAImB,KACPlB,EAAImB,KACLrB,IAASC,EAAIqB,IAAW7C,GAAcyB,EAAIqB,IAAW9C,EAAa,GAClE6C,GAAUrB,EACVsB,GAAUrB,EACVvD,GAAU6E,GAAkBC,SAAQ,IAE1B,SAAXC,GAAW5I,OACNiG,GAAajG,IACjBA,EAAID,EAAUC,EAAGC,GACjBsF,IAAYyB,IAAU,OAClB6B,GAA8B,IAAhB7I,EAAE8I,UAAkBnF,EAA6B,IAAhB3D,EAAE8I,UAAkBtM,GAAKuM,YAAc,GAAK/E,EAC/FkD,GAAQlH,EAAEsG,OAASuC,EAAY7I,EAAEwG,OAASqC,EAAY,GACtDhF,IAAWuB,GAAgBsD,GAAkBC,SAAQ,IAE5C,SAAVK,GAAUhJ,OACLiG,GAAajG,QACbmH,EAAInH,EAAE4H,QACTR,EAAIpH,EAAE6H,QACNxB,EAAKc,EAAI9J,GAAK8J,EACdZ,EAAKa,EAAI/J,GAAK+J,EACf/J,GAAK8J,EAAIA,EACT9J,GAAK+J,EAAIA,EACTP,IAAQ,EACRhD,GAAU6E,GAAkBC,SAAQ,IACnCtC,GAAME,IAAOkB,GAAsBpB,EAAIE,IAE9B,SAAX0C,GAAWjJ,GAAM3C,GAAK4G,MAAQjE,EAAGgF,EAAQ3H,IAC3B,SAAd6L,GAAclJ,GAAM3C,GAAK4G,MAAQjE,EAAGiF,EAAW5H,IACpC,SAAX8L,GAAWnJ,UAAKiG,GAAajG,IAAOD,EAAUC,EAAGC,IAAmByF,EAAQrI,SA5LxEqB,OAASA,EAASvB,EAAWuB,IAAWP,QACxCqF,KAAOA,EACDO,EAAXA,GAAoBrJ,GAAK8C,MAAMC,QAAQsG,GACvCN,EAAYA,GAAa,KACzBC,EAAcA,GAAe,EAC7BM,EAAaA,GAAc,EAC3B2B,EAAcA,GAAe,EAC7BrK,EAAOA,GAAQ,sBACfsI,GAAwB,IAAbA,EACID,EAAfA,GAA4ByF,WAAW5M,GAAK6M,iBAAiB/H,IAAOqC,aAAe,OAC/EsD,GAAIyB,GAAmB5B,GAASD,GAAOG,GAASD,GAAQW,GAC3DrK,GAAOiM,KACP3C,GAAa,EACbC,GAAa,EACbpL,GAAUgI,EAAKhI,UAAayE,IAAmC,IAAjBuD,EAAKhI,QACnD8M,GAAcxK,EAAeY,EAAQkE,IACrC2F,GAAczK,EAAeY,EAAQL,IACrCmK,GAAUF,KACVG,GAAUF,KACVpC,IAAgB7K,EAAKL,QAAQ,YAAcK,EAAKL,QAAQ,YAAiC,gBAAnBkH,GAAY,GAClFoH,GAAarO,EAAYwD,GACzB8K,GAAW9K,EAAO+K,eAAiBxL,GACnCqI,GAAS,CAAC,EAAG,EAAG,GAChBE,GAAS,CAAC,EAAG,EAAG,GAChBR,GAAc,EAqFd0D,GAAWrM,GAAKgH,QAAU,SAAArE,GACrBiG,GAAajG,EAAG,IAAOA,GAAKA,EAAE2J,SAClCtM,GAAKqK,KAAOA,GAAO,KACnBgB,GAAkBkB,QAClBvM,GAAKtB,WAAY,EACjBiE,EAAID,EAAUC,GACd2G,GAAaC,GAAa,EAC1BvJ,GAAK0K,OAAS1K,GAAK8J,EAAInH,EAAE4H,QACzBvK,GAAK2K,OAAS3K,GAAK+J,EAAIpH,EAAE6H,QACzBxK,GAAKiK,IAAI5H,QACTrC,GAAKkK,IAAI7H,QACTrE,EAAa+J,EAAe1G,EAAS8K,GAAUrH,GAAY,GAAIwF,GAASnM,IAAS,GACjF6B,GAAKiJ,OAASjJ,GAAKmJ,OAAS,EAC5BnC,GAAWA,EAAQhH,MAEpBwM,GAAaxM,GAAKiH,UAAY,SAAAtE,OACzBiG,GAAajG,EAAG,IACpBrE,EAAgByJ,EAAe1G,EAAS8K,GAAUrH,GAAY,GAAIwF,IAAS,OACvEmC,GAAkBC,MAAM1M,GAAK+J,EAAI/J,GAAK2K,QACzCgC,EAAc3M,GAAKyK,WACnBmC,EAAiBD,IAAiD,EAAjCnN,KAAKyD,IAAIjD,GAAK8J,EAAI9J,GAAK0K,SAAgD,EAAjClL,KAAKyD,IAAIjD,GAAK+J,EAAI/J,GAAK2K,SAC9FkC,EAAYnK,EAAUC,IAClBiK,GAAkBH,IACtBzM,GAAKiK,IAAI5H,QACTrC,GAAKkK,IAAI7H,QAELO,GAAkB2F,GACrBlL,GAAKyP,YAAY,IAAM,cACS,IAA3BjL,KAAa8G,KAAsBhG,EAAEoK,oBACpCpK,EAAEtB,OAAO2L,MACZrK,EAAEtB,OAAO2L,aACH,GAAIb,GAASc,YAAa,KAC5BC,EAAiBf,GAASc,YAAY,eAC1CC,EAAeC,eAAe,SAAS,GAAM,EAAMhO,GAAM,EAAG0N,EAAUO,QAASP,EAAUQ,QAASR,EAAUtC,QAASsC,EAAUrC,SAAS,GAAO,GAAO,GAAO,EAAO,EAAG,MACvK7H,EAAEtB,OAAOiM,cAAcJ,OAM5BlN,GAAKyK,WAAazK,GAAK8K,YAAc9K,GAAKtB,WAAY,EACtD8H,GAAUmG,IAAgB5E,GAAgBsD,GAAkBC,SAAQ,GACpE7B,IAAW9H,KACXmF,GAAa6F,GAAe7F,EAAU9G,IACtCiH,GAAaA,EAAUjH,GAAM4M,KAqC/BvB,GAAoBrL,GAAKuN,IAAMlQ,GAAKyP,YAAYrG,GAAe,IAnKjD,SAAb+G,aACCxN,GAAKiK,IAAI5H,QACTrC,GAAKkK,IAAI7H,QACTgJ,GAAkBkB,QAClB/F,GAAUA,EAAOxG,MA+J8DuM,QAEjFvM,GAAKiJ,OAASjJ,GAAKmJ,OAAS,EAC5BnJ,GAAKiK,IAAMzI,EAAiB,EAAG,IAAI,GACnCxB,GAAKkK,IAAM1I,EAAiB,EAAG,IAAI,GACnCxB,GAAKmL,QAAUF,GACfjL,GAAKoL,QAAUF,GACflL,GAAKyK,WAAazK,GAAK8K,YAAc9K,GAAKtB,WAAY,EACtDyF,GAAS8H,MACTjM,GAAKyN,OAAS,SAAA9K,UACR3C,GAAK0N,YACT1P,EAAakO,GAAaC,GAAW9K,EAAQ,SAAU7C,GAC7B,GAA1BP,EAAKL,QAAQ,WAAkBI,EAAakO,GAAaC,GAAW9K,EAAQ,SAAU2J,GAAU7M,GAASC,GAChF,GAAzBH,EAAKL,QAAQ,UAAiBI,EAAaqD,EAAQ,QAASkK,GAAUpN,GAASC,IACjD,GAAzBH,EAAKL,QAAQ,UAAiB0G,IAAwC,GAA3BrG,EAAKL,QAAQ,cAC5DI,EAAaqD,EAAQyD,GAAY,GAAIuH,GAAUlO,GAASC,GACxDJ,EAAamO,GAAUrH,GAAY,GAAI0H,IACvCxO,EAAamO,GAAUrH,GAAY,GAAI0H,IACvCjE,GAAevK,EAAaqD,EAAQ,QAASqH,IAAc,GAAM,GACjEL,GAAWrK,EAAaqD,EAAQ,QAASyK,IACzC9D,GAAkBhK,EAAamO,GAAU,eAAgBvB,IACzD3C,GAAgBjK,EAAamO,GAAU,aAAcpB,IACrDpD,GAAW3J,EAAaqD,EAAQgD,GAAe,QAASuH,IACxDhE,GAAc5J,EAAaqD,EAAQgD,GAAe,QAASwH,IAC3DhE,GAAU7J,EAAaqD,EAAQgD,GAAe,OAAQsH,KAEvD3L,GAAK0N,WAAY,EACjB1N,GAAKyK,WAAazK,GAAK8K,YAAc9K,GAAKtB,UAAY8K,GAAQC,IAAU,EACxEzJ,GAAKiK,IAAI5H,QACTrC,GAAKkK,IAAI7H,QACT8I,GAAUF,KACVG,GAAUF,KACVvI,GAAKA,EAAE1E,MAAQoO,GAAS1J,GACxBwF,GAAYA,EAASnI,KAEfA,IAERA,GAAK2N,QAAU,WACV3N,GAAK0N,YAERxI,GAAW0I,OAAO,SAAAC,UAAKA,IAAM7N,IAAQnC,EAAYgQ,EAAExM,UAASD,QAAU9C,EAAgB4N,GAAaC,GAAW9K,EAAQ,SAAU7C,GAC5HwB,GAAKtB,YACRsB,GAAKiK,IAAI5H,QACTrC,GAAKkK,IAAI7H,QACT/D,EAAgByJ,EAAe1G,EAAS8K,GAAUrH,GAAY,GAAIwF,IAAS,IAE5EhM,EAAgB4N,GAAaC,GAAW9K,EAAQ,SAAU2J,GAAU5M,GACpEE,EAAgB+C,EAAQ,QAASkK,GAAUnN,GAC3CE,EAAgB+C,EAAQyD,GAAY,GAAIuH,GAAUjO,GAClDE,EAAgB6N,GAAUrH,GAAY,GAAI0H,IAC1ClO,EAAgB6N,GAAUrH,GAAY,GAAI0H,IAC1ClO,EAAgB+C,EAAQ,QAASqH,IAAc,GAC/CpK,EAAgB+C,EAAQ,QAASyK,IACjCxN,EAAgB6N,GAAU,eAAgBvB,IAC1CtM,EAAgB6N,GAAU,aAAcpB,IACxCzM,EAAgB+C,EAAQgD,GAAe,QAASuH,IAChDtN,EAAgB+C,EAAQgD,GAAe,QAASwH,IAChDvN,EAAgB+C,EAAQgD,GAAe,OAAQsH,IAC/C3L,GAAK0N,UAAY1N,GAAKtB,UAAYsB,GAAKyK,YAAa,EACpDrC,GAAaA,EAAUpI,MAIzBA,GAAK8N,KAAO9N,GAAK+N,OAAS,WACzB/N,GAAK2N,cACD5M,EAAImE,GAAWtH,QAAQoC,IACtB,GAALe,GAAUmE,GAAW8I,OAAOjN,EAAG,GAC/BtC,KAAgBuB,KAASvB,GAAc,IAGxCyG,GAAWjE,KAAKjB,IAChB+H,GAAgBlK,EAAYwD,KAAY5C,GAAcuB,IAEtDA,GAAKyN,OAAO7G,8JAILqF,KAAKhC,IAAI3H,2DAGT2J,KAAK/B,IAAI5H,8CAtRL6D,QACND,KAAKC,GA0RZ5B,EAAS0J,QAAU,SACnB1J,EAAS2J,OAAS,SAAA/H,UAAQ,IAAI5B,EAAS4B,IACvC5B,EAAS4J,SAAWvK,EACpBW,EAAS6J,OAAS,kBAAMlJ,GAAWmJ,SACnC9J,EAAS+J,QAAU,SAAA1E,UAAM1E,GAAW0I,OAAO,SAAAC,UAAKA,EAAE1H,KAAKyD,KAAOA,IAAI,IAElExM,KAAcC,GAAKE,eAAegH,GCxZnB,SAAdgK,GAAetP,EAAOhB,EAAM+B,OACvBkE,EAASsK,GAAUvP,KAAkC,WAAvBA,EAAMwP,OAAO,EAAG,KAA2C,EAAxBxP,EAAMrB,QAAQ,eACnFoC,EAAK,IAAM/B,EAAO,SAAWiG,GACdjF,EAAMwP,OAAO,EAAGxP,EAAMmC,OAAS,GAAKnC,EAEvC,SAAbyP,GAAczP,EAAOiF,UAAUA,GAAWsK,GAAUvP,IAAiC,WAAvBA,EAAMwP,OAAO,EAAG,GAA4CxP,EAAzB,SAAWA,EAAQ,IAE9F,SAAtB0P,YAA4BC,GAAiB,EACzB,SAApBC,YAA0BD,GAAiB,EAC5B,SAAfE,GAAevP,UAAKA,EACX,SAATwP,GAAS9P,UAASO,KAAKC,MAAc,IAARR,GAAkB,KAAU,EACzC,SAAhB+P,WAAyC,oBAAZ1R,OAClB,SAAXF,YAAiBC,IAAS2R,OAAoB3R,GAAOC,OAAOD,OAASA,GAAKE,gBAAkBF,GAC9E,SAAdQ,GAAc8E,YAAQ5E,EAAMH,QAAQ+E,GACZ,SAAxBsM,GAAwBC,UAA4C,WAAtBA,EAAiCC,EAAShQ,GAAK,QAAU+P,KAAuBpO,GAAO,SAAWoO,IAAsBjL,GAAM,SAAWiL,GACtK,SAAjBE,GAAiB3R,UAAWD,EAAcC,EAAS,2BAA6BI,GAAYJ,GAAW,kBAAO4R,GAAYC,MAAQnQ,GAAKoQ,WAAYF,GAAYG,OAASL,EAAeE,IAAgB,kBAAMI,GAAWhS,KAG3M,SAAbiS,GAAcjS,SAAUiD,IAAAA,EAAGmF,IAAAA,GAAID,IAAAA,EAAG5C,IAAAA,SAAOxD,KAAK4C,IAAI,GAAI1B,EAAI,SAAWmF,KAAQ7C,EAAIxF,EAAcC,EAASiD,IAAMsC,IAAMoM,GAAe3R,EAAf2R,GAA0BxJ,GAAK/H,GAAYJ,IAAYqD,GAAOJ,IAAMuD,GAAMvD,IAAMuO,GAAsBpJ,GAAMpI,EAAQiD,GAAKjD,EAAQ,SAAWoI,IAC1O,SAAtB8J,GAAuBzR,EAAM0R,OACvB,IAAI7O,EAAI,EAAGA,EAAI8O,EAAazO,OAAQL,GAAK,EAC3C6O,KAAWA,EAAOhS,QAAQiS,EAAa9O,EAAE,KAAQ7C,EAAK2R,EAAa9O,GAAI8O,EAAa9O,EAAE,GAAI8O,EAAa9O,EAAE,IAI/F,SAAd+O,GAAc7Q,SAA2B,mBAAXA,EAClB,SAAZ8Q,GAAY9Q,SAA2B,iBAAXA,EAChB,SAAZ+Q,GAAY/Q,SAA2B,iBAAXA,EACZ,SAAhBgR,GAAiBC,EAAWC,EAAU5D,UAAU2D,GAAaA,EAAUE,SAASD,EAAW,EAAI,IAAM5D,GAAS2D,EAAU3D,QAC5G,SAAZ8D,GAAarQ,EAAM9B,MACd8B,EAAKsQ,QAAS,KACbC,EAASvQ,EAAKC,KAAOD,EAAKC,KAAKuQ,IAAI,kBAAMtS,EAAK8B,KAAS9B,EAAK8B,GAChEuQ,GAAUA,EAAOE,YAAczQ,EAAK0Q,kBAAoBH,IAmBtC,SAApBI,GAAoBlT,UAAW0B,GAAK6M,iBAAiBvO,GAKtC,SAAfmT,GAAgBC,EAAKC,OACf,IAAItL,KAAKsL,EACZtL,KAAKqL,IAASA,EAAIrL,GAAKsL,EAAStL,WAE3BqL,EAQG,SAAXE,GAAYtT,SAAUoI,IAAAA,UAAQpI,EAAQ,SAAWoI,IAAOpI,EAAQ,SAAWoI,IAAO,EAC5D,SAAtBmL,GAAsBC,OAIpBzL,EAHGxC,EAAI,GACPkO,EAASD,EAASC,OAClBC,EAAWF,EAASE,eAEhB3L,KAAK0L,EACTlO,EAAE/B,KAAKiQ,EAAO1L,GAAK2L,UAEbnO,EAGW,SAAnBoO,GAAmBC,OACdC,EAAOjU,GAAK8C,MAAMmR,KAAKD,GAC1BrO,EAAIuO,MAAMC,QAAQH,IAAyBA,EAAqBhD,MAAM,GAAGoD,KAAK,SAACzO,EAAG0O,UAAM1O,EAAI0O,WACtF1O,EAAI,SAAC/D,EAAO0S,EAAWC,OACzB7Q,cADyB6Q,IAAAA,EAAW,OAEnCD,SACGL,EAAKrS,MAEG,EAAZ0S,EAAe,KAClB1S,GAAS2S,EACJ7Q,EAAI,EAAGA,EAAIiC,EAAE5B,OAAQL,OACrBiC,EAAEjC,IAAM9B,SACJ+D,EAAEjC,UAGJiC,EAAEjC,EAAE,OAEXA,EAAIiC,EAAE5B,OACNnC,GAAS2S,EACF7Q,QACFiC,EAAEjC,IAAM9B,SACJ+D,EAAEjC,UAILiC,EAAE,IACN,SAAC/D,EAAO0S,EAAWC,YAAAA,IAAAA,EAAW,UAC7BC,EAAUP,EAAKrS,UACX0S,GAAanS,KAAKyD,IAAI4O,EAAU5S,GAAS2S,GAAeC,EAAU5S,EAAQ,GAAO0S,EAAY,EAAKE,EAAUP,EAAKK,EAAY,EAAI1S,EAAQoS,EAAuBpS,EAAQoS,IAIjK,SAAjBS,GAAkB5T,EAAMT,EAASsU,EAAOC,UAAaD,EAAM/M,MAAM,KAAKiN,QAAQ,SAAAhU,UAAQC,EAAKT,EAASQ,EAAM+T,KAC3F,SAAfhU,GAAgBP,EAASQ,EAAMC,EAAMgU,EAAY9T,UAAYX,EAAQY,iBAAiBJ,EAAMC,EAAM,CAACC,SAAU+T,EAAY9T,UAAWA,IAClH,SAAlBE,GAAmBb,EAASQ,EAAMC,EAAME,UAAYX,EAAQc,oBAAoBN,EAAMC,IAAQE,GAC7E,SAAjB+T,GAAkBjU,EAAMJ,EAAIsU,IAC3BA,EAAaA,GAAcA,EAAWC,gBAErCnU,EAAKJ,EAAI,QAASsU,GAClBlU,EAAKJ,EAAI,YAAasU,IAMV,SAAdE,GAAerT,EAAOsT,MACjB/D,GAAUvP,GAAQ,KACjBuT,EAAUvT,EAAMrB,QAAQ,KAC3B6U,GAAYD,GAAYvT,EAAMyT,OAAOF,EAAQ,GAAK,GAAKzG,WAAW9M,EAAMwP,OAAO+D,EAAU,IAAM,GAC3FA,IACHvT,EAAMrB,QAAQ,KAAO4U,IAAaC,GAAYF,EAAO,KACtDtT,EAAQA,EAAMwP,OAAO,EAAG+D,EAAQ,IAEjCvT,EAAQwT,GAAaxT,KAAS0T,EAAaA,EAAU1T,GAASsT,GAAQtT,EAAMrB,QAAQ,KAAOmO,WAAW9M,GAASsT,EAAO,IAAMxG,WAAW9M,IAAU,UAE3IA,EAEQ,SAAhB2T,GAAiB3U,EAAM0F,EAAMkP,EAAWlB,IAAiE9R,EAAQiT,EAAcC,OAA3EC,IAAAA,WAAYC,IAAAA,SAAUC,IAAAA,SAAUC,IAAAA,OAAQC,IAAAA,WACvFzQ,EAAI/B,GAAKyS,cAAc,OAC1BC,EAAmBzV,GAAYgV,IAAsD,UAAxCrV,EAAcqV,EAAW,WACtEU,GAA2C,IAA9BtV,EAAKL,QAAQ,YAC1B4V,EAASF,EAAmBrP,GAAQ4O,EACpCY,GAAqC,IAA3BxV,EAAKL,QAAQ,SACvB8V,EAAQD,EAAUT,EAAaC,EAC/BU,EAAM,gBAAkBD,EAAQ,cAAgBR,EAAW,UAAYQ,EAAQ,gBAAkBN,EAAa,8IAC/GO,GAAO,cAAgBJ,GAAcR,IAAuBO,EAAmB,SAAW,cACzFC,IAAcR,GAAuBO,IAAsBK,IAAQhC,IAAc3Q,GAAY4S,EAASC,GAAW,KAAOhU,EAASkM,WAAWoH,IAAW,OACxJL,IAAiBa,GAAO,+CAAiDb,EAAagB,YAAc,OACpGnR,EAAEoR,SAAWN,EACb9Q,EAAEqR,aAAa,QAAS,eAAiB/V,GAAQ0F,EAAO,WAAaA,EAAO,KAC5EhB,EAAEsR,MAAMC,QAAUP,EAClBhR,EAAEwR,UAAYxQ,GAAiB,IAATA,EAAa1F,EAAO,IAAM0F,EAAO1F,EACvDuV,EAAOY,SAAS,GAAKZ,EAAOa,aAAa1R,EAAG6Q,EAAOY,SAAS,IAAMZ,EAAOc,YAAY3R,GACrFA,EAAE4R,QAAU5R,EAAE,SAAWgP,EAAU3L,GAAGH,IACtC2O,EAAgB7R,EAAG,EAAGgP,EAAW8B,GAC1B9Q,EAiBA,SAAR8R,YAA6C,GAA/B5S,KAAa6S,KAAoCC,EAAXA,GAAoBxK,sBAAsByK,IAClF,SAAZpW,KACMC,GAAgBA,EAAYC,aAAaD,EAAYiM,OAASzG,GAAM4Q,eACxElW,GAAWC,QACPH,EACQkW,EAAXA,GAAoBxK,sBAAsByK,GAE1CA,IAEDF,IAAmBI,EAAU,eAC7BJ,GAAkB7S,MAGC,SAArBkT,KACCC,EAAmB7V,GAAKoQ,WACxB0F,EAAoB9V,GAAKuM,YAEd,SAAZwJ,GAAatT,GACZjD,GAAWC,SACA,IAAVgD,IAAoBuT,IAAgBC,GAAkBxU,GAAKyU,mBAAsBzU,GAAK0U,yBAA6BC,GAAuBP,IAAqB7V,GAAKoQ,cAAc/P,KAAKyD,IAAI9D,GAAKuM,YAAcuJ,GAAwC,IAAnB9V,GAAKuM,eAAyB8J,EAAalK,SAAQ,GAIzQ,SAAfmK,YAAqBnX,GAAgB6E,GAAe,YAAasS,KAAiBC,IAAY,GAG5E,SAAlBC,GAAkBC,OACZ,IAAI7U,EAAI,EAAGA,EAAI8U,EAAazU,OAAQL,GAAG,IACtC6U,GAASC,EAAa9U,EAAE,IAAM8U,EAAa9U,EAAE,GAAG+U,QAAUF,KAC9DC,EAAa9U,GAAGkT,MAAMC,QAAU2B,EAAa9U,EAAE,GAC/C8U,EAAa9U,GAAGgV,SAAWF,EAAa9U,GAAGiT,aAAa,YAAa6B,EAAa9U,EAAE,IAAM,IAC1F8U,EAAa9U,EAAE,GAAGiV,QAAU,GAIlB,SAAbC,GAAcnI,EAAM8H,OACfM,MACCC,GAAK,EAAGA,GAAKC,GAAUhV,OAAQ+U,OACnCD,EAAUE,GAAUD,MACHP,GAASM,EAAQjW,OAAS2V,IACtC9H,EACHoI,EAAQpI,KAAK,GAEboI,EAAQnI,QAAO,GAAM,IAIxBsI,GAAc,EACdT,GAASD,GAAgBC,GACzBA,GAASd,EAAU,UAEC,SAArBwB,GAAsBjX,EAAmBuC,GACxCjD,GAAWC,SACVgD,GAAU2U,IAAmB5X,GAAWsT,QAAQ,SAAApB,UAAOf,GAAYe,IAAQA,EAAIlR,YAAckR,EAAI2F,IAAM,KACxGhI,GAAUnP,KAAuBF,GAAKC,QAAQC,kBAAoBoX,EAAqBpX,GAWxE,SAAhBqX,KACCzS,GAAMqQ,YAAYqC,GAClBxH,GAAW1Q,GAAekY,EAAUC,cAAiBzX,GAAKuM,YAC1DzH,GAAM4S,YAAYF,GAED,SAAlBG,GAAkBC,UAAQC,GAAS,gGAAgG/E,QAAQ,SAAAnU,UAAMA,EAAGmW,MAAMgD,QAAUF,EAAO,OAAS,UA8GvK,SAAbG,GAAcC,EAAKC,EAAQC,EAAIC,OACzBH,EAAII,MAAMC,UAAW,SAIxBhS,EAHGzE,EAAI0W,EAAiBrW,OACxBsW,EAAcN,EAAOnD,MACrB0D,EAAWR,EAAIlD,MAETlT,KAEN2W,EADAlS,EAAIiS,EAAiB1W,IACJsW,EAAG7R,GAErBkS,EAAYE,SAA2B,aAAhBP,EAAGO,SAA0B,WAAa,WACjD,WAAfP,EAAGJ,UAA0BS,EAAYT,QAAU,gBACpDU,EAAS9D,GAAW8D,EAAS/D,GAAU,OACvC8D,EAAYG,UAAYR,EAAGQ,WAAa,OACxCH,EAAYI,SAAW,UACvBJ,EAAYK,UAAY,aACxBL,EAAYM,IAAUjH,GAASoG,EAAK5R,IAAe0S,GACnDP,EAAYQ,IAAWnH,GAASoG,EAAKnW,IAAaiX,GAClDP,EAAYS,IAAYR,EAASS,IAAWT,EAAQ,IAASA,EAAQ,KAAU,IAC/EU,GAAUf,GACVK,EAASK,IAAUL,EAAQ,SAAmBN,EAAGW,IACjDL,EAASO,IAAWP,EAAQ,UAAoBN,EAAGa,IACnDP,EAASQ,IAAYd,EAAGc,IACpBhB,EAAImB,aAAelB,IACtBD,EAAImB,WAAWjE,aAAa+C,EAAQD,GACpCC,EAAO9C,YAAY6C,IAEpBA,EAAII,MAAMC,WAAY,GAsBZ,SAAZe,GAAY9a,WACP+a,EAAIC,GAAYrX,OACnB6S,EAAQxW,EAAQwW,MAChByE,EAAQ,GACR3X,EAAI,EACEA,EAAIyX,EAAGzX,IACb2X,EAAMzX,KAAKwX,GAAY1X,GAAIkT,EAAMwE,GAAY1X,YAE9C2X,EAAM3Y,EAAItC,EACHib,EAuBS,SAAjBC,GAAkB1Z,EAAOiX,EAAS0C,EAAcjH,EAAWkH,EAAQC,EAAQC,EAAgB/Y,EAAMgZ,EAAgBC,EAAa3F,EAAkB4F,EAAanG,EAAoBoG,GAChLrJ,GAAY7Q,KAAWA,EAAQA,EAAMe,IACjCwO,GAAUvP,IAAgC,QAAtBA,EAAMwP,OAAO,EAAE,KACtCxP,EAAQia,GAAmC,MAApBja,EAAMyT,OAAO,GAAaJ,GAAY,IAAMrT,EAAMwP,OAAO,GAAImK,GAAgB,QAGpGQ,EAAI3T,EAAIhI,EADL4b,EAAOtG,EAAqBA,EAAmBsG,OAAS,KAE5DtG,GAAsBA,EAAmBuG,KAAK,GAC9C5M,MAAMzN,KAAWA,GAASA,GACrB8Q,GAAU9Q,GAkBd8T,IAAuB9T,EAAQ5B,GAAK8C,MAAMoZ,SAASxG,EAAmByG,cAAcC,MAAO1G,EAAmByG,cAAcE,IAAK,EAAGR,EAAaja,IACjJ8Z,GAAkBvE,EAAgBuE,EAAgBH,EAAcjH,GAAW,OAnBrD,CACtB7B,GAAYoG,KAAaA,EAAUA,EAAQlW,QAE1C2Z,EAAQC,EAAaC,EAAc5C,EADhC6C,GAAW7a,GAAS,KAAK+F,MAAM,KAEnCvH,EAAUqC,EAAWoW,EAASlW,IAASiE,IACvC0V,EAASlK,GAAWhS,IAAY,MACdkc,EAAOI,MAASJ,EAAOK,MAAgD,SAAvCrJ,GAAkBlT,GAASwZ,UAC5EA,EAAUxZ,EAAQwW,MAAMgD,QACxBxZ,EAAQwW,MAAMgD,QAAU,QACxB0C,EAASlK,GAAWhS,GACpBwZ,EAAWxZ,EAAQwW,MAAMgD,QAAUA,EAAWxZ,EAAQwW,MAAMgG,eAAe,YAE5EL,EAActH,GAAYwH,EAAQ,GAAIH,EAAOhI,EAAU/L,IACvDiU,EAAevH,GAAYwH,EAAQ,IAAM,IAAKlB,GAC9C3Z,EAAQ0a,EAAOhI,EAAUnM,GAAKwT,EAAerH,EAAUnM,GAAKyT,EAAcW,EAAcf,EAASgB,EACjGd,GAAkBvE,EAAgBuE,EAAgBc,EAAclI,EAAYiH,EAAeiB,EAAe,IAAOd,EAAehF,UAA2B,GAAf8F,GAC5IjB,GAAgBA,EAAeiB,KAK5BV,IACHnZ,EAAKmZ,GAAiBla,IAAU,KAChCA,EAAQ,IAAMA,EAAQ,IAEnB6Z,EAAQ,KACPlB,EAAW3Y,EAAQ2Z,EACtBnF,EAAUqF,EAAO/E,SAClBqF,EAAK,SAAWzH,EAAU9L,GAC1B2O,EAAgBsE,EAAQlB,EAAUjG,EAAY8B,GAAsB,GAAXmE,IAAoBnE,IAAYH,EAAmB9T,KAAK4C,IAAI6B,GAAMmV,GAAKtY,GAAOsY,IAAON,EAAOR,WAAWc,KAAQxB,EAAW,GAC/KtE,IACH0F,EAAiBvJ,GAAWsJ,GAC5BzF,IAAqBwF,EAAO7E,MAAMtC,EAAU3L,GAAGR,GAAMwT,EAAerH,EAAU3L,GAAGR,GAAKmM,EAAU3L,GAAGkU,EAAIpB,EAAOvE,QAAW0D,YAGvHlF,GAAsBtV,IACzB2b,EAAK3J,GAAWhS,GAChBsV,EAAmBuG,KAAKJ,GACxBzT,EAAKgK,GAAWhS,GAChBsV,EAAmBoH,cAAgBf,EAAGzH,EAAUnM,GAAKC,EAAGkM,EAAUnM,GAClEvG,EAAQA,EAAS8T,EAAmBoH,cAAiBjB,GAEtDnG,GAAsBA,EAAmBuG,KAAKD,GACvCtG,EAAqB9T,EAAQO,KAAKC,MAAMR,GAGpC,SAAZmb,GAAa3c,EAAS+V,EAAQwG,EAAKD,MAC9Btc,EAAQ6a,aAAe9E,EAAQ,KAEjChO,EAAG6R,EADApD,EAAQxW,EAAQwW,SAEhBT,IAAWvP,GAAO,KAGhBuB,KAFL/H,EAAQ4c,QAAUpG,EAAMC,QACxBmD,EAAK1G,GAAkBlT,IAEhB+H,GAAM8U,GAAWC,KAAK/U,KAAM6R,EAAG7R,IAA0B,iBAAbyO,EAAMzO,IAAyB,MAANA,IAC1EyO,EAAMzO,GAAK6R,EAAG7R,IAGhByO,EAAM+F,IAAMA,EACZ/F,EAAM8F,KAAOA,OAEb9F,EAAMC,QAAUzW,EAAQ4c,QAEzBhd,GAAK+F,KAAKoX,SAAS/c,GAASuY,QAAU,EACtCxC,EAAOc,YAAY7W,IAGE,SAAvBgd,GAAwBC,EAAcC,EAAcC,OAC/CC,EAAQF,EACXG,EAAQD,SACF,SAAA5b,OACF8b,EAAUvb,KAAKC,MAAMib,YACrBK,IAAYF,GAASE,IAAYD,GAAqC,EAA5Btb,KAAKyD,IAAI8X,EAAUF,IAA0C,EAA5Brb,KAAKyD,IAAI8X,EAAUD,KACjG7b,EAAQ8b,EACRH,GAAeA,KAEhBE,EAAQD,EACRA,EAAQrb,KAAKC,MAAMR,IAIN,SAAf+b,GAAgBlC,EAAQnH,EAAW1S,OAC9BkH,EAAO,GACXA,EAAKwL,EAAUnM,GAAK,KAAOvG,EAC3B5B,GAAK4d,IAAInC,EAAQ3S,GAUC,SAAnB+U,GAAoBC,EAAUxJ,GAGjB,SAAXyJ,GAAYtV,EAAUK,EAAMwU,EAAcU,EAASC,OAC9CC,EAAQH,GAASG,MACpBC,EAAarV,EAAKqV,WAClBC,EAAY,GACbd,EAAeA,GAAgBe,QAC3BC,EAAuBlB,GAAqBiB,EAAWf,EAAc,WACxEY,EAAMzN,OACNsN,GAASG,MAAQ,WAElBD,EAAWD,GAAWC,GAAY,EAClCD,EAAUA,GAAYvV,EAAW6U,EACjCY,GAASA,EAAMzN,OACf3H,EAAKyV,GAAQ9V,EACbK,EAAK0V,SAAU,GACf1V,EAAKsV,UAAYA,GACPG,GAAQ,kBAAMD,EAAqBhB,EAAeU,EAAUE,EAAMO,MAAQR,EAAUC,EAAMO,MAAQP,EAAMO,QAClH3V,EAAK4V,SAAW,WACfpd,GAAWC,QACXwc,GAASG,OAAS3G,KAEnBzO,EAAKqV,WAAa,WACjBJ,GAASG,MAAQ,EACjBC,GAAcA,EAAWQ,KAAKT,IAE/BA,EAAQH,GAASG,MAAQle,GAAK4e,GAAGd,EAAUhV,OA1BzCuV,EAAYjb,EAAe0a,EAAUxJ,GACxCiK,EAAO,UAAYjK,EAAUlM,UA4B9B0V,EAASS,GAAQF,GACPrJ,aAAe,kBAAM+I,GAASG,OAASH,GAASG,MAAMzN,SAAWsN,GAASG,MAAQ,IAC5Fvd,GAAamd,EAAU,QAASO,EAAUrJ,cAC1ClP,GAAcqB,SAAWxG,GAAamd,EAAU,YAAaO,EAAUrJ,cAChE+I,GAjkBT,IAAI/d,GAAMwG,EAAc1E,GAAMyB,GAAME,GAAQmD,GAAOlG,EAAOyX,EAAcwB,GAAUkF,GAAQC,GAAQC,EAAejH,GAAavG,GAAgByN,EAAgBlG,GAAImG,EAAYC,EAAa1M,EAAc2M,GAAOC,GAAqBrH,EAAe3W,EAAa8W,EAAqBN,EAAmBD,EAAkB0H,EAAYvY,EAAUsS,EAAoBE,EAAWxH,EAAQkH,EAAasG,GACpYC,GAiLAjI,EAyDA4B,GAEAsG,GAwEAC,GAnTA5d,GAAW,EACX2C,GAAWsD,KAAKC,IAChB2X,EAASlb,KACT6S,GAAkB,EAClBsI,GAAW,EAyBXxO,GAAY,SAAZA,UAAYvP,SAA2B,iBAAXA,GAW5Bge,GAAOzd,KAAKyD,IAGZ2Q,EAAS,QACTC,EAAU,SACVmE,GAAS,QACTE,GAAU,SACVgF,GAAS,QACTC,GAAQ,OACRC,GAAO,MACPC,GAAU,SACVlF,GAAW,UACXC,GAAU,SACVkF,GAAS,QACTC,EAAU,SACVtF,GAAM,KAYNxI,GAAa,SAAbA,WAAchS,EAAS+f,OAClBjC,EAAQiC,GAAoE,6BAA/C7M,GAAkBlT,GAAS4e,IAAkDhf,GAAK4e,GAAGxe,EAAS,CAACqM,EAAG,EAAGC,EAAG,EAAG0T,SAAU,EAAGC,SAAU,EAAGC,SAAU,EAAGC,UAAW,EAAGC,UAAW,EAAGC,MAAO,EAAGC,MAAO,EAAGC,MAAO,IAAI5N,SAAS,GACtPuJ,EAASlc,EAAQwgB,+BAClB1C,GAASA,EAAMnL,SAAS,GAAGtC,OACpB6L,GAwDRuE,GAAkB,CAAClL,WAAY,QAASC,SAAU,MAAOE,OAAQ,EAAGD,SAAU,OAAQE,WAAW,UACjG+K,GAAY,CAACC,cAAe,OAAQC,cAAe,GACnD1L,EAAY,CAACqH,IAAK,EAAGD,KAAM,EAAGuE,OAAQ,GAAKC,OAAQ,EAAGC,MAAO,GAiC7DhK,EAAkB,SAAlBA,gBAAmBsE,EAAQW,EAAO9H,EAAW8M,OACxCtY,EAAO,CAAC8Q,QAAS,SACpByH,EAAO/M,EAAU8M,EAAU,MAAQ,MACnCE,EAAehN,EAAU8M,EAAU,KAAO,OAC3C3F,EAAO8F,WAAaH,EACpBtY,EAAKwL,EAAU3O,EAAI,WAAayb,GAAW,IAAM,EACjDtY,EAAKwL,EAAU3O,GAAKyb,EAAU,MAAQ,EACtCtY,EAAK,SAAWuY,EAAOpB,IAAU,EACjCnX,EAAK,SAAWwY,EAAerB,IAAU,EACzCnX,EAAKwL,EAAUnM,GAAKiU,EAAQ,KAC5Bpc,GAAK4d,IAAInC,EAAQ3S,IAElBiQ,GAAY,GACZyI,GAAO,GAuBPC,EAAa,GACbC,EAAc,GAEdjK,EAAY,SAAZA,UAAY7W,UAAS6gB,EAAW7gB,IAAS6gB,EAAW7gB,GAAM+gB,IAAI,SAAAlgB,UAAKA,OAASigB,GAC5ElJ,EAAe,GAgCfoJ,GAAa,EAcbvJ,GAAc,SAAdA,YAAe9T,EAAOsd,MACrBpe,GAASF,GAAKoD,gBACdC,GAAQrD,GAAKmD,KACbhG,EAAQ,CAACoB,GAAMyB,GAAME,GAAQmD,KACzByQ,IAAoB9S,GAAUyU,GAIlCK,KACAH,GAAiBpT,GAAcgc,cAAe,EAC9CxgB,GAAWsT,QAAQ,SAAApB,UAAOf,GAAYe,MAAUA,EAAIlR,UAAYkR,EAAI2F,IAAM3F,WACtEuO,EAAetK,EAAU,eAC7B0H,IAASrZ,GAAcsO,OACvByN,GAAcjJ,KACdtX,GAAWsT,QAAQ,SAAApB,GACdf,GAAYe,KACfA,EAAIvP,SAAWuP,EAAIxP,OAAO4S,MAAMoL,eAAiB,QACjDxO,EAAI,MAGNuF,GAAU/H,MAAM,GAAG4D,QAAQ,SAAAlS,UAAKA,EAAEuf,YAClCjJ,GAAc,EACdD,GAAUnE,QAAQ,SAAClS,MACdA,EAAEwf,eAAiBxf,EAAEoX,IAAK,KACzByE,EAAO7b,EAAEoG,KAAKqZ,WAAa,cAAgB,eAC9CC,EAAW1f,EAAEoX,IAAIyE,GAClB7b,EAAEgO,QAAO,EAAM,GACfhO,EAAE2f,iBAAiB3f,EAAEoX,IAAIyE,GAAQ6D,GACjC1f,EAAEuf,aAGJ3C,GAAe,EACf7F,IAAgB,GAChBV,GAAUnE,QAAQ,SAAAlS,OACbqC,EAAMsN,GAAW3P,EAAEob,SAAUpb,EAAE4f,MAClCC,EAA0B,QAAf7f,EAAEoG,KAAKuT,KAAkB3Z,EAAE8f,WAAa9f,EAAE2Z,IAAMtX,EAC3D0d,EAAa/f,EAAEggB,aAAehgB,EAAE0Z,OAASrX,GACzCwd,GAAYE,IAAe/f,EAAEigB,aAAaF,EAAa1d,EAAM,EAAIrC,EAAE0Z,MAAOmG,EAAWpgB,KAAK4C,IAAI0d,EAAa1d,EAAMrC,EAAE0Z,MAAQ,EAAGrX,GAAOrC,EAAE2Z,KAAK,KAE9I5C,IAAgB,GAChB6F,GAAe,EACfyC,EAAanN,QAAQ,SAAA1B,UAAUA,GAAUA,EAAO0P,QAAU1P,EAAO0P,QAAQ,KACzEthB,GAAWsT,QAAQ,SAAApB,GACdf,GAAYe,KACfA,EAAIvP,QAAU6I,sBAAsB,kBAAM0G,EAAIxP,OAAO4S,MAAMoL,eAAiB,WAC5ExO,EAAI2F,KAAO3F,EAAIA,EAAI2F,QAGrBF,GAAmBG,EAAoB,GACvCjB,EAAajJ,QACb0S,KAEArK,EADA2B,GAAiB,GAEjBH,GAAUnE,QAAQ,SAAAlS,UAAK+P,GAAY/P,EAAEoG,KAAK+Z,YAAcngB,EAAEoG,KAAK+Z,UAAUngB,KACzEwW,GAAiBpT,GAAcgc,cAAe,EAC9CrK,EAAU,gBAlDT9W,GAAamF,GAAe,YAAasS,KAoD3C0K,EAAc,EACdC,GAAa,EAEbxL,EAAa,SAAbA,WAAchT,MACC,IAAVA,IAAiB2U,KAAmBF,EAAc,CACrDlT,GAAckd,YAAa,EAC3BvD,IAAYA,GAASnb,OAAO,OACxB6W,EAAIpC,GAAUhV,OACjBiY,EAAOxX,KACPye,EAAkC,IAAjBjH,EAAO0D,EACxBlE,EAASL,GAAKpC,GAAU,GAAGyC,YAC5BuH,GAA2BvH,EAAdsH,GAAwB,EAAI,EACzC5J,KAAmB4J,EAActH,GAC7ByH,IACC5L,KAAoB9F,IAA2C,IAAzByK,EAAO3E,KAChDA,GAAkB,EAClBI,EAAU,cAEXqH,GAASY,EACTA,EAAS1D,GAEN+G,GAAa,EAAG,KACnBjK,GAAKqC,EACS,EAAPrC,MACNC,GAAUD,KAAOC,GAAUD,IAAIxU,OAAO,EAAG2e,GAE1CF,GAAa,WAERjK,GAAK,EAAGA,GAAKqC,EAAGrC,KACpBC,GAAUD,KAAOC,GAAUD,IAAIxU,OAAO,EAAG2e,GAG3Cnd,GAAckd,YAAa,EAE5B1L,EAAS,GAEV8C,EAAmB,CA5SX,OACD,MA2S0B5D,EAASD,EAAQwE,GAAUiF,GAASjF,GAAU8E,GAAQ9E,GAAUgF,GAAMhF,GAAU+E,GAAO,UAAW,aAAc,QAAS,SAAU,kBAAmB,gBAAiB,eAAgB,aAAc,WAAY,cAAe,YAAa,YAAa,SAC3R1E,GAAchB,EAAiB8I,OAAO,CAACvI,GAAQE,GAAS,YAAa,MAAQoF,GAAQ,MAAQC,EAAS,WAAYnF,GAASD,GAAUA,GAAWiF,GAAMjF,GAAW+E,GAAQ/E,GAAWkF,GAASlF,GAAWgF,KA6CxMqD,GAAW,WACXnI,GAAY,SAAZA,UAAYK,MACPA,EAAO,KAITlT,EAAGvG,EAHAgV,EAAQyE,EAAM3Y,EAAEkU,MACnBuE,EAAIE,EAAMtX,OACVL,EAAI,OAEJ2X,EAAM3Y,EAAEwX,OAASla,GAAK+F,KAAKoX,SAAS9B,EAAM3Y,IAAIiW,QAAU,EAClDjV,EAAIyX,EAAGzX,GAAI,EACjB9B,EAAQyZ,EAAM3X,EAAE,GAChByE,EAAIkT,EAAM3X,GACN9B,EACHgV,EAAMzO,GAAKvG,EACDgV,EAAMzO,IAChByO,EAAMgG,eAAezU,EAAEib,QAAQD,GAAU,OAAOE,iBA4BpDrR,GAAc,CAAC0K,KAAK,EAAGC,IAAI,GA+D3BM,GAAa,qCAyFDnX,4BAQZ+C,KAAA,cAAKC,EAAM+J,WACLE,SAAWnE,KAAKwN,MAAQ,OACxBtT,MAAQ8F,KAAK6B,MAAK,GAAM,GACxBkP,QAwBJ2D,EAASC,EAAUC,EAAUC,EAASC,EAAStH,EAAOC,EAAKsH,EAAaC,EAAWC,EAAoBC,EAAkBC,EAAYC,EACrIC,EAAQC,EAAkBC,EAAgBC,EAAUrK,EAAQvX,EAAQ6hB,EAAWC,EAAWC,EAAUC,EAAWC,EAAcxK,EAAayK,EAAmBC,EAC7JC,EAAiB5K,EAAI6K,EAAOC,EAAOC,GAAYC,EAAaC,EAAcC,GAAiBC,GAAYC,GAAkBC,EAAgBC,EArBrI5G,GADL5V,EAAOyK,GAAcpC,GAAUrI,IAAS4J,GAAU5J,IAASA,EAAKyc,SAAY,CAAC1M,QAAS/P,GAAQA,EAAMgY,KAC/FpC,SAAU8G,EAAsO1c,EAAtO0c,YAAajZ,EAAyNzD,EAAzNyD,GAAIkZ,EAAqN3c,EAArN2c,SAAU5C,GAA2M/Z,EAA3M+Z,UAAW6C,EAAgM5c,EAAhM4c,MAAO7M,GAAyL/P,EAAzL+P,QAASiB,GAAgLhR,EAAhLgR,IAAK6L,GAA2K7c,EAA3K6c,WAAYC,GAA+J9c,EAA/J8c,oBAAqB5E,EAA0IlY,EAA1IkY,cAAe6E,EAA2H/c,EAA3H+c,gBAAiBC,EAA0Ghd,EAA1Ggd,eAAgBC,GAA0Fjd,EAA1Fid,KAAM9R,GAAoFnL,EAApFmL,KAAM+R,GAA8Eld,EAA9Ekd,YAAaC,EAAiEnd,EAAjEmd,UAAWvQ,GAAsD5M,EAAtD4M,mBAAoBwQ,GAAkCpd,EAAlCod,cAAeC,GAAmBrd,EAAnBqd,gBACjO7R,GAAYxL,EAAKqZ,YAAerZ,EAAK4M,qBAA0C,IAApB5M,EAAKqZ,WAAwBja,GAAcvE,GACtGyiB,IAAYV,GAAmB,IAAVA,EACrB5H,GAAWrb,EAAWqG,EAAKgV,UAAYhc,IACvCukB,EAAgBrmB,GAAK+F,KAAKoX,SAASW,IACnCjP,GAAarO,GAAYsd,IACzB7H,GAA0H,WAAtG,YAAanN,EAAOA,EAAKwd,QAAUnmB,EAAc2d,GAAU,YAAejP,IAAc,SAC5G0X,GAAY,CAACzd,EAAK0d,QAAS1d,EAAK2d,QAAS3d,EAAK4d,YAAa5d,EAAK6d,aAChE5F,GAAgBqF,IAAYtd,EAAKiY,cAAcpZ,MAAM,KACrDif,GAAU,YAAa9d,EAAOA,EAAK8d,QAAU9F,GAAU8F,QACvDhL,GAAc/M,GAAa,EAAIH,WAAW4E,GAAkBwK,IAAU,SAAWxJ,GAAUlM,GAAK6X,MAAY,EAC5Gtd,GAAOiM,KACPiY,GAAgB/d,EAAK+d,eAAkB,kBAAM/d,EAAK+d,cAAclkB,KAChEmkB,GA7kBa,SAAfC,aAAgBjJ,EAAUjP,SAAatG,IAAAA,EAAGC,IAAAA,GAAI7C,IAAAA,SAAQA,EAAIxF,EAAc2d,EAAU,0BAA4B,kBAAMnY,IAAI4C,IAAK,kBAAOsG,EAAa+C,GAAsBpJ,GAAMsV,EAAS,SAAWtV,KAAQ,GA6kBrLue,CAAajJ,GAAUjP,GAAYyF,IACrD0S,GA7kBgB,SAAlBC,gBAAmB7mB,EAASyO,UAAgBA,IAAevO,GAASC,QAAQH,GAAW2R,GAAe3R,GAAW,kBAAM4R,IA6kBhGiV,CAAgBnJ,GAAUjP,IAC/CqY,GAAW,EACXC,GAAc,EACdC,GAAe,EACfrS,GAAa3R,EAAe0a,GAAUxJ,OAMvC3R,GAAK+f,YAAc/f,GAAK6f,WAAY,EACpC7f,GAAK2f,KAAOhO,GACZ0M,GAAiB,GACjBre,GAAKmb,SAAWA,GAChBnb,GAAK6Y,OAAS9F,GAAqBA,GAAmBsG,KAAKqL,KAAK3R,IAAsBX,GACtF0O,EAAU1O,KACVpS,GAAKmG,KAAOA,EACZ+J,EAAYA,GAAa/J,EAAK+J,UAC1B,oBAAqB/J,IACxBqW,GAAQ,GACkB,OAA1BrW,EAAKwe,kBAA8B7H,GAAW9c,KAE/C0jB,EAAckB,YAAclB,EAAckB,aAAe,CACxD5K,IAAKkB,GAAiBC,GAAUna,IAChC+Y,KAAMmB,GAAiBC,GAAU5V,KAElCvF,GAAK2gB,QAAUA,EAAU+C,EAAckB,YAAYjT,GAAUnM,GAC7DxF,GAAK6kB,cAAgB,SAAA5lB,IACpBojB,EAActS,GAAU9Q,IAAUA,GAKjCmjB,GAAaA,GAAWjR,SAASlS,GAAUmjB,GAAa/kB,GAAK4e,GAAG/L,EAAW,CAAC4U,KAAM,OAAQC,cAAe,MAAOlJ,SAAS,EAAO1K,SAAUkR,EAAa2C,QAAQ,EAAMxJ,WAAY,6BAAM0H,GAAmBA,EAAgBljB,QAH1NoiB,IAAcA,GAAWhS,SAAS,GAAGtC,OACrCsU,GAAa,IAKXlS,IACHA,EAAU/J,KAAK8e,MAAO,EACrB/U,EAAUgV,WAAallB,GAAKmlB,aAAmD,IAAnCjV,EAAU/J,KAAKif,kBAAsD,IAAzBjf,EAAKif,iBAA6BlV,EAAUiB,YAAcjB,EAAU+P,OAAO,GAAG,GAAM,GAC7KjgB,GAAKkQ,UAAYA,EAAU3D,SAC3B2D,EAAUsJ,cAAgBxZ,IACrB6kB,cAAc9B,GACnBb,EAAQ,EACDtY,EAAPA,GAAYsG,EAAU/J,KAAKyD,IAGxB0H,KAEEtB,GAAUsB,MAASA,GAAKrQ,OAC5BqQ,GAAO,CAAC+T,OAAQ/T,wBAEIrN,GAAMgQ,OAAU5W,GAAK4d,IAAI/O,GAAa,CAACjI,GAAOnD,IAAUqa,GAAU,CAACkE,eAAgB,SACxG1gB,GAAWsT,QAAQ,SAAApE,UAAKiC,GAAYjC,IAAMA,EAAExM,UAAY6K,GAAatL,GAAKC,kBAAoBC,GAASqa,MAActN,EAAEvM,QAAS,KAChIuf,EAAW/Q,GAAYwB,GAAK+T,QAAU/T,GAAK+T,OAAyB,WAAhB/T,GAAK+T,OApkBxC,SAAnBC,iBAAmBpV,UAAa,SAAAjR,UAAS5B,GAAK8C,MAAMmR,KAAKN,GAAoBd,GAAYjR,IAokBRqmB,CAAiBpV,GAA6B,sBAAhBoB,GAAK+T,OApiB7F,SAAvBE,qBAAuBtU,UAAY,SAAChS,EAAOumB,UAAOpU,GAAiBJ,GAAoBC,GAArCG,CAAgDnS,EAAOumB,EAAG7T,YAoiByC4T,CAAqBrV,IAAkC,IAArBoB,GAAKmU,YAAwB,SAACxmB,EAAOumB,UAAOpU,GAAiBE,GAAK+T,OAAtBjU,CAA8BnS,EAAO4C,KAAa2iB,GAAc,IAAM,EAAIgB,EAAG7T,YAAatU,GAAK8C,MAAMmR,KAAKA,GAAK+T,QAChV/C,EAAehR,GAAKH,UAAY,CAACrP,IAAK,GAAKM,IAAK,GAChDkgB,EAAetS,GAAUsS,GAAgBpG,GAAOoG,EAAaxgB,IAAKwgB,EAAalgB,KAAO8Z,GAAOoG,EAAcA,GAC3GC,GAAkBllB,GAAKyP,YAAYwE,GAAKoU,OAAUrD,EAAc,GAAM,GAAK,eACtExJ,EAASzG,KACZuT,EAAoB9jB,KAAa2iB,GAAc,IAC/CjJ,EAAQoF,EAAQpF,WACZoK,GAAqBnmB,KAAKyD,IAAIjD,GAAKsC,eAAiB,KAAQiZ,GAAU3M,IAAkB2V,KAAa1L,EAoC/F7Y,GAAK4lB,UAAYrB,KAAa1L,GACxC0J,GAAgBjX,SAAQ,OArCyF,KAMhHua,EAAUC,EALP1V,GAAYyI,EAASY,GAAS6H,EACjCyD,EAAgB7U,IAAcuT,GAAWvT,EAAU6U,gBAAkB3U,EACrE2V,EAAWJ,EAAoB,GAAMZ,EAAgB5C,IAAUtgB,KAAasa,IAAU,KAAS,EAC/Fd,EAAUhe,GAAK8C,MAAM+D,OAAOkM,EAAU,EAAIA,EAAU6M,GAAK8I,EAAW,GAAKA,EAAW,MACpFC,EAAa5V,IAA6B,IAAjBkB,GAAK2U,QAAoB,EAAI5K,GAEpD6K,EAAqC5U,GAArC4U,QAAStL,EAA4BtJ,GAA5BsJ,YAAaY,EAAelK,GAAfkK,cACzBqK,EAAWhF,EAASmF,EAAYhmB,IAChC+P,GAAU8V,KAAcA,EAAWG,GACnCF,EAAYtmB,KAAK4C,IAAI,EAAG5C,KAAKC,MAAMga,EAAQoM,EAAWvE,IAClDzI,GAAUa,GAAiBD,GAAVZ,GAAmBiN,IAAcjN,EAAQ,IACzD0C,IAAUA,EAAM2J,UAAY3J,EAAMhY,MAAQ0Z,GAAK6I,EAAYjN,WAG1C,IAAjBvH,GAAK2U,UACR5K,EAAUwK,EAAWzV,GAEtBuQ,EAAQmF,EAAW,CAClB3U,SAAUmR,EAAarF,GAAoF,KAA7Ezd,KAAK4C,IAAI6a,GAAK+I,EAAajB,GAAgB9H,GAAK4I,EAAWd,IAA0BgB,EAAW,KAAS,IACvIjB,KAAMxT,GAAKwT,MAAQ,SACnBvhB,KAAM0Z,GAAK6I,EAAYjN,GACvB+B,YAAa,8BAAM2H,GAAgBjX,SAAQ,IAASsP,GAAeA,EAAY5a,KAC/Ewb,iCACCxb,GAAK2B,SACL4iB,GAAWnS,KACPlC,IAAcuT,KACjBrB,GAAaA,GAAW+D,QAAQ,gBAAiBN,EAAU3V,EAAUkW,OAASlW,EAAUmW,OAASnW,EAAUE,SAASyV,IAErH3D,EAAQC,EAAQjS,IAAcuT,GAAWvT,EAAU6U,gBAAkB/kB,GAAKoQ,SAC1E+S,GAAkBA,EAAenjB,IACjCwb,GAAcA,EAAWxb,MAExB6Y,EAAQwC,EAAUiG,EAAQwE,EAAYjN,EAASwC,EAAUiG,GAC5D4E,GAAWA,EAAQlmB,GAAM2gB,EAAQpF,WAKjChP,SAEJ3C,IAAOiV,GAAKjV,GAAM5J,IAKK2iB,GADvBA,GAHAzM,GAAUlW,GAAKkW,QAAUpW,EAAWoW,KAAoB,IAARiB,IAAgBA,MAGhCjB,GAAQqB,OAASrB,GAAQqB,MAAM+O,WACnB3D,EAAmB3iB,IAE/DmX,IAAc,IAARA,GAAejB,GAAUpW,EAAWqX,IAC1C3I,GAAUqU,KAAiBA,EAAc,CAAC0D,QAASrQ,GAASsQ,UAAW3D,IACnE1L,MACa,IAAf6L,IAAwBA,KAAe5K,KAAa4K,MAAcA,IAAc7L,GAAImB,YAAcnB,GAAImB,WAAWrE,OAAuD,SAA9CtD,GAAkBwG,GAAImB,YAAYrB,UAA6BkB,IAC1LnY,GAAKmX,IAAMA,IACXyJ,EAAWvjB,GAAK+F,KAAKoX,SAASrD,KAChBC,OAYbmK,EAAmBX,EAASa,UAXxB6B,KACHA,EAAYxjB,EAAWwjB,MACTA,EAAUV,WAAaU,EAAYA,EAAUvI,SAAWuI,EAAUmD,eAChF7F,EAAS8F,iBAAmBpD,EAC5BA,IAAc1C,EAAStJ,YAAciB,GAAU+K,KAEhD1C,EAASxJ,OAASA,EAASkM,GAAa1iB,GAAKyS,cAAc,OAC3D+D,EAAOuP,UAAUnW,IAAI,cACrB5G,GAAMwN,EAAOuP,UAAUnW,IAAI,cAAgB5G,GAC3CgX,EAASa,SAAWF,EAAmBhJ,GAAUpB,MAIjC,IAAjBhR,EAAKygB,SAAqBvpB,GAAK4d,IAAI9D,GAAK,CAACyP,SAAS,IAClD5mB,GAAKoX,OAASA,EAASwJ,EAASxJ,OAChCC,EAAK1G,GAAkBwG,IACvB2K,EAAezK,EAAG2L,GAAarR,GAAUhM,KACzC+b,EAAYrkB,GAAKkE,YAAY4V,IAC7BwK,EAAYtkB,GAAKwpB,YAAY1P,GAAKxF,GAAU3O,EAAGiV,IAE/Cf,GAAWC,GAAKC,EAAQC,GACxBoK,EAAWlJ,GAAUpB,KAElB8M,GAAS,CACZ7C,EAAapR,GAAUiU,IAAWrT,GAAaqT,GAAS/F,IAAmBA,GAC3EgD,EAAqBtO,GAAc,iBAAkBhJ,EAAIuR,GAAUxJ,GAAWyP,EAAY,GAC1FD,EAAmBvO,GAAc,eAAgBhJ,EAAIuR,GAAUxJ,GAAWyP,EAAY,EAAGF,GACzFrhB,EAASqhB,EAAmB,SAAWvP,GAAU3L,GAAGH,QAChDihB,EAAUhnB,EAAWtC,EAAc2d,GAAU,YAAcA,IAC/D6F,EAAc/U,KAAK+U,YAAcpO,GAAc,QAAShJ,EAAIkd,EAASnV,GAAWyP,EAAYvhB,EAAQ,EAAGkT,IACvGkO,EAAYhV,KAAKgV,UAAYrO,GAAc,MAAOhJ,EAAIkd,EAASnV,GAAWyP,EAAYvhB,EAAQ,EAAGkT,IACjGA,KAAuB2P,EAAiBrlB,GAAKwpB,YAAY,CAAC7F,EAAaC,GAAYtP,GAAU3O,EAAGiV,KAC1F3E,IAAsB3V,GAASyD,SAAsD,IAA5C5D,EAAc2d,GAAU,kBA7rBrD,SAApB4L,kBAAoBtpB,OACfma,EAAWjH,GAAkBlT,GAASma,SAC1Cna,EAAQwW,MAAM2D,SAAyB,aAAbA,GAAwC,UAAbA,EAAwBA,EAAW,WA4rBtFmP,CAAkB7a,GAAajI,GAAQkX,IACvC9d,GAAK4d,IAAI,CAACiG,EAAoBC,GAAmB,CAACyF,SAAS,IAC3D7E,EAAoB1kB,GAAKwpB,YAAY3F,EAAoBvP,GAAU3O,EAAGiV,IACtEgK,EAAkB5kB,GAAKwpB,YAAY1F,EAAkBxP,GAAU3O,EAAGiV,QAIhElF,GAAoB,KACnBiU,EAAcjU,GAAmB5M,KAAK4V,SACzCkL,EAAYlU,GAAmB5M,KAAK+gB,eACrCnU,GAAmBoU,cAAc,WAAY,WAC5CnnB,GAAK2B,OAAO,EAAG,EAAG,GAClBqlB,GAAeA,EAAYI,MAAMrU,GAAoBkU,GAAa,SAIpEjnB,GAAKqnB,SAAW,kBAAMjR,GAAUA,GAAUxY,QAAQoC,IAAQ,IAC1DA,GAAKsnB,KAAO,kBAAMlR,GAAUA,GAAUxY,QAAQoC,IAAQ,IAEtDA,GAAK+N,OAAS,SAACA,EAAQwZ,OACjBA,SAAevnB,GAAK8N,MAAK,OAC1B0Z,GAAe,IAAXzZ,IAAqB/N,GAAKsQ,QACjCmX,EAAiBtS,GACdqS,IAAMxnB,GAAKmlB,aACVqC,IACHhF,GAAahjB,KAAK4C,IAAIgQ,KAAcpS,GAAK6Y,OAAOrC,KAAO,GACvDiO,GAAezkB,GAAKoQ,SACpBqS,GAAmBvS,GAAaA,EAAUE,YAE3C4Q,GAAe,CAACA,EAAaC,EAAWC,EAAoBC,GAAkBlP,QAAQ,SAAAiI,UAAKA,EAAEjG,MAAMgD,QAAUuQ,EAAI,OAAS,UACtHA,IACHrS,GAAcnV,IACT2B,OAAO6lB,IAETrQ,IAASkM,IAAgBrjB,GAAK4lB,WAC7B4B,EAncM,SAAdE,YAAevQ,EAAKC,EAAQsB,GAC3BL,GAAUK,OACN9Z,EAAQuY,EAAII,SACZ3Y,EAAM8nB,eACTrO,GAAUzZ,EAAM0Y,kBACV,GAAIH,EAAII,MAAMC,UAAW,KAC3BhE,EAAS4D,EAAOkB,WAChB9E,IACHA,EAAOa,aAAa8C,EAAKC,GACzB5D,EAAOqD,YAAYO,IAGrBD,EAAII,MAAMC,WAAY,EAwblBkQ,CAAYvQ,GAAKC,EAAQmK,GAEzBrK,GAAWC,GAAKC,EAAQzG,GAAkBwG,IAAMG,IAGlDkQ,GAAKxnB,GAAK2B,OAAO6lB,GACjBrS,GAAcsS,EACdznB,GAAKmlB,WAAaqC,IAIpBxnB,GAAKsf,QAAU,SAACqI,EAAM/lB,EAAOgW,EAAUgQ,OACjCzS,IAAgBnV,GAAKsQ,SAAa1O,KAGnCuV,IAAOwQ,GAAQjT,GAClB1W,GAAamF,cAAe,YAAasS,UAGzCc,IAAkB2N,IAAiBA,GAAclkB,IAClDmV,GAAcnV,GACV2gB,EAAQpF,QAAU3D,IACrB+I,EAAQpF,MAAMzN,OACd6S,EAAQpF,MAAQ,GAEjB6G,IAAcA,GAAW7V,QACzB0W,IAAuB/S,GAAaA,EAAUnC,OAAO,CAACD,MAAM,IAAQ+Z,aACpE7nB,GAAKmlB,YAAcnlB,GAAK+N,QAAO,GAAM,GACrC/N,GAAKuf,eAAgB,MAapBlI,EAAIsC,EAAQd,EAAQiP,EAAYC,EAAUC,EAAYC,EAAQC,EAAgBC,EAASC,EAAcC,EAAgBC,EAAmBC,EAZrIhW,EAAO4R,KACVnL,EAAiBqL,KACjBjiB,EAAM2Q,GAAqBA,GAAmB5B,WAAazB,GAAWyL,GAAUxJ,IAChF6W,EAAiBlH,GAAU,IAC3BzhB,EAAS,EACT4oB,EAAiBb,GAAa,EAC9Bc,EAAY1Y,GAAU4H,GAAYA,EAAS8B,IAAMvT,EAAKuT,IACtDiP,EAAmBxiB,EAAKyiB,YAAc1S,GACtC2S,EAAc7Y,GAAU4H,GAAYA,EAAS6B,MAAStT,EAAKsT,QAAyB,IAAftT,EAAKsT,OAAgBvD,GAAeiB,GAAM,MAAQ,SAAnB,GACpG2R,EAAkB9oB,GAAK8oB,gBAAkB3iB,EAAK2iB,iBAAmBhpB,EAAWqG,EAAK2iB,gBAAiB9oB,IAClG+oB,EAAgB7S,IAAW1W,KAAK4C,IAAI,EAAGgU,GAAUxY,QAAQoC,MAAW,EACpEe,EAAIgoB,MAED9E,IAAWjU,GAAU4H,KACxB0Q,EAAoBjrB,GAAKkE,YAAY2f,EAAoBvP,GAAUnM,GACnE+iB,EAAkBlrB,GAAKkE,YAAY4f,EAAkBxP,GAAUnM,IAEnD,EAANzE,MACNinB,EAAa5R,GAAUrV,IACZ2Y,KAAOsO,EAAW1I,QAAQ,EAAG,KAAOnK,GAAcnV,MAC7DioB,EAASD,EAAW7Q,MACL8Q,IAAW/R,IAAW+R,IAAW9Q,IAAO8Q,IAAWa,GAAqBd,EAAW7C,cAChFiD,EAAjBA,GAAgC,IACnBY,QAAQhB,GACrBA,EAAWja,QAAO,GAAM,IAErBia,IAAe5R,GAAUrV,KAC5BgoB,IACAhoB,SAGF+O,GAAY+Y,KAAiBA,EAAcA,EAAY7oB,KACvD6oB,EAActa,GAAYsa,EAAa,QAAS7oB,IAChDyZ,EAAQd,GAAekQ,EAAa3S,GAAS3D,EAAMZ,GAAWS,KAAc4O,EAAaE,EAAoBlhB,GAAMgZ,EAAgBC,GAAa3F,GAAkBlR,EAAK2Q,GAAoB/S,GAAK+f,aAAe,iBAAmB5I,IAAO,KAAQ,GACjPrH,GAAY4Y,KAAeA,EAAYA,EAAU1oB,KAC7CwO,GAAUka,KAAeA,EAAU9qB,QAAQ,SACzC8qB,EAAU9qB,QAAQ,KACtB8qB,GAAala,GAAUqa,GAAeA,EAAY7jB,MAAM,KAAK,GAAK,IAAM0jB,GAExE7oB,EAASyS,GAAYoW,EAAUja,OAAO,GAAI8D,GAC1CmW,EAAYla,GAAUqa,GAAeA,GAAe9V,GAAqB1V,GAAK8C,MAAMoZ,SAAS,EAAGxG,GAAmB5B,WAAY4B,GAAmByG,cAAcC,MAAO1G,GAAmByG,cAAcE,IAAKD,GAASA,GAAS5Z,EAC/N8oB,EAAmBzS,KAGrBwS,EAAYna,GAAYma,EAAW,MAAO1oB,IAC1C0Z,EAAMla,KAAK4C,IAAIqX,EAAOd,GAAe+P,IAAcC,EAAmB,SAAWvmB,GAAMumB,EAAkBpW,EAAMZ,GAAWS,KAAevS,EAAQohB,EAAWE,EAAkBnhB,GAAMgZ,EAAgBC,GAAa3F,GAAkBlR,EAAK2Q,GAAoB/S,GAAK6f,WAAa,gBAAkB,KAEhShgB,EAAS,EACTkB,EAAIgoB,EACGhoB,MAENknB,GADAD,EAAa5R,GAAUrV,IACHoW,MACN6Q,EAAWvO,MAAQuO,EAAWiB,UAAYxP,IAAU1G,IAAuC,EAAjBiV,EAAWtO,MAClGrC,EAAK2Q,EAAWtO,KAAO1Z,GAAK+f,YAAcvgB,KAAK4C,IAAI,EAAG4lB,EAAWvO,OAASuO,EAAWvO,QAC/EwO,IAAW/R,IAAW8R,EAAWvO,MAAQuO,EAAWiB,SAAWxP,GAAUwO,IAAWa,IAAoBpc,MAAMmc,KACnHhpB,GAAUwX,GAAM,EAAI2Q,EAAW5X,WAEhC6X,IAAW9Q,KAAQsR,GAAkBpR,OAGvCoC,GAAS5Z,EACT6Z,GAAO7Z,EACPG,GAAK+f,cAAgB/f,GAAK+f,aAAelgB,GAErCG,GAAK6f,YAActJ,KACtBvW,GAAK6f,UAAYnG,IAAQ,KACzBA,EAAMla,KAAKsC,IAAI4X,EAAKhK,GAAWyL,GAAUxJ,MAE1C2P,EAAU5H,EAAMD,IAAYA,GAAS,MAAS,KAE1C+O,IACH/D,GAAepnB,GAAK8C,MAAM+D,MAAM,EAAG,EAAG7G,GAAK8C,MAAM+oB,UAAUzP,EAAOC,EAAK8I,MAExExiB,GAAKipB,SAAWR,EACZzH,GAAenhB,KAClBwX,EAAK,IACF1F,GAAU3O,GAAK,KAAOnD,EACzBipB,IAAoBzR,EAAG1F,GAAUnM,GAAK,KAAO4M,MAC7C/U,GAAK4d,IAAI,CAAC+F,EAAaC,GAAY5J,KAGhCF,IAASwF,IAAgB3c,GAAK0Z,KAAOhK,GAAWyL,GAAUxJ,KAuEvD,GAAIuE,IAAW9D,OAAiBW,OACtC4G,EAASzD,GAAQoC,WACVqB,GAAUA,IAAW1V,IACvB0V,EAAOwP,aACV1P,GAASE,EAAOwP,WAChBzP,GAAOC,EAAOwP,YAEfxP,EAASA,EAAOrB,gBA7EjBjB,EAAK1G,GAAkBwG,IACvB2Q,EAAanW,KAAc3Q,GAC3B6X,EAASzG,KACTwP,EAAW7V,WAAW2V,EAAU/P,GAAU3O,IAAMylB,GAC3CrmB,GAAa,EAANsX,IAEX2O,EAAiB,CAACpU,MADlBoU,GAAkBnc,GAActL,GAAKC,kBAAoBC,GAAUqa,IAAUlH,MACpChV,MAAOopB,EAAe,WAAa1W,GAAU3O,EAAEomB,gBACpFld,IAAmF,WAArEyE,GAAkB1M,IAAO,WAAa0N,GAAU3O,EAAEomB,iBACnEf,EAAepU,MAAM,WAAatC,GAAU3O,EAAEomB,eAAiB,WAGjElS,GAAWC,GAAKC,EAAQC,GACxBoK,EAAWlJ,GAAUpB,IAErBwC,EAASlK,GAAW0H,IAAK,GACzB+Q,EAAiB5U,IAAoB7S,EAAe0a,GAAU2M,EAAaviB,GAAcvE,GAApDP,GACjCuiB,KACH1L,EAAc,CAAC0L,GAAarR,GAAUhM,IAAK2b,EAASmH,EAAiBxQ,KACzDlY,EAAIqX,GAChBrW,EAAKiiB,KAAe7K,GAAYpH,GAASoG,GAAKxF,IAAa2P,EAASmH,EAAiB,KAEpFnR,EAAYrW,KAAK0Q,GAAU/L,EAAG7E,EAAIkX,IACP,SAA3Bb,EAAOnD,MAAM4D,YAAyBT,EAAOnD,MAAM4D,UAAY9W,EAAIkX,KAEpEI,GAAUf,GACNwR,GACH1S,GAAUnE,QAAQ,SAAAlS,GACbA,EAAEoX,MAAQ2R,IAAyC,IAAtB/oB,EAAEoG,KAAK6c,aACvCjjB,EAAEwf,eAAgB,KAIrBjM,IAAoBlB,GAAWoQ,MAE/BzhB,EAAIgQ,GAASoG,GAAKxF,MACc,SAA3ByF,EAAOnD,MAAM4D,YAAyBT,EAAOnD,MAAM4D,UAAY9W,EAAIkX,IAErE3E,MACHyU,EAAW,CACV/N,IAAML,EAAOK,KAAO8N,EAAajP,EAASY,EAAQyO,GAAmBjQ,GACrE8B,KAAOJ,EAAOI,MAAQ+N,EAAaI,EAAiBrP,EAASY,GAAUxB,GACvEF,UAAW,aACXH,SAAU,UAEFI,IAAU+P,EAAQ,SAAmBvoB,KAAK6pB,KAAK1P,EAAOrK,OAAS2I,GACxE8P,EAAS7P,IAAW6P,EAAQ,UAAoBvoB,KAAK6pB,KAAK1P,EAAOnK,QAAUyI,GAC3E8P,EAAS3P,IAAW2P,EAAS3P,GAAUgF,IAAQ2K,EAAS3P,GAAU8E,IAAU6K,EAAS3P,GAAUiF,IAAW0K,EAAS3P,GAAU+E,IAAS,IACtI4K,EAAS5P,IAAYd,EAAGc,IACxB4P,EAAS5P,GAAWiF,IAAQ/F,EAAGc,GAAWiF,IAC1C2K,EAAS5P,GAAW+E,IAAU7F,EAAGc,GAAW+E,IAC5C6K,EAAS5P,GAAWkF,IAAWhG,EAAGc,GAAWkF,IAC7C0K,EAAS5P,GAAWgF,IAAS9F,EAAGc,GAAWgF,IAC3CqE,EA7hBS,SAAb8H,WAAc5Q,EAAOqP,EAAUwB,WAI7B/jB,EAHG+K,EAAS,GACZiI,EAAIE,EAAMtX,OACVL,EAAIwoB,EAAc,EAAI,EAEhBxoB,EAAIyX,EAAGzX,GAAK,EAClByE,EAAIkT,EAAM3X,GACVwP,EAAOtP,KAAKuE,EAAIA,KAAKuiB,EAAYA,EAASviB,GAAKkT,EAAM3X,EAAE,WAExDwP,EAAOxQ,EAAI2Y,EAAM3Y,EACVwQ,EAmhBa+Y,CAAW/H,EAAkBwG,EAAU1E,IACxD9M,IAAkBnE,GAAW,IAE1BlC,GACHiY,EAAUjY,EAAUgV,SACpBzI,GAAoB,GACpBvM,EAAU+P,OAAO/P,EAAUiB,YAAY,GAAM,GAC7C0Q,EAAYH,EAAU/P,GAAU3O,GAAK4e,EAAWN,EAASmH,EACzDzG,EAA0C,EAA/BxiB,KAAKyD,IAAIqe,EAASO,GAC7BvO,IAAoB0O,GAAYR,EAAexT,OAAOwT,EAAepgB,OAAS,EAAG,GACjF8O,EAAU+P,OAAO,GAAG,GAAM,GAC1BkI,GAAWjY,EAAU2X,YAAW,GAChC3X,EAAUsD,QAAUtD,EAAUO,UAAUP,EAAUO,aAClDgM,GAAoB,IAEpBoF,EAAYP,EAEb+G,IAAmBA,EAAeppB,MAASopB,EAAepU,MAAM,WAAatC,GAAU3O,EAAEomB,eAAiBf,EAAeppB,MAASopB,EAAepU,MAAMgG,eAAe,YAActI,GAAU3O,IAW/LolB,GAAgBA,EAAanW,QAAQ,SAAAlS,UAAKA,EAAEgO,QAAO,GAAO,KAC1D/N,GAAKyZ,MAAQA,EACbzZ,GAAK0Z,IAAMA,EACXoH,EAAUC,EAAUxK,GAAiBiM,GAAapQ,KAC7CW,IAAuBwD,KAC3BuK,EAAU0B,IAAcpQ,GAAWoQ,IACnCxiB,GAAK6Y,OAAOrC,IAAM,GAEnBxW,GAAK+N,QAAO,GAAO,GACnByW,GAAc3iB,KACV0gB,KACHgC,IAAY,EAEZhC,GAAgBjX,SAAQ,IAEzB6J,GAAc,EACdjF,GAAauT,KAAavT,EAAUgV,UAAYzC,KAAqBvS,EAAUE,aAAeqS,IAAoBvS,EAAUE,SAASqS,IAAoB,GAAG,GAAMxC,OAAO/P,EAAUmJ,QAAQ,GAAM,IAC7LmP,GAAkB/D,KAAiBzkB,GAAKoQ,UAAY2C,IAAsBkQ,IAAwB/S,IAAcA,EAAUgV,YAC7HhV,IAAcuT,IAAYvT,EAAU6U,cAAchS,IAAsB0G,GAAS,OAAUgL,GAAepnB,GAAK8C,MAAM+oB,UAAUzP,EAAOC,EAAK,GAAK+K,IAAc,GAC9JzkB,GAAKoQ,SAAWoY,IAAoB1H,EAAUrH,GAAS6H,IAAWmD,GAAgB,EAAIA,IAEvFtN,IAAO6L,KAAe5L,EAAO+R,WAAa3pB,KAAKC,MAAMO,GAAKoQ,SAAWyR,IACrEO,IAAcA,GAAWyF,aAEpBnb,MAAM4b,KACVA,GAAqBjrB,GAAKkE,YAAY2f,EAAoBvP,GAAUnM,GACpE+iB,GAAmBlrB,GAAKkE,YAAY4f,EAAkBxP,GAAUnM,GAChEwV,GAAakG,EAAoBvP,GAAW2W,GAC5CtN,GAAagG,EAAarP,GAAW2W,GAAqBV,GAAa,IACvE5M,GAAamG,EAAkBxP,GAAW4W,GAC1CvN,GAAaiG,EAAWtP,GAAW4W,GAAmBX,GAAa,KAGpEY,IAAmBjS,IAAkBvW,GAAK2B,UAEtCue,IAAc3J,IAAmB8K,IACpCA,GAAqB,EACrBnB,GAAUlgB,IACVqhB,GAAqB,KAIvBrhB,GAAKsC,YAAc,kBAAQ8P,KAAe2O,IAAYlf,KAAasa,IAAU,KAAS,GAEtFnc,GAAKwpB,aAAe,WACnBvZ,GAAcjQ,GAAK0Q,mBACfR,IACHkS,GAAaA,GAAWhS,SAAS,GAAOF,EAAU8U,SAA4DvB,IAAYxT,GAAcC,EAAWlQ,GAAK2R,UAAY,EAAG,GAA1G1B,GAAcC,EAAWA,EAAUC,cAIlGnQ,GAAKypB,cAAgB,SAAAC,UAASxZ,GAAaA,EAAUgB,SAAYuI,GAASzZ,GAAKsf,WAAa7F,GAAUvJ,EAAUgB,OAAOwY,GAASxZ,EAAUiB,WAAcmQ,GAAW,GAEnKthB,GAAK2pB,YAAc,SAAAhmB,OACd5C,EAAIqV,GAAUxY,QAAQoC,IACzBgD,EAAqB,EAAjBhD,GAAK2R,UAAgByE,GAAU/H,MAAM,EAAGtN,GAAG6oB,UAAYxT,GAAU/H,MAAMtN,EAAE,UACtEyN,GAAU7K,GAAQX,EAAE4K,OAAO,SAAA7N,UAAKA,EAAEoG,KAAKqd,kBAAoB7f,IAAQX,GAAG4K,OAAO,SAAA7N,UAAsB,EAAjBC,GAAK2R,UAAgB5R,EAAE2Z,KAAOD,EAAQ1Z,EAAE0Z,OAASC,KAI5I1Z,GAAK2B,OAAS,SAACU,EAAOie,EAAgBuJ,OACjC9W,IAAuB8W,GAAcxnB,OAOxCujB,EAAqBkE,EAAaC,EAAQC,EAAcC,EAASC,EAASC,EAJvEtR,GAA4B,IAAnBtC,GAA0BiM,GAAaxiB,GAAK6Y,SACxDrT,EAAInD,EAAQ,GAAKwW,EAASY,GAAS6H,EACnC8I,EAAU5kB,EAAI,EAAI,EAAQ,EAAJA,EAAQ,EAAIA,GAAK,EACvCif,EAAezkB,GAAKoQ,YAEjBkQ,IACHS,EAAUD,EACVA,EAAU/N,GAAqBX,KAAeyG,EAC1CvH,KACH6Q,EAAQD,EACRA,EAAQhS,IAAcuT,GAAWvT,EAAU6U,gBAAkBqF,IAI3D/L,GAAiBlH,KAAQhC,KAAgBjW,IAAYwV,MACnD0V,GAAW3Q,EAAQZ,GAAWA,EAASkI,IAAYlf,KAAasa,IAAWkC,EAC/E+L,EAAU,KACY,IAAZA,GAAiB1Q,EAAMb,GAAWA,EAASkI,IAAYlf,KAAasa,IAAWkC,IACzF+L,EAAU,QAGRA,IAAY3F,GAAgBzkB,GAAKsQ,QAAS,IAI7C0Z,GADAC,GAFArE,EAAW5lB,GAAK4lB,WAAawE,GAAWA,EAAU,OACpC3F,GAAgBA,EAAe,OAEjB2F,KAAc3F,EAC1CzkB,GAAK2R,UAAsB8S,EAAV2F,EAAyB,GAAK,EAC/CpqB,GAAKoQ,SAAWga,EAEZJ,IAAiB7U,KACpB2U,EAAcM,IAAY3F,EAAe,EAAgB,IAAZ2F,EAAgB,EAAqB,IAAjB3F,EAAqB,EAAI,EACtFhB,KACHsG,GAAWE,GAA8C,SAAnC7L,GAAc0L,EAAc,IAAiB1L,GAAc0L,EAAc,IAAO1L,GAAc0L,GACpHK,EAAiBja,IAAyB,aAAX6Z,GAAoC,UAAXA,GAAsBA,KAAU7Z,KAI1FsT,KAAoByG,GAAWE,KAAoBA,GAAkBpH,IAAU7S,KAAeJ,GAAY0T,IAAmBA,GAAgBxjB,IAAQA,GAAK2pB,YAAYnG,IAAiBvR,QAAQ,SAAAlS,UAAKA,EAAEypB,kBAEjM/F,MACArB,IAAejN,IAAgBjW,GAQxBgR,GACVA,EAAU6U,cAAcqF,KAAYjV,KAAgBqP,KAAeniB,KARlE+f,GAAWiI,IAAIC,MAAQlI,GAAWmI,SAAWnI,GAAWkI,OAAUlI,GAAWnC,OAAOmC,GAAWiI,IAAIC,MAAQlI,GAAWmI,QACnHnI,GAAW+D,QACd/D,GAAW+D,QAAQ,gBAAiBiE,EAASla,EAAUkW,OAASlW,EAAUmW,QAE1EjE,GAAWjc,KAAK4e,cAAgBqF,EAChChI,GAAWyF,aAAavc,aAMvB6L,MACH9U,GAAS2gB,KAAe5L,EAAOnD,MAAM+O,GAAarR,GAAUhM,KAAOmc,GAC9DxO,IAEE,GAAI0W,EAAc,IACxBE,GAAW7nB,GAAmBoiB,EAAV2F,GAAoCvR,EAAVa,EAAM,GAAcb,EAAS,GAAKnJ,GAAWyL,GAAUxJ,IACjG0R,MACEhhB,IAAUujB,IAAYsE,EAK1B9P,GAAUjD,GAAKC,OALqB,KAChCuC,EAASlK,GAAW0H,IAAK,GAC5BtX,EAASgZ,EAASY,EACnBW,GAAUjD,GAAKlT,GAAQ0V,EAAOK,KAAOrI,KAAc3Q,GAAYnB,EAAS,GAAMoY,GAAM0B,EAAOI,MAAQpI,KAAc3Q,GAAY,EAAInB,GAAWoY,IAK9II,GAAUuN,GAAYsE,EAAU1I,EAAiBC,GAChDO,GAAYoI,EAAU,GAAKxE,GAAajE,EAAUC,GAAwB,IAAZwI,GAAkBF,EAAsB,EAAZrI,UAb3FF,EAAU5S,GAAO6S,EAAWC,EAAYuI,KAgB1C9Y,IAASqP,EAAQpF,OAAUpG,IAAgBjW,IAAYqjB,GAAgBjX,SAAQ,GAC/EuX,IAAgBoH,GAAY7G,IAAQgH,IAAYA,EAAU,IAAMxN,MAAsB5F,GAAS6L,EAAY0D,SAAStU,QAAQ,SAAAnU,UAAMA,EAAG6oB,UAAUf,GAAYxC,GAAO,MAAQ,UAAUP,EAAY2D,cAChMzK,GAAa0H,IAAaphB,GAAS0Z,EAAS/b,IACxCgqB,IAAiB7U,IAChBsO,KACC0G,IACY,aAAXJ,EACH7Z,EAAU3D,QAAQwY,cAAc,GACX,UAAXgF,EACV7Z,EAAU5E,SAAQ,GAAMiB,QACH,YAAXwd,EACV7Z,EAAU5E,SAAQ,GAElB4E,EAAU6Z,MAGZhO,GAAYA,EAAS/b,MAElBiqB,GAAYrN,KACfkG,GAAYmH,GAAW5Z,GAAUrQ,GAAM8iB,GACvCc,GAAUkG,IAAgBzZ,GAAUrQ,GAAM4jB,GAAUkG,IACpD1G,KAAqB,IAAZgH,EAAgBpqB,GAAK8N,MAAK,EAAO,GAAM8V,GAAUkG,GAAe,GACpEG,GAEJrG,GADAkG,EAA0B,IAAZM,EAAgB,EAAI,IACR/Z,GAAUrQ,GAAM4jB,GAAUkG,KAGlDvG,KAAkBqC,GAAYpmB,KAAKyD,IAAIjD,GAAKsC,gBAAkByN,GAAUwT,IAAiBA,GAAgB,QAC5GtT,GAAcjQ,GAAK0Q,mBACnB0R,GAAaA,GAAWhS,SAAS,GAAKH,GAAcC,EAAsB,YAAX6Z,EAAuB,GAAKK,EAAS,KAE3F3G,IAAY1H,IAAa5G,IACnC4G,EAAS/b,OAIPiiB,EAAiB,KAChBuI,EAAIzX,GAAqB8F,EAAS9F,GAAmB5B,YAAc4B,GAAmBoH,eAAiB,GAAKtB,EAChHkJ,EAAkByI,GAAKtJ,EAAmBtC,WAAa,EAAI,IAC3DqD,EAAgBuI,GAEjB9H,GAAkBA,GAAgB7J,EAAS9F,GAAmB5B,YAAc4B,GAAmBoH,eAAiB,MAGjHna,GAAKyN,OAAS,SAACpL,EAAOid,GAChBtf,GAAKsQ,UACTtQ,GAAKsQ,SAAU,EACftS,GAAamd,GAAU,SAAUjG,IACjChJ,IAAclO,GAAamd,GAAU,SAAU3c,IAC/C0lB,IAAiBlmB,GAAamF,cAAe,cAAe+gB,KAC9C,IAAV7hB,IACHrC,GAAKoQ,SAAWqU,GAAe,EAC/B3D,EAAUC,EAAUwD,GAAWnS,OAEpB,IAAZkN,GAAqBtf,GAAKsf,YAI5Btf,GAAKob,SAAW,SAAA9J,UAAQA,GAAQqP,EAAUA,EAAQpF,MAAQ6G,IAE1DpiB,GAAKggB,aAAe,SAACyK,EAAUC,EAAQC,EAAW/C,MAC7C7U,GAAoB,KACnByS,EAAKzS,GAAmByG,cAC3BrI,EAAW4B,GAAmB5B,WAC9BmQ,EAASkE,EAAG9L,IAAM8L,EAAG/L,MACtBgR,EAAWjF,EAAG/L,MAAQ6H,EAASmJ,EAAWtZ,EAC1CuZ,EAASlF,EAAG/L,MAAQ6H,EAASoJ,EAASvZ,EAEvCnR,GAAKsf,SAAQ,GAAO,EAAO,CAAC7F,MAAO/K,GAAW+b,EAAUE,KAAe3qB,GAAK+f,aAAcrG,IAAKhL,GAAWgc,EAAQC,KAAe3qB,GAAK6f,YAAa+H,GACnJ5nB,GAAK2B,UAGN3B,GAAK0f,iBAAmB,SAAAkL,MACnBtT,GAAesT,EAAQ,KACtB7pB,EAAIuW,EAAY1Z,QAAQ+T,GAAU/L,GAAK,EAC3C0R,EAAYvW,GAAMgL,WAAWuL,EAAYvW,IAAM6pB,EAAU3S,GACzDX,EAAY,GAAMvL,WAAWuL,EAAY,IAAMsT,EAAU3S,GACzDI,GAAUf,KAIZtX,GAAK2N,QAAU,SAACtL,EAAOwoB,MAClB7qB,GAAKsQ,WACE,IAAVjO,GAAmBrC,GAAK+N,QAAO,GAAM,GACrC/N,GAAKsQ,QAAUtQ,GAAK4lB,UAAW,EAC/BiF,GAAmBzI,IAAcA,GAAW7V,QAC5CiW,GAAa,EACb5B,IAAaA,EAAS5K,QAAU,GAChCkO,IAAiB5lB,GAAgB6E,cAAe,cAAe+gB,IAC3D3B,KACHA,GAAgBhW,QAChBoU,EAAQpF,OAASoF,EAAQpF,MAAMzN,SAAW6S,EAAQpF,MAAQ,KAEtDrP,IAAY,SACZnL,EAAIqV,GAAUhV,OACXL,QACFqV,GAAUrV,GAAGoa,WAAaA,IAAY/E,GAAUrV,KAAOf,UAI5D1B,GAAgB6c,GAAU,SAAUjG,IACpChJ,IAAc5N,GAAgB6c,GAAU,SAAU3c,MAKrDwB,GAAK8N,KAAO,SAACC,EAAQ8c,GACpB7qB,GAAK2N,QAAQI,EAAQ8c,GACrBzI,KAAeyI,GAAkBzI,GAAWtU,OAC5ClE,UAAciV,GAAKjV,OACf7I,EAAIqV,GAAUxY,QAAQoC,IACrB,GAALe,GAAUqV,GAAUpI,OAAOjN,EAAG,GAC9BA,IAAMoV,IAAmB,EAAbiK,IAAkBjK,KAG9BpV,EAAI,EACJqV,GAAUnE,QAAQ,SAAAlS,UAAKA,EAAEob,WAAanb,GAAKmb,WAAapa,EAAI,KAC5DA,GAAKwV,KAAmBvW,GAAK6Y,OAAOrC,IAAM,GAEtCtG,IACHA,EAAUsJ,cAAgB,KAC1BzL,GAAUmC,EAAUnC,OAAO,CAACD,MAAM,IAClC+c,GAAkB3a,EAAUpC,QAE7BkT,GAAe,CAACA,EAAaC,EAAWC,EAAoBC,GAAkBlP,QAAQ,SAAAiI,UAAKA,EAAE5B,YAAc4B,EAAE5B,WAAWzB,YAAYqD,KACpI4C,KAAa9c,KAAS8c,GAAW,GAC7B3F,KACHyJ,IAAaA,EAAS5K,QAAU,GAChCjV,EAAI,EACJqV,GAAUnE,QAAQ,SAAAlS,UAAKA,EAAEoX,MAAQA,IAAOpW,MACxCA,IAAM6f,EAASxJ,OAAS,IAEzBjR,EAAK2kB,QAAU3kB,EAAK2kB,OAAO9qB,KAG5BoW,GAAUnV,KAAKjB,IACfA,GAAKyN,QAAO,GAAO,GACnBkV,GAAsBA,EAAmB3iB,IAErCkQ,GAAaA,EAAUM,MAAQ8Q,EAAQ,KACtCyJ,EAAa/qB,GAAK2B,OACtB3B,GAAK2B,OAAS,WACb3B,GAAK2B,OAASopB,EACdpsB,GAAWC,QACX6a,GAASC,GAAO1Z,GAAKsf,WAEtBjiB,GAAKyP,YAAY,IAAM9M,GAAK2B,QAC5B2f,EAAS,IACT7H,EAAQC,EAAM,OAEd1Z,GAAKsf,UAENnI,IA7gCkB,SAAnB6T,sBACKnO,KAAoBoC,GAAY,KAC/BrV,EAAKiT,GAAkBoC,GAC3B9U,sBAAsB,kBAAMP,IAAOqV,IAAcvJ,IAAY,MA0gCvDsV,aAxqBDrpB,OAASsK,KAAKqT,QAAUrT,KAAK6B,KAAOgB,kBA4qBpCX,SAAP,kBAAgB/K,UACVS,IACJxG,GAAO+F,GAAQhG,KACf4R,MAAmB1R,OAAOwG,UAAYX,cAAcsK,SACpD5J,EAAemZ,IAETnZ,iBAGDiN,SAAP,kBAAgBzQ,MACXA,MACE,IAAImF,KAAKnF,EACb8d,GAAU3Y,GAAKnF,EAAOmF,UAGjB2Y,kBAGDxQ,QAAP,iBAAetL,EAAOyL,GACrBkP,GAAW,EACX5G,GAAUnE,QAAQ,SAAAiE,UAAWA,EAAQpI,EAAO,OAAS,WAAWzL,KAChE/D,GAAgBa,GAAM,QAASX,IAC/BF,GAAgBsC,GAAM,SAAUpC,IAChCysB,cAAc7O,GACd9d,GAAgBsC,GAAM,cAAekO,IACrCxQ,GAAgB2F,GAAO,aAAc6K,IACrCgD,GAAexT,GAAiBsC,GAAM,mCAAoC+N,IAC1EmD,GAAexT,GAAiBsC,GAAM,6BAA8BiO,IACpE2G,EAAa1H,OACb6B,GAAoBrR,QACf,IAAIyC,EAAI,EAAGA,EAAIpC,GAAWyC,OAAQL,GAAG,EACzCoR,GAAe7T,GAAiBK,GAAWoC,GAAIpC,GAAWoC,EAAE,IAC5DoR,GAAe7T,GAAiBK,GAAWoC,GAAIpC,GAAWoC,EAAE,mBAIvD0M,OAAP,qBACCtO,GAAO7B,OACPsD,GAAOkD,SACPhD,GAASF,GAAKoD,gBACdC,GAAQrD,GAAKmD,KACT1G,KACH2Z,GAAW3Z,GAAK8C,MAAMC,QACtB8b,GAAS7e,GAAK8C,MAAM+D,MACpBC,EAAW9G,GAAK+F,KAAKgB,SAAW0K,GAChC2N,GAAsBpf,GAAK+F,KAAK8nB,oBAAsBpc,GACtD2H,EAAqBtX,GAAKC,QAAQC,mBAAqB,OACvD8gB,EAAchhB,GAAK8G,aAAe,EAClC5I,GAAK+F,KAAKC,QAAQ,gBAAiBF,eAC/Bc,IAAO,CACV+Y,GAAW,GACXrG,EAAY7S,SAASuP,cAAc,QACzBY,MAAMzE,OAAS,QACzBmH,EAAU1C,MAAM2D,SAAW,WAC3BlB,KAxyCU,SAAbyU,oBAAmBnO,IAAY7S,sBAAsBghB,YAyyClDA,GACA5mB,EAAS4J,SAAS9Q,IAElB8F,cAAcqB,QAAUD,EAASC,QACjCkY,EAAanY,EAASC,SAAW,0BAA0B+V,KAAK5V,UAAUymB,WAC1E7V,EAA2C,IAArBhR,EAASC,QAC/BxG,GAAamB,GAAM,QAASX,IAC5BT,EAAQ,CAACoB,GAAMyB,GAAME,GAAQmD,IACzB5G,GAAKoH,YACRtB,cAAcsB,WAAa,SAAA0B,OAEzBX,EADG6lB,EAAKhuB,GAAKoH,iBAETe,KAAKW,EACTklB,EAAG7a,IAAIhL,EAAGW,EAAKX,WAET6lB,GAERhuB,GAAKgB,iBAAiB,iBAAkB,kBAAM4X,OAC9C5Y,GAAKgB,iBAAiB,mBAAoB,kBAAMsX,OAChDtY,GAAKgB,iBAAiB,aAAc,WACnCqX,GAAY,EAAG,GACfZ,EAAU,gBAEXzX,GAAKoH,aAAa+L,IAAI,0BAA2B,kBAChDuE,KACOA,MAGRxU,QAAQC,KAAK,iCAEduU,KACA/W,GAAa4C,GAAM,SAAUpC,QAK5Bmb,EAAQ5Y,EAJLuqB,EAAernB,GAAMsnB,aAAa,SACrCC,EAAYvnB,GAAMgQ,MAClBwX,EAASD,EAAUE,eACnBC,EAAiBtuB,GAAK+F,KAAKwoB,UAAUC,cAEtCF,EAAe5d,QAAU+d,OAAOC,eAAeJ,EAAgB,SAAU,CAAE1sB,MAAO,wBAAoBgN,KAAKoN,MAAM,KAAM,MACvHmS,EAAUE,eAAiB,QAC3B/R,EAASlK,GAAWxL,IACpBjD,GAAUkZ,EAAI1a,KAAKC,MAAMka,EAAOK,IAAMhZ,GAAUL,OAAS,EACzD4E,GAAY2U,EAAI1a,KAAKC,MAAMka,EAAOI,KAAOxU,GAAY5E,OAAS,EAC9D8qB,EAAUD,EAAUE,eAAiBD,EAAUD,EAAUvR,eAAe,oBACnEqR,IACJrnB,GAAM+P,aAAa,QAAS,IAC5B/P,GAAM+nB,gBAAgB,UAGvB5P,EAAgB6P,YAAYxX,GAAO,KACnCpX,GAAKyP,YAAY,GAAK,kBAAM5N,GAAW,IACvClB,GAAa4C,GAAM,cAAekO,IAClC9Q,GAAaiG,GAAO,aAAc6K,IAClCgD,GAAe9T,GAAc4C,GAAM,mCAAoC+N,IACvEmD,GAAe9T,GAAc4C,GAAM,6BAA8BiO,IACjEwN,EAAiBhf,GAAK8C,MAAM+rB,YAAY,aACxCzT,GAAYxX,KAAKob,GACjBxY,EAAehC,KACf2T,EAAenY,GAAKyP,YAAY,GAAK4I,IAAanJ,QAClDsD,EAAe,CAACjP,GAAM,mBAAoB,eACrCurB,EAAIhtB,GAAKoQ,WACZ6c,EAAIjtB,GAAKuM,YACN9K,GAAKyrB,QACR/P,EAAa6P,EACb5P,EAAc6P,GACJ9P,IAAe6P,GAAK5P,IAAgB6P,GAC9ClX,MAECtU,GAAM,mBAAoB8U,GAAavW,GAAM,OAAQuW,GAAavW,GAAM,SAAU+V,IACrFvF,GAAoB3R,IACpBoY,GAAUnE,QAAQ,SAAAiE,UAAWA,EAAQzI,OAAO,EAAG,KAC1C1M,EAAI,EAAGA,EAAIpC,GAAWyC,OAAQL,GAAG,EACrCoR,GAAe7T,GAAiBK,GAAWoC,GAAIpC,GAAWoC,EAAE,IAC5DoR,GAAe7T,GAAiBK,GAAWoC,GAAIpC,GAAWoC,EAAE,oBAMzDV,OAAP,gBAAc8F,sBACQA,IAAUyW,KAAoBzW,EAAKmmB,oBACpDC,EAAKpmB,EAAKqmB,aACdD,GAAMtB,cAAc7O,KAAoBA,EAAgBmQ,IAAON,YAAYxX,GAAO8X,0BACzDpmB,IAAUoP,EAAgD,IAA1BpS,cAAcqB,SAAiB2B,EAAKsmB,oBACzF,sBAAuBtmB,IAC1BwJ,GAAoBrR,KAAoBqR,GAAoB3R,GAAcmI,EAAKumB,mBAAqB,QACpGtX,GAAqE,KAApDjP,EAAKumB,kBAAoB,IAAI9uB,QAAQ,0BAIjD+uB,cAAP,uBAAqBtrB,EAAQ8E,OACxBpG,EAAID,EAAWuB,GAClBN,EAAIpC,GAAWf,QAAQmC,GACvBmM,EAAarO,GAAYkC,IACrBgB,GACJpC,GAAWqP,OAAOjN,EAAGmL,EAAa,EAAI,GAEnC/F,IACH+F,EAAavO,GAASqrB,QAAQ7pB,GAAMgH,EAAMlC,GAAOkC,EAAMrF,GAAQqF,GAAQxI,GAASqrB,QAAQjpB,EAAGoG,mBAItFymB,gBAAP,yBAAuB9W,GACtBM,GAAUnE,QAAQ,SAAAlS,UAAKA,EAAEE,MAAQF,EAAEE,KAAK6V,QAAUA,GAAS/V,EAAEE,KAAK6N,MAAK,GAAM,oBAGvE+e,aAAP,sBAAoBpvB,EAASqe,EAAO0D,OAC/B7F,GAAUnL,GAAU/Q,GAAWqC,EAAWrC,GAAWA,GAASwgB,wBACjEpe,EAAS8Z,EAAO6F,EAAaxH,GAASE,IAAW4D,GAAS,SACpD0D,EAAqC,EAAxB7F,EAAO6E,MAAQ3e,GAAc8Z,EAAOI,KAAOla,EAASV,GAAKoQ,WAAsC,EAAzBoK,EAAO4E,OAAS1e,GAAc8Z,EAAOK,IAAMna,EAASV,GAAKuM,2BAG7IohB,mBAAP,4BAA0BrvB,EAASsvB,EAAgBvN,GAClDhR,GAAU/Q,KAAaA,EAAUqC,EAAWrC,QACxCkc,EAASlc,EAAQwgB,wBACpB1L,EAAOoH,EAAO6F,EAAaxH,GAASE,IACpCrY,EAA2B,MAAlBktB,EAAyBxa,EAAO,EAAMwa,KAAkBpa,EAAaA,EAAUoa,GAAkBxa,GAAQwa,EAAenvB,QAAQ,KAAOmO,WAAWghB,GAAkBxa,EAAO,IAAMxG,WAAWghB,IAAmB,SAClNvN,GAAc7F,EAAOI,KAAOla,GAAUV,GAAKoQ,YAAcoK,EAAOK,IAAMna,GAAUV,GAAKuM,2BAGtFshB,QAAP,iBAAeC,MACd7W,GAAU/H,MAAM,GAAG4D,QAAQ,SAAAlS,SAAmB,mBAAdA,EAAEoG,KAAKyD,IAA2B7J,EAAE+N,UAC7C,IAAnBmf,EAAyB,KACxBC,EAAYpO,EAAWkO,SAAW,GACtClO,EAAa,GACboO,EAAUjb,QAAQ,SAAAnT,UAAKA,8CAz2BbqH,EAAM+J,GACjBrM,GAAgBV,cAAcgL,SAAS9Q,KAASkD,QAAQC,KAAK,6CAC7D2D,EAAS8H,WACJ/F,KAAKC,EAAM+J,MA42BJjC,QAAU,YACVkf,WAAa,SAAA5G,UAAWA,EAAUvP,GAASuP,GAAStU,QAAQ,SAAA5Q,MACrEA,GAAUA,EAAO4S,MAAO,KACvBlT,EAAI8U,EAAajY,QAAQyD,GACxB,GAALN,GAAU8U,EAAa7H,OAAOjN,EAAG,GACjC8U,EAAa5U,KAAKI,EAAQA,EAAO4S,MAAMC,QAAS7S,EAAO0U,SAAW1U,EAAO+rB,aAAa,aAAc/vB,GAAK+F,KAAKoX,SAASnZ,GAAS8C,QAE7H0R,MACS9H,OAAS,SAAC4Z,EAAM/R,UAAUK,IAAY0R,EAAM/R,OAC5C1H,OAAS,SAAC/H,EAAM+J,UAAc,IAAI/M,GAAcgD,EAAM+J,OACtDoP,QAAU,SAAA+N,UAAQA,EAAOnY,IAAU,IAASrR,GAAgBV,GAAcgL,aAAeuH,IAAY,OACrG/T,OAAS,SAAAC,WAAWjD,GAAWC,OAASgW,GAAqB,IAAVhT,EAAiB,EAAI,OACxE0rB,kBAAoBhX,MACpBiX,UAAY,SAAC9vB,EAAS+hB,UAAe9P,GAAWjS,EAAS+hB,EAAaja,GAAcvE,QACpFwsB,cAAgB,SAAC/vB,EAAS+hB,UAAe/e,EAAeX,EAAWrC,GAAU+hB,EAAaja,GAAcvE,QACxGsN,QAAU,SAAA1E,UAAMiV,GAAKjV,OACrBwE,OAAS,kBAAMgI,GAAUxI,OAAO,SAAA7N,SAAmB,mBAAdA,EAAEoG,KAAKyD,SAC5C6jB,YAAc,mBAAQ/Y,OACtBgZ,gBAAkBtc,MAClB/S,iBAAmB,SAACJ,EAAM+T,OACnChP,EAAI8b,EAAW7gB,KAAU6gB,EAAW7gB,GAAQ,KAC/C+E,EAAEpF,QAAQoU,IAAahP,EAAE/B,KAAK+Q,OAElBzT,oBAAsB,SAACN,EAAM+T,OACtChP,EAAI8b,EAAW7gB,GAClB8C,EAAIiC,GAAKA,EAAEpF,QAAQoU,GACf,GAALjR,GAAUiC,EAAEgL,OAAOjN,EAAG,OAET4sB,MAAQ,SAACpH,EAASpgB,GAKd,SAAhBynB,GAAiB3vB,EAAM+T,OAClB6b,EAAW,GACdC,EAAW,GACXpI,EAAQroB,GAAKyP,YAAYihB,EAAU,WAAO/b,EAAS6b,EAAUC,GAAWD,EAAW,GAAIC,EAAW,KAAMvhB,eAClG,SAAAvM,GACN6tB,EAASzsB,QAAUskB,EAAMpa,SAAQ,GACjCuiB,EAAS5sB,KAAKjB,EAAKkW,SACnB4X,EAAS7sB,KAAKjB,GACdguB,GAAYH,EAASzsB,QAAUskB,EAAMtV,SAAS,QAGhD5K,EAfG+K,EAAS,GACZ0d,EAAW,GACXF,EAAW5nB,EAAK4nB,UAAY,KAC5BC,EAAW7nB,EAAK6nB,UAAY,QAaxBxoB,KAAKW,EACT8nB,EAASzoB,GAAyB,OAAnBA,EAAEiJ,OAAO,EAAG,IAAeqB,GAAY3J,EAAKX,KAAa,kBAANA,EAAyBooB,GAAcpoB,EAAGW,EAAKX,IAAMW,EAAKX,UAEzHsK,GAAYke,KACfA,EAAWA,IACXhwB,GAAamF,GAAe,UAAW,kBAAM6qB,EAAW7nB,EAAK6nB,cAE9DhX,GAASuP,GAAStU,QAAQ,SAAA5Q,OACrBhB,EAAS,OACRmF,KAAKyoB,EACT5tB,EAAOmF,GAAKyoB,EAASzoB,GAEtBnF,EAAO6V,QAAU7U,EACjBkP,EAAOtP,KAAKkC,GAAc+K,OAAO7N,MAE3BkQ,GAKmC,SAAvC2d,GAAwC9b,EAAY2I,EAASrB,EAAKtX,UAC1DA,EAAV2Y,EAAgB3I,EAAWhQ,GAAO2Y,EAAU,GAAK3I,EAAW,GAC/ChQ,EAANsX,GAAatX,EAAM2Y,IAAYrB,EAAMqB,GAAWrB,EAAM,EAAIqB,GAAWA,EAAUrB,GAAO,EAExE,SAAtByU,GAAuB9sB,EAAQsQ,IACZ,IAAdA,EACHtQ,EAAO4S,MAAMgG,eAAe,gBAE5B5Y,EAAO4S,MAAMma,aAA4B,IAAdzc,EAAqB,OAASA,EAAY,OAASA,GAAapN,EAASC,QAAU,cAAgB,IAAM,OAErInD,IAAWP,IAAUqtB,GAAoBlqB,GAAO0N,GAGjC,SAAhB0c,UAGqBhX,EAHHzQ,IAAAA,MAAOvF,IAAAA,OAAQgJ,IAAAA,KAC5BikB,GAAQ1nB,EAAM9D,eAAiB8D,EAAM9D,eAAe,GAAK8D,GAAOvF,OACnEzC,EAAQ0vB,EAAK/W,OAASla,GAAK+F,KAAKoX,SAAS8T,GACzCjV,EAAOxX,SACHjD,EAAM2vB,YAAwC,IAA1BlV,EAAOza,EAAM2vB,WAAmB,MACjDD,GAAQA,IAASrqB,KAAWqqB,EAAKE,cAAgBF,EAAKG,cAAgBH,EAAKI,aAAeJ,EAAKzZ,cAAkB8Z,IAAWtX,EAAK1G,GAAkB2d,IAAOM,aAAcD,GAAUtX,EAAGwX,aAAcP,EAAOA,EAAKhW,WACtN1Z,EAAMkwB,UAAYR,GAAQA,IAASjtB,IAAWxD,GAAYywB,KAAUK,IAAWtX,EAAK1G,GAAkB2d,IAAOM,YAAcD,GAAUtX,EAAGwX,YACxIjwB,EAAM2vB,WAAalV,GAEhBza,EAAMkwB,WAAsB,MAATzkB,IACtBzD,EAAMmoB,kBACNnoB,EAAM/D,YAAa,GAIJ,SAAjBmsB,GAAkB3tB,EAAQpD,EAAMgxB,EAAQC,UAAW3qB,EAAS2J,OAAO,CAClE7M,OAAQA,EACRjD,SAAS,EACTmI,UAAU,EACViC,UAAU,EACVvK,KAAMA,EACNiK,QAAUgnB,EAASA,GAAUb,GAC7BrnB,QAASkoB,EACTnoB,OAAQmoB,EACRlkB,SAAUkkB,EACV/mB,SAAU,2BAAM8mB,GAAUjxB,GAAa4C,GAAM2D,EAASQ,WAAW,GAAIoqB,IAAgB,GAAO,IAC5F/mB,UAAW,4BAAM9J,GAAgBsC,GAAM2D,EAASQ,WAAW,GAAIoqB,IAAgB,MAWzD,SAAvBC,GAAuBjpB,GAoBH,SAAlBkpB,YAAwBC,GAAgB,EAGzB,SAAfC,KACCC,EAAO9f,GAAWrO,EAAQL,IAC1ByuB,EAAevT,GAAOQ,EAAa,EAAI,EAAG8S,GAC1CE,IAAqBC,EAAezT,GAAO,EAAGxM,GAAWrO,EAAQkE,MACjEqqB,EAAgB3Q,GAEK,SAAtB4Q,KACC/I,EAAQvP,MAAMxN,EAAIgF,GAAOhD,WAAW+a,EAAQvP,MAAMxN,GAAKmB,EAAYrL,QAAU,KAC7EinB,EAAQ7S,MAAM6b,UAAY,mDAAqD/jB,WAAW+a,EAAQvP,MAAMxN,GAAK,UAC7GmB,EAAYrL,OAASqL,EAAYvL,QAAU,EAqBjC,SAAXowB,KACCR,KACIhU,EAAMqK,YAAcrK,EAAMpV,KAAKiF,QAAUokB,IAC5CtkB,IAAgBskB,EAAOjU,EAAMnL,SAAS,IAAMlF,EAAYskB,GAAQjU,EAAM4K,QAAQ,UAAWqJ,IAvD5Fxf,GAAU7J,KAAUA,EAAO,IAC3BA,EAAKvD,eAAiBuD,EAAK4B,aAAe5B,EAAKoC,aAAc,EAC7DpC,EAAKlI,OAASkI,EAAKlI,KAAO,eAC1BkI,EAAKI,WAAaJ,EAAKI,SACvBJ,EAAKyD,GAAKzD,EAAKyD,IAAM,iBAEpB5J,EAAMwvB,EAWNI,EAAeN,EAkCf/T,EAAOyU,EAAcC,EAAc5kB,EA9C/BqkB,EAA4DvpB,EAA5DupB,iBAAkBQ,EAA0C/pB,EAA1C+pB,SAAUC,EAAgChqB,EAAhCgqB,kBAAmBlpB,EAAad,EAAbc,UAEnD5F,EAASvB,EAAWqG,EAAK9E,SAAWP,GACpCsvB,EAAW/yB,GAAK+F,KAAKC,UAAUgtB,eAC/BC,EAAmBF,GAAYA,EAASG,MACxCzJ,EAAUpK,IAAgBvW,EAAK2gB,SAAWhnB,EAAWqG,EAAK2gB,UAAcwJ,IAAqC,IAAjBnqB,EAAK2gB,UAAsBwJ,EAAiBhvB,UAAYgvB,EAAiBxJ,WACrK5b,EAAczK,EAAeY,EAAQL,IACrCiK,EAAcxK,EAAeY,EAAQkE,IACrCuY,EAAQ,EACR0S,GAAgBjsB,EAASC,SAAWrF,GAAKsxB,eAAiBtxB,GAAKsxB,eAAe3S,MAAQ3e,GAAKsxB,eAAenhB,MAAQnQ,GAAKuxB,YAAcvxB,GAAKoQ,WAC1IohB,EAAe,EACfC,EAA0B9gB,GAAYogB,GAAY,kBAAMA,EAASlwB,IAAQ,kBAAMkwB,GAAY,KAE3FW,EAAgB7B,GAAe3tB,EAAQ8E,EAAKlI,MAAM,EAAMkyB,GAExDR,EAAe7gB,GACf2gB,EAAe3gB,UAqChBgY,GAAWzpB,GAAK4d,IAAI6L,EAAS,CAAC/c,EAAG,QACjC5D,EAAK2B,YAAc,SAAAnF,UAAM+Z,GAAyB,cAAX/Z,EAAE1E,MA1B3B,SAAb6yB,gBACKxB,EAAe,CAClBnlB,sBAAsBklB,QAClBxvB,EAASkP,GAAO/O,EAAKmJ,OAAS,GACjC0P,EAAS4W,EAAavkB,EAAY3L,EAAIM,MACnCinB,GAAWjO,IAAW3N,EAAY3L,EAAI2L,EAAYrL,OAAQ,CAC7DqL,EAAYrL,OAASgZ,EAAS3N,EAAY3L,MACtCwK,EAAIgF,IAAQhD,WAAW+a,GAAWA,EAAQvP,MAAMxN,IAAM,GAAKmB,EAAYrL,QAC3EinB,EAAQ7S,MAAM6b,UAAY,mDAAqD/lB,EAAI,UACnF+c,EAAQvP,MAAMxN,EAAIA,EAAI,KACtBmB,EAAYvL,QAAUhB,GAAWC,MACjCgW,WAEM,EAER1J,EAAYrL,QAAUgwB,KACtBP,GAAgB,EAU+CwB,IAA2B,KAARhT,GAA2B,eAAXnb,EAAE1E,MAA0B+B,EAAK8K,aAAgBnI,EAAEkI,SAA8B,EAAnBlI,EAAEkI,QAAQzJ,QAC5K+E,EAAKa,QAAU,WACdsoB,GAAgB,MACZyB,EAAYjT,EAChBA,EAAQ/O,IAAS5P,GAAKsxB,gBAAkBtxB,GAAKsxB,eAAe3S,OAAU,GAAK0S,GAC3EjV,EAAMhP,QACNwkB,IAAcjT,GAASqQ,GAAoB9sB,EAAgB,KAARyc,IAAsB4R,GAA2B,KACpGM,EAAe/kB,IACfglB,EAAe/kB,IACfqkB,KACAK,EAAgB3Q,IAEjB9Y,EAAKc,UAAYd,EAAK6B,eAAiB,SAAChI,EAAM2M,MAC7CzB,EAAYrL,QAAUgwB,KACjBljB,EAEE,CACNhO,GAAWC,YAGVoyB,EAAelL,EADZmL,EAAML,IAENlB,IAEH5J,GADAkL,EAAgB/lB,KACmB,IAANgmB,GAAcjxB,EAAKkxB,UAAa,KAC7DD,GAAO/C,GAAqCjjB,EAAa+lB,EAAelL,EAAWpW,GAAWrO,EAAQkE,KACtGgW,EAAMpV,KAAKgF,QAAUwkB,EAAa7J,IAGnCA,GADAkL,EAAgB9lB,KACmB,IAAN+lB,GAAcjxB,EAAKmxB,UAAa,KAC7DF,GAAO/C,GAAqChjB,EAAa8lB,EAAelL,EAAWpW,GAAWrO,EAAQL,KACtGua,EAAMpV,KAAKiF,QAAUqkB,EAAa3J,GAClCvK,EAAMsM,aAAa1W,SAAS8f,GAAKG,KAAK,MAClC1U,GAAcnB,EAAMpV,KAAKiF,SAAWokB,GAAyBA,EAAK,GAAtBwB,IAC/C3zB,GAAK4e,GAAG,GAAI,CAACF,SAAUgU,GAAU5e,SAAU8f,SAlB5C5lB,EAAkBC,SAAQ,GAqB3BrE,GAAaA,EAAUjH,IAExBmG,EAAK+B,QAAU,WACdqT,EAAM8V,KAAO9V,EAAMhP,QACa,IAA5B1K,KAAa8uB,IAChBf,EAAgB,EAChBe,EAAe9uB,OAGjBsE,EAAKqB,SAAW,SAACxH,EAAMgJ,EAAIE,EAAIooB,EAAQC,MACtCtS,KAAe2Q,GAAiBL,KAChCvmB,GAAM0mB,GAAoBzkB,EAAY0kB,EAAa2B,EAAO,KAAOtoB,EAAKgnB,GAAgBhwB,EAAK0K,OAAS1K,EAAK8J,GAAKmB,IAAgBjC,EAAKsoB,EAAO,KACtIpoB,EAAI,CACPgC,EAAYrL,QAAUgwB,SAClBrrB,EAAU+sB,EAAO,KAAOroB,EAC3Ba,EAAIvF,EAAUyrB,EAAejwB,EAAK2K,OAAS3K,EAAK+J,EAAImB,IAAgBhC,EAAKqoB,EAAO,GAChFC,EAAW/B,EAAa1lB,GACzBvF,GAAWuF,IAAMynB,IAAavB,GAAgBuB,EAAWznB,GACzDmB,EAAYsmB,IAEZtoB,GAAMF,IAAO4L,KAEfzO,EAAKgC,SAAW,WACfgmB,GAAoB9sB,GAAQquB,GAA2B,KACvDvsB,GAAc9E,iBAAiB,UAAW0xB,IAC1C/xB,GAAamB,GAAM,SAAU4wB,IACzB7kB,EAAY5J,SACf4J,EAAY7J,OAAO4S,MAAMoL,eAAiB,OAC1CnU,EAAY5J,OAAS2J,EAAY3J,QAAS,GAE3CuvB,EAAcpjB,UAEftH,EAAKiC,UAAY,WAChB+lB,GAAoB9sB,GAAQ,GAC5B/C,GAAgBa,GAAM,SAAU4wB,IAChC5sB,GAAc5E,oBAAoB,UAAWwxB,IAC7Cc,EAAc/iB,QAEf3H,EAAKqC,UAA6B,IAAlBrC,EAAKqC,WACrBxI,EAAO,IAAIuE,EAAS4B,IACfzG,IAAMgd,KACIxR,KAAiBA,EAAY,GAC5CwR,GAAcrf,GAAKo0B,OAAOjhB,IAAI1B,IAC9BzD,EAAoBrL,EAAKuN,IACzBgO,EAAQle,GAAK4e,GAAGjc,EAAM,CAAC8kB,KAAM,SAAUE,QAAQ,EAAMnJ,SAAS,EAAO1Q,QAASukB,EAAmB,QAAU,MAAOtkB,QAAS,QAASqQ,UAAW,CAACrQ,QAASqP,GAAqBvP,EAAaA,IAAe,kBAAMqQ,EAAMhP,WAAYwP,SAAUnH,EAAY4G,WAAYnQ,EAAkBlF,KAAKqV,aACpRxb,EA/LT,IA0CC0xB,GA9BA/C,GAAY,CAACgD,KAAM,EAAG9Y,OAAQ,GA6B9B+Y,GAAY,iCAEZzC,GAAiB,SAAjBA,eAAiBxsB,OACZkvB,EAAUD,GAAUrX,KAAK5X,EAAEtB,OAAOywB,UAClCD,GAAWH,MACd/uB,EAAEE,YAAa,EACf6uB,GAAkBG,OAmJPpgB,KAAO,SAAAvT,MAChB4R,GAAY5R,UACRkY,GAAU3E,KAAKvT,OAEnB2a,EAAS1Z,GAAK8G,aAAe,SACjC9C,GAAciL,SAAS6D,QAAQ,SAAAlS,UAAKA,EAAEgyB,OAAShyB,EAAEmW,QAAU2C,EAAS9Y,EAAEmW,QAAQ+H,wBAAwBjE,IAAMja,EAAE0Z,MAAQta,GAAKuM,cACpH0K,GAAU3E,KAAKvT,GAAS,SAAC8E,EAAG0O,UAAuC,KAAhC1O,EAAEmD,KAAKwe,iBAAmB,IAAa3hB,EAAEmD,KAAK4M,mBAAqB,IAAM/P,EAAE+uB,UAAYrgB,EAAEvL,KAAK4M,mBAAqB,IAAMrB,EAAEqgB,SAA2C,KAAhCrgB,EAAEvL,KAAKwe,iBAAmB,UAE7LqN,QAAU,SAAA7rB,UAAQ,IAAI5B,EAAS4B,OAC/B8rB,gBAAkB,SAAA9rB,WACV,IAAVA,SACH1H,MAEK,IAAT0H,GAAiB1H,SACbA,EAAYgP,aAEP,IAATtH,SACH1H,GAAeA,EAAYqP,YAC3BrP,EAAc0H,OAGX+rB,EAAa/rB,aAAgB5B,EAAW4B,EAAOipB,GAAqBjpB,UACxE1H,GAAeA,EAAY4C,SAAW6wB,EAAW7wB,QAAU5C,EAAYqP,OACvEjQ,GAAYq0B,EAAW7wB,UAAY5C,EAAcyzB,GAC1CA,MAIM9uB,KAAO,CACpB5B,iBAAAA,EACAwtB,eAAAA,GACArwB,WAAAA,GACAhB,SAAAA,GACA6F,OAAQ,CAEP2uB,GAAI,cACHzd,IAAmBI,EAAU,eAC7BJ,GAAkB7S,MAGnBuwB,IAAK,sBAAMjd,YAIC9X,GAAKE,eAAe4F"} \ No newline at end of file diff --git a/dot-line-system/public/gsap.min.js b/dot-line-system/public/gsap.min.js new file mode 100644 index 0000000..c0f9bfa --- /dev/null +++ b/dot-line-system/public/gsap.min.js @@ -0,0 +1,11 @@ +/*! + * GSAP 3.12.7 + * https://gsap.com + * + * @license Copyright 2025, GreenSock. All rights reserved. + * Subject to the terms at https://gsap.com/standard-license or for Club GSAP members, the agreement issued with that membership. + * @author: Jack Doyle, jack@greensock.com + */ + +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).window=t.window||{})}(this,function(e){"use strict";function _inheritsLoose(t,e){t.prototype=Object.create(e.prototype),(t.prototype.constructor=t).__proto__=e}function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function r(t){return"string"==typeof t}function s(t){return"function"==typeof t}function t(t){return"number"==typeof t}function u(t){return void 0===t}function v(t){return"object"==typeof t}function w(t){return!1!==t}function x(){return"undefined"!=typeof window}function y(t){return s(t)||r(t)}function P(t){return(i=yt(t,ot))&&ze}function Q(t,e){return console.warn("Invalid property",t,"set to",e,"Missing plugin? gsap.registerPlugin()")}function R(t,e){return!e&&console.warn(t)}function S(t,e){return t&&(ot[t]=e)&&i&&(i[t]=e)||ot}function T(){return 0}function ea(t){var e,r,i=t[0];if(v(i)||s(i)||(t=[t]),!(e=(i._gsap||{}).harness)){for(r=gt.length;r--&&!gt[r].targetTest(i););e=gt[r]}for(r=t.length;r--;)t[r]&&(t[r]._gsap||(t[r]._gsap=new Vt(t[r],e)))||t.splice(r,1);return t}function fa(t){return t._gsap||ea(Mt(t))[0]._gsap}function ga(t,e,r){return(r=t[e])&&s(r)?t[e]():u(r)&&t.getAttribute&&t.getAttribute(e)||r}function ha(t,e){return(t=t.split(",")).forEach(e)||t}function ia(t){return Math.round(1e5*t)/1e5||0}function ja(t){return Math.round(1e7*t)/1e7||0}function ka(t,e){var r=e.charAt(0),i=parseFloat(e.substr(2));return t=parseFloat(t),"+"===r?t+i:"-"===r?t-i:"*"===r?t*i:t/i}function la(t,e){for(var r=e.length,i=0;t.indexOf(e[i])<0&&++ia;)s=s._prev;return s?(e._next=s._next,s._next=e):(e._next=t[r],t[r]=e),e._next?e._next._prev=e:t[i]=e,e._prev=s,e.parent=e._dp=t,e}function ya(t,e,r,i){void 0===r&&(r="_first"),void 0===i&&(i="_last");var n=e._prev,a=e._next;n?n._next=a:t[r]===e&&(t[r]=a),a?a._prev=n:t[i]===e&&(t[i]=n),e._next=e._prev=e.parent=null}function za(t,e){t.parent&&(!e||t.parent.autoRemoveChildren)&&t.parent.remove&&t.parent.remove(t),t._act=0}function Aa(t,e){if(t&&(!e||e._end>t._dur||e._start<0))for(var r=t;r;)r._dirty=1,r=r.parent;return t}function Ca(t,e,r,i){return t._startAt&&(L?t._startAt.revert(ht):t.vars.immediateRender&&!t.vars.autoRevert||t._startAt.render(e,!0,i))}function Ea(t){return t._repeat?Tt(t._tTime,t=t.duration()+t._rDelay)*t:0}function Ga(t,e){return(t-e._start)*e._ts+(0<=e._ts?0:e._dirty?e.totalDuration():e._tDur)}function Ha(t){return t._end=ja(t._start+(t._tDur/Math.abs(t._ts||t._rts||X)||0))}function Ia(t,e){var r=t._dp;return r&&r.smoothChildTiming&&t._ts&&(t._start=ja(r._time-(0X)&&e.render(r,!0)),Aa(t,e)._dp&&t._initted&&t._time>=t._dur&&t._ts){if(t._dur(n=Math.abs(n))&&(a=i,o=n);return a}function tb(t){return za(t),t.scrollTrigger&&t.scrollTrigger.kill(!!L),t.progress()<1&&Ct(t,"onInterrupt"),t}function wb(t){if(t)if(t=!t.name&&t.default||t,x()||t.headless){var e=t.name,r=s(t),i=e&&!r&&t.init?function(){this._props=[]}:t,n={init:T,render:he,add:Wt,kill:ce,modifier:fe,rawVars:0},a={targetTest:0,get:0,getSetter:ne,aliases:{},register:0};if(Ft(),t!==i){if(pt[e])return;qa(i,qa(ua(t,n),a)),yt(i.prototype,yt(n,ua(t,a))),pt[i.prop=e]=i,t.targetTest&&(gt.push(i),ft[e]=1),e=("css"===e?"CSS":e.charAt(0).toUpperCase()+e.substr(1))+"Plugin"}S(e,i),t.register&&t.register(ze,i,_e)}else At.push(t)}function zb(t,e,r){return(6*(t+=t<0?1:1>16,e>>8&St,e&St]:0:zt.black;if(!p){if(","===e.substr(-1)&&(e=e.substr(0,e.length-1)),zt[e])p=zt[e];else if("#"===e.charAt(0)){if(e.length<6&&(e="#"+(n=e.charAt(1))+n+(a=e.charAt(2))+a+(s=e.charAt(3))+s+(5===e.length?e.charAt(4)+e.charAt(4):"")),9===e.length)return[(p=parseInt(e.substr(1,6),16))>>16,p>>8&St,p&St,parseInt(e.substr(7),16)/255];p=[(e=parseInt(e.substr(1),16))>>16,e>>8&St,e&St]}else if("hsl"===e.substr(0,3))if(p=c=e.match(tt),r){if(~e.indexOf("="))return p=e.match(et),i&&p.length<4&&(p[3]=1),p}else o=+p[0]%360/360,u=p[1]/100,n=2*(h=p[2]/100)-(a=h<=.5?h*(u+1):h+u-h*u),3=U?u.endTime(!1):t._dur;return r(e)&&(isNaN(e)||e in o)?(a=e.charAt(0),s="%"===e.substr(-1),n=e.indexOf("="),"<"===a||">"===a?(0<=n&&(e=e.replace(/=/,"")),("<"===a?u._start:u.endTime(0<=u._repeat))+(parseFloat(e.substr(1))||0)*(s?(n<0?u:i).totalDuration()/100:1)):n<0?(e in o||(o[e]=h),o[e]):(a=parseFloat(e.charAt(n-1)+e.substr(n+1)),s&&i&&(a=a/100*(Z(i)?i[0]:i).totalDuration()),1=r&&te)return i;i=i._next}else for(i=t._last;i&&i._start>=r;){if("isPause"===i.data&&i._start=n._start)&&n._ts&&h!==n){if(n.parent!==this)return this.render(t,e,r);if(n.render(0=this.totalDuration()||!v&&_)&&(f!==this._start&&Math.abs(l)===Math.abs(this._ts)||this._lock||(!t&&g||!(v===m&&0=i&&(a instanceof $t?e&&n.push(a):(r&&n.push(a),t&&n.push.apply(n,a.getChildren(!0,e,r)))),a=a._next;return n},e.getById=function getById(t){for(var e=this.getChildren(1,1,1),r=e.length;r--;)if(e[r].vars.id===t)return e[r]},e.remove=function remove(t){return r(t)?this.removeLabel(t):s(t)?this.killTweensOf(t):(t.parent===this&&ya(this,t),t===this._recent&&(this._recent=this._last),Aa(this))},e.totalTime=function totalTime(t,e){return arguments.length?(this._forcing=1,!this._dp&&this._ts&&(this._start=ja(Rt.time-(0r:!r||s.isActive())&&n.push(s):(i=s.getTweensOf(a,r)).length&&n.push.apply(n,i),s=s._next;return n},e.tweenTo=function tweenTo(t,e){e=e||{};var r,i=this,n=xt(i,t),a=e.startAt,s=e.onStart,o=e.onStartParams,u=e.immediateRender,h=$t.to(i,qa({ease:e.ease||"none",lazy:!1,immediateRender:!1,time:n,overwrite:"auto",duration:e.duration||Math.abs((n-(a&&"time"in a?a.time:i._time))/i.timeScale())||X,onStart:function onStart(){if(i.pause(),!r){var t=e.duration||Math.abs((n-(a&&"time"in a?a.time:i._time))/i.timeScale());h._dur!==t&&Ra(h,t,0,1).render(h._time,!0,!0),r=1}s&&s.apply(h,o||[])}},e));return u?h.render(0):h},e.tweenFromTo=function tweenFromTo(t,e,r){return this.tweenTo(e,qa({startAt:{time:xt(this,t)}},r))},e.recent=function recent(){return this._recent},e.nextLabel=function nextLabel(t){return void 0===t&&(t=this._time),rb(this,xt(this,t))},e.previousLabel=function previousLabel(t){return void 0===t&&(t=this._time),rb(this,xt(this,t),1)},e.currentLabel=function currentLabel(t){return arguments.length?this.seek(t,!0):this.previousLabel(this._time+X)},e.shiftChildren=function shiftChildren(t,e,r){void 0===r&&(r=0);for(var i,n=this._first,a=this.labels;n;)n._start>=r&&(n._start+=t,n._end+=t),n=n._next;if(e)for(i in a)a[i]>=r&&(a[i]+=t);return Aa(this)},e.invalidate=function invalidate(t){var e=this._first;for(this._lock=0;e;)e.invalidate(t),e=e._next;return i.prototype.invalidate.call(this,t)},e.clear=function clear(t){void 0===t&&(t=!0);for(var e,r=this._first;r;)e=r._next,this.remove(r),r=e;return this._dp&&(this._time=this._tTime=this._pTime=0),t&&(this.labels={}),Aa(this)},e.totalDuration=function totalDuration(t){var e,r,i,n=0,a=this,s=a._last,o=U;if(arguments.length)return a.timeScale((a._repeat<0?a.duration():a.totalDuration())/(a.reversed()?-t:t));if(a._dirty){for(i=a.parent;s;)e=s._prev,s._dirty&&s.totalDuration(),o<(r=s._start)&&a._sort&&s._ts&&!a._lock?(a._lock=1,Ka(a,s,r-s._delay,1)._lock=0):o=r,r<0&&s._ts&&(n-=r,(!i&&!a._dp||i&&i.smoothChildTiming)&&(a._start+=r/a._ts,a._time-=r,a._tTime-=r),a.shiftChildren(-r,!1,-Infinity),o=0),s._end>n&&s._ts&&(n=s._end),s=e;Ra(a,a===I&&a._time>n?a._time:n,1,1),a._dirty=0}return a._tDur},Timeline.updateRoot=function updateRoot(t){if(I._ts&&(na(I,Ga(t,I)),f=Rt.frame),Rt.frame>=mt){mt+=q.autoSleep||120;var e=I._first;if((!e||!e._ts)&&q.autoSleep&&Rt._listeners.length<2){for(;e&&!e._ts;)e=e._next;e||Rt.sleep()}}},Timeline}(Ut);qa(Xt.prototype,{_lock:0,_hasPause:0,_forcing:0});function ac(t,e,i,n,a,o){var u,h,l,f;if(pt[t]&&!1!==(u=new pt[t]).init(a,u.rawVars?e[t]:function _processVars(t,e,i,n,a){if(s(t)&&(t=Kt(t,a,e,i,n)),!v(t)||t.style&&t.nodeType||Z(t)||$(t))return r(t)?Kt(t,a,e,i,n):t;var o,u={};for(o in t)u[o]=Kt(t[o],a,e,i,n);return u}(e[t],n,a,o,i),i,n,o)&&(i._pt=h=new _e(i._pt,a,t,0,1,u.render,u,0,u.priority),i!==d))for(l=i._ptLookup[i._targets.indexOf(a)],f=u._props.length;f--;)l[u._props[f]]=h;return u}function gc(t,r,e,i){var n,a,s=r.ease||i||"power1.inOut";if(Z(r))a=e[t]||(e[t]=[]),r.forEach(function(t,e){return a.push({t:e/(r.length-1)*100,v:t,e:s})});else for(n in r)a=e[n]||(e[n]=[]),"ease"===n||a.push({t:parseFloat(t),v:r[n],e:s})}var Nt,Gt,Wt=function _addPropTween(t,e,i,n,a,o,u,h,l,f){s(n)&&(n=n(a||0,t,o));var d,c=t[e],p="get"!==i?i:s(c)?l?t[e.indexOf("set")||!s(t["get"+e.substr(3)])?e:"get"+e.substr(3)](l):t[e]():c,_=s(c)?l?re:te:Zt;if(r(n)&&(~n.indexOf("random(")&&(n=ob(n)),"="===n.charAt(1)&&(!(d=ka(p,n)+(Ya(p)||0))&&0!==d||(n=d))),!f||p!==n||Gt)return isNaN(p*n)||""===n?(c||e in t||Q(e,n),function _addComplexStringPropTween(t,e,r,i,n,a,s){var o,u,h,l,f,d,c,p,_=new _e(this._pt,t,e,0,1,ue,null,n),m=0,g=0;for(_.b=r,_.e=i,r+="",(c=~(i+="").indexOf("random("))&&(i=ob(i)),a&&(a(p=[r,i],t,e),r=p[0],i=p[1]),u=r.match(it)||[];o=it.exec(i);)l=o[0],f=i.substring(m,o.index),h?h=(h+1)%5:"rgba("===f.substr(-5)&&(h=1),l!==u[g++]&&(d=parseFloat(u[g-1])||0,_._pt={_next:_._pt,p:f||1===g?f:",",s:d,c:"="===l.charAt(1)?ka(d,l)-d:parseFloat(l)-d,m:h&&h<4?Math.round:0},m=it.lastIndex);return _.c=m")}),s.duration();else{for(l in u={},x)"ease"===l||"easeEach"===l||gc(l,x[l],u,x.easeEach);for(l in u)for(A=u[l].sort(function(t,e){return t.t-e.t}),o=E=0;o=t._tDur||e<0)&&t.ratio===u&&(u&&za(t,1),r||L||(Ct(t,u?"onComplete":"onReverseComplete",!0),t._prom&&t._prom()))}else t._zTime||(t._zTime=e)}(this,t,e,r);return this},e.targets=function targets(){return this._targets},e.invalidate=function invalidate(t){return t&&this.vars.runBackwards||(this._startAt=0),this._pt=this._op=this._onUpdate=this._lazy=this.ratio=0,this._ptLookup=[],this.timeline&&this.timeline.invalidate(t),D.prototype.invalidate.call(this,t)},e.resetTo=function resetTo(t,e,r,i,n){c||Rt.wake(),this._ts||this.play();var a,s=Math.min(this._dur,(this._dp._time-this._start)*this._ts);return this._initted||Qt(this,s),a=this._ease(s/this._dur),function _updatePropTweens(t,e,r,i,n,a,s,o){var u,h,l,f,d=(t._pt&&t._ptCache||(t._ptCache={}))[e];if(!d)for(d=t._ptCache[e]=[],l=t._ptLookup,f=t._targets.length;f--;){if((u=l[f][e])&&u.d&&u.d._pt)for(u=u.d._pt;u&&u.p!==e&&u.fp!==e;)u=u._next;if(!u)return Gt=1,t.vars[e]="+=0",Qt(t,s),Gt=0,o?R(e+" not eligible for reset"):1;d.push(u)}for(f=d.length;f--;)(u=(h=d[f])._pt||h).s=!i&&0!==i||n?u.s+(i||0)+a*u.c:i,u.c=r-u.s,h.e&&(h.e=ia(r)+Ya(h.e)),h.b&&(h.b=u.s+Ya(h.b))}(this,t,e,r,i,a,s,n)?this.resetTo(t,e,r,i,1):(Ia(this,0),this.parent||xa(this._dp,this,"_first","_last",this._dp._sort?"_start":0),this.render(0))},e.kill=function kill(t,e){if(void 0===e&&(e="all"),!(t||e&&"all"!==e))return this._lazy=this._pt=0,this.parent?tb(this):this.scrollTrigger&&this.scrollTrigger.kill(!!L),this;if(this.timeline){var i=this.timeline.totalDuration();return this.timeline.killTweensOf(t,e,Nt&&!0!==Nt.vars.overwrite)._first||tb(this),this.parent&&i!==this.timeline.totalDuration()&&Ra(this,this._dur*this.timeline._tDur/i,0,1),this}var n,a,s,o,u,h,l,f=this._targets,d=t?Mt(t):f,c=this._ptLookup,p=this._pt;if((!e||"all"===e)&&function _arraysMatch(t,e){for(var r=t.length,i=r===e.length;i&&r--&&t[r]===e[r];);return r<0}(f,d))return"all"===e&&(this._pt=0),tb(this);for(n=this._op=this._op||[],"all"!==e&&(r(e)&&(u={},ha(e,function(t){return u[t]=1}),e=u),e=function _addAliasesToVars(t,e){var r,i,n,a,s=t[0]?fa(t[0]).harness:0,o=s&&s.aliases;if(!o)return e;for(i in r=yt({},e),o)if(i in r)for(n=(a=o[i].split(",")).length;n--;)r[a[n]]=r[i];return r}(f,e)),l=f.length;l--;)if(~d.indexOf(f[l]))for(u in a=c[l],"all"===e?(n[l]=e,o=a,s={}):(s=n[l]=n[l]||{},o=e),o)(h=a&&a[u])&&("kill"in h.d&&!0!==h.d.kill(u)||ya(this,h,"_pt"),delete a[u]),"all"!==s&&(s[u]=1);return this._initted&&!this._pt&&p&&tb(this),this},Tween.to=function to(t,e,r){return new Tween(t,e,r)},Tween.from=function from(t,e){return Va(1,arguments)},Tween.delayedCall=function delayedCall(t,e,r,i){return new Tween(e,0,{immediateRender:!1,lazy:!1,overwrite:!1,delay:t,onComplete:e,onReverseComplete:e,onCompleteParams:r,onReverseCompleteParams:r,callbackScope:i})},Tween.fromTo=function fromTo(t,e,r){return Va(2,arguments)},Tween.set=function set(t,e){return e.duration=0,e.repeatDelay||(e.repeat=0),new Tween(t,e)},Tween.killTweensOf=function killTweensOf(t,e,r){return I.killTweensOf(t,e,r)},Tween}(Ut);qa($t.prototype,{_targets:[],_lazy:0,_startAt:0,_op:0,_onInit:0}),ha("staggerTo,staggerFrom,staggerFromTo",function(r){$t[r]=function(){var t=new Xt,e=Ot.call(arguments,0);return e.splice("staggerFromTo"===r?5:4,0,0),t[r].apply(t,e)}});function oc(t,e,r){return t.setAttribute(e,r)}function wc(t,e,r,i){i.mSet(t,e,i.m.call(i.tween,r,i.mt),i)}var Zt=function _setterPlain(t,e,r){return t[e]=r},te=function _setterFunc(t,e,r){return t[e](r)},re=function _setterFuncWithParam(t,e,r,i){return t[e](i.fp,r)},ne=function _getSetter(t,e){return s(t[e])?te:u(t[e])&&t.setAttribute?oc:Zt},ae=function _renderPlain(t,e){return e.set(e.t,e.p,Math.round(1e6*(e.s+e.c*t))/1e6,e)},se=function _renderBoolean(t,e){return e.set(e.t,e.p,!!(e.s+e.c*t),e)},ue=function _renderComplexString(t,e){var r=e._pt,i="";if(!t&&e.b)i=e.b;else if(1===t&&e.e)i=e.e;else{for(;r;)i=r.p+(r.m?r.m(r.s+r.c*t):Math.round(1e4*(r.s+r.c*t))/1e4)+i,r=r._next;i+=e.c}e.set(e.t,e.p,i,e)},he=function _renderPropTweens(t,e){for(var r=e._pt;r;)r.r(t,r.d),r=r._next},fe=function _addPluginModifier(t,e,r,i){for(var n,a=this._pt;a;)n=a._next,a.p===i&&a.modifier(t,e,r),a=n},ce=function _killPropTweensOf(t){for(var e,r,i=this._pt;i;)r=i._next,i.p===t&&!i.op||i.op===t?ya(this,i,"_pt"):i.dep||(e=1),i=r;return!e},pe=function _sortPropTweensByPriority(t){for(var e,r,i,n,a=t._pt;a;){for(e=a._next,r=i;r&&r.pr>a.pr;)r=r._next;(a._prev=r?r._prev:n)?a._prev._next=a:i=a,(a._next=r)?r._prev=a:n=a,a=e}t._pt=i},_e=(PropTween.prototype.modifier=function modifier(t,e,r){this.mSet=this.mSet||this.set,this.set=wc,this.m=t,this.mt=r,this.tween=e},PropTween);function PropTween(t,e,r,i,n,a,s,o,u){this.t=e,this.s=i,this.c=n,this.p=r,this.r=a||ae,this.d=s||this,this.set=o||Zt,this.pr=u||0,(this._next=t)&&(t._prev=this)}ha(vt+"parent,duration,ease,delay,overwrite,runBackwards,startAt,yoyo,immediateRender,repeat,repeatDelay,data,paused,reversed,lazy,callbackScope,stringFilter,id,yoyoEase,stagger,inherit,repeatRefresh,keyframes,autoRevert,scrollTrigger",function(t){return ft[t]=1}),ot.TweenMax=ot.TweenLite=$t,ot.TimelineLite=ot.TimelineMax=Xt,I=new Xt({sortChildren:!1,defaults:V,autoRemoveChildren:!0,id:"root",smoothChildTiming:!0}),q.stringFilter=Fb;function Ec(t){return(ye[t]||Te).map(function(t){return t()})}function Fc(){var t=Date.now(),o=[];2 typeof(value) === \"string\",\n\t_isFunction = value => typeof(value) === \"function\",\n\t_isNumber = value => typeof(value) === \"number\",\n\t_isUndefined = value => typeof(value) === \"undefined\",\n\t_isObject = value => typeof(value) === \"object\",\n\t_isNotFalse = value => value !== false,\n\t_windowExists = () => typeof(window) !== \"undefined\",\n\t_isFuncOrString = value => _isFunction(value) || _isString(value),\n\t_isTypedArray = (typeof ArrayBuffer === \"function\" && ArrayBuffer.isView) || function() {}, // note: IE10 has ArrayBuffer, but NOT ArrayBuffer.isView().\n\t_isArray = Array.isArray,\n\t_strictNumExp = /(?:-?\\.?\\d|\\.)+/gi, //only numbers (including negatives and decimals) but NOT relative values.\n\t_numExp = /[-+=.]*\\d+[.e\\-+]*\\d*[e\\-+]*\\d*/g, //finds any numbers, including ones that start with += or -=, negative numbers, and ones in scientific notation like 1e-8.\n\t_numWithUnitExp = /[-+=.]*\\d+[.e-]*\\d*[a-z%]*/g,\n\t_complexStringNumExp = /[-+=.]*\\d+\\.?\\d*(?:e-|e\\+)?\\d*/gi, //duplicate so that while we're looping through matches from exec(), it doesn't contaminate the lastIndex of _numExp which we use to search for colors too.\n\t_relExp = /[+-]=-?[.\\d]+/,\n\t_delimitedValueExp = /[^,'\"\\[\\]\\s]+/gi, // previously /[#\\-+.]*\\b[a-z\\d\\-=+%.]+/gi but didn't catch special characters.\n\t_unitExp = /^[+\\-=e\\s\\d]*\\d+[.\\d]*([a-z]*|%)\\s*$/i,\n\t_globalTimeline, _win, _coreInitted, _doc,\n\t_globals = {},\n\t_installScope = {},\n\t_coreReady,\n\t_install = scope => (_installScope = _merge(scope, _globals)) && gsap,\n\t_missingPlugin = (property, value) => console.warn(\"Invalid property\", property, \"set to\", value, \"Missing plugin? gsap.registerPlugin()\"),\n\t_warn = (message, suppress) => !suppress && console.warn(message),\n\t_addGlobal = (name, obj) => (name && (_globals[name] = obj) && (_installScope && (_installScope[name] = obj))) || _globals,\n\t_emptyFunc = () => 0,\n\t_startAtRevertConfig = {suppressEvents: true, isStart: true, kill: false},\n\t_revertConfigNoKill = {suppressEvents: true, kill: false},\n\t_revertConfig = {suppressEvents: true},\n\t_reservedProps = {},\n\t_lazyTweens = [],\n\t_lazyLookup = {},\n\t_lastRenderedFrame,\n\t_plugins = {},\n\t_effects = {},\n\t_nextGCFrame = 30,\n\t_harnessPlugins = [],\n\t_callbackNames = \"\",\n\t_harness = targets => {\n\t\tlet target = targets[0],\n\t\t\tharnessPlugin, i;\n\t\t_isObject(target) || _isFunction(target) || (targets = [targets]);\n\t\tif (!(harnessPlugin = (target._gsap || {}).harness)) { // find the first target with a harness. We assume targets passed into an animation will be of similar type, meaning the same kind of harness can be used for them all (performance optimization)\n\t\t\ti = _harnessPlugins.length;\n\t\t\twhile (i-- && !_harnessPlugins[i].targetTest(target)) {\t}\n\t\t\tharnessPlugin = _harnessPlugins[i];\n\t\t}\n\t\ti = targets.length;\n\t\twhile (i--) {\n\t\t\t(targets[i] && (targets[i]._gsap || (targets[i]._gsap = new GSCache(targets[i], harnessPlugin)))) || targets.splice(i, 1);\n\t\t}\n\t\treturn targets;\n\t},\n\t_getCache = target => target._gsap || _harness(toArray(target))[0]._gsap,\n\t_getProperty = (target, property, v) => (v = target[property]) && _isFunction(v) ? target[property]() : (_isUndefined(v) && target.getAttribute && target.getAttribute(property)) || v,\n\t_forEachName = (names, func) => ((names = names.split(\",\")).forEach(func)) || names, //split a comma-delimited list of names into an array, then run a forEach() function and return the split array (this is just a way to consolidate/shorten some code).\n\t_round = value => Math.round(value * 100000) / 100000 || 0,\n\t_roundPrecise = value => Math.round(value * 10000000) / 10000000 || 0, // increased precision mostly for timing values.\n\t_parseRelative = (start, value) => {\n\t\tlet operator = value.charAt(0),\n\t\t\tend = parseFloat(value.substr(2));\n\t\tstart = parseFloat(start);\n\t\treturn operator === \"+\" ? start + end : operator === \"-\" ? start - end : operator === \"*\" ? start * end : start / end;\n\t},\n\t_arrayContainsAny = (toSearch, toFind) => { //searches one array to find matches for any of the items in the toFind array. As soon as one is found, it returns true. It does NOT return all the matches; it's simply a boolean search.\n\t\tlet l = toFind.length,\n\t\t\ti = 0;\n\t\tfor (; toSearch.indexOf(toFind[i]) < 0 && ++i < l;) { }\n\t\treturn (i < l);\n\t},\n\t_lazyRender = () => {\n\t\tlet l = _lazyTweens.length,\n\t\t\ta = _lazyTweens.slice(0),\n\t\t\ti, tween;\n\t\t_lazyLookup = {};\n\t\t_lazyTweens.length = 0;\n\t\tfor (i = 0; i < l; i++) {\n\t\t\ttween = a[i];\n\t\t\ttween && tween._lazy && (tween.render(tween._lazy[0], tween._lazy[1], true)._lazy = 0);\n\t\t}\n\t},\n\t_lazySafeRender = (animation, time, suppressEvents, force) => {\n\t\t_lazyTweens.length && !_reverting && _lazyRender();\n\t\tanimation.render(time, suppressEvents, force || (_reverting && time < 0 && (animation._initted || animation._startAt)));\n\t\t_lazyTweens.length && !_reverting && _lazyRender(); //in case rendering caused any tweens to lazy-init, we should render them because typically when someone calls seek() or time() or progress(), they expect an immediate render.\n\t},\n\t_numericIfPossible = value => {\n\t\tlet n = parseFloat(value);\n\t\treturn (n || n === 0) && (value + \"\").match(_delimitedValueExp).length < 2 ? n : _isString(value) ? value.trim() : value;\n\t},\n\t_passThrough = p => p,\n\t_setDefaults = (obj, defaults) => {\n\t\tfor (let p in defaults) {\n\t\t\t(p in obj) || (obj[p] = defaults[p]);\n\t\t}\n\t\treturn obj;\n\t},\n\t_setKeyframeDefaults = excludeDuration => (obj, defaults) => {\n\t\tfor (let p in defaults) {\n\t\t\t(p in obj) || (p === \"duration\" && excludeDuration) || p === \"ease\" || (obj[p] = defaults[p]);\n\t\t}\n\t},\n\t_merge = (base, toMerge) => {\n\t\tfor (let p in toMerge) {\n\t\t\tbase[p] = toMerge[p];\n\t\t}\n\t\treturn base;\n\t},\n\t_mergeDeep = (base, toMerge) => {\n\t\tfor (let p in toMerge) {\n\t\t\tp !== \"__proto__\" && p !== \"constructor\" && p !== \"prototype\" && (base[p] = _isObject(toMerge[p]) ? _mergeDeep(base[p] || (base[p] = {}), toMerge[p]) : toMerge[p]);\n\t\t}\n\t\treturn base;\n\t},\n\t_copyExcluding = (obj, excluding) => {\n\t\tlet copy = {},\n\t\t\tp;\n\t\tfor (p in obj) {\n\t\t\t(p in excluding) || (copy[p] = obj[p]);\n\t\t}\n\t\treturn copy;\n\t},\n\t_inheritDefaults = vars => {\n\t\tlet parent = vars.parent || _globalTimeline,\n\t\t\tfunc = vars.keyframes ? _setKeyframeDefaults(_isArray(vars.keyframes)) : _setDefaults;\n\t\tif (_isNotFalse(vars.inherit)) {\n\t\t\twhile (parent) {\n\t\t\t\tfunc(vars, parent.vars.defaults);\n\t\t\t\tparent = parent.parent || parent._dp;\n\t\t\t}\n\t\t}\n\t\treturn vars;\n\t},\n\t_arraysMatch = (a1, a2) => {\n\t\tlet i = a1.length,\n\t\t\tmatch = i === a2.length;\n\t\twhile (match && i-- && a1[i] === a2[i]) { }\n\t\treturn i < 0;\n\t},\n\t_addLinkedListItem = (parent, child, firstProp = \"_first\", lastProp = \"_last\", sortBy) => {\n\t\tlet prev = parent[lastProp],\n\t\t\tt;\n\t\tif (sortBy) {\n\t\t\tt = child[sortBy];\n\t\t\twhile (prev && prev[sortBy] > t) {\n\t\t\t\tprev = prev._prev;\n\t\t\t}\n\t\t}\n\t\tif (prev) {\n\t\t\tchild._next = prev._next;\n\t\t\tprev._next = child;\n\t\t} else {\n\t\t\tchild._next = parent[firstProp];\n\t\t\tparent[firstProp] = child;\n\t\t}\n\t\tif (child._next) {\n\t\t\tchild._next._prev = child;\n\t\t} else {\n\t\t\tparent[lastProp] = child;\n\t\t}\n\t\tchild._prev = prev;\n\t\tchild.parent = child._dp = parent;\n\t\treturn child;\n\t},\n\t_removeLinkedListItem = (parent, child, firstProp = \"_first\", lastProp = \"_last\") => {\n\t\tlet prev = child._prev,\n\t\t\tnext = child._next;\n\t\tif (prev) {\n\t\t\tprev._next = next;\n\t\t} else if (parent[firstProp] === child) {\n\t\t\tparent[firstProp] = next;\n\t\t}\n\t\tif (next) {\n\t\t\tnext._prev = prev;\n\t\t} else if (parent[lastProp] === child) {\n\t\t\tparent[lastProp] = prev;\n\t\t}\n\t\tchild._next = child._prev = child.parent = null; // don't delete the _dp just so we can revert if necessary. But parent should be null to indicate the item isn't in a linked list.\n\t},\n\t_removeFromParent = (child, onlyIfParentHasAutoRemove) => {\n\t\tchild.parent && (!onlyIfParentHasAutoRemove || child.parent.autoRemoveChildren) && child.parent.remove && child.parent.remove(child);\n\t\tchild._act = 0;\n\t},\n\t_uncache = (animation, child) => {\n\t\tif (animation && (!child || child._end > animation._dur || child._start < 0)) { // performance optimization: if a child animation is passed in we should only uncache if that child EXTENDS the animation (its end time is beyond the end)\n\t\t\tlet a = animation;\n\t\t\twhile (a) {\n\t\t\t\ta._dirty = 1;\n\t\t\t\ta = a.parent;\n\t\t\t}\n\t\t}\n\t\treturn animation;\n\t},\n\t_recacheAncestors = animation => {\n\t\tlet parent = animation.parent;\n\t\twhile (parent && parent.parent) { //sometimes we must force a re-sort of all children and update the duration/totalDuration of all ancestor timelines immediately in case, for example, in the middle of a render loop, one tween alters another tween's timeScale which shoves its startTime before 0, forcing the parent timeline to shift around and shiftChildren() which could affect that next tween's render (startTime). Doesn't matter for the root timeline though.\n\t\t\tparent._dirty = 1;\n\t\t\tparent.totalDuration();\n\t\t\tparent = parent.parent;\n\t\t}\n\t\treturn animation;\n\t},\n\t_rewindStartAt = (tween, totalTime, suppressEvents, force) => tween._startAt && (_reverting ? tween._startAt.revert(_revertConfigNoKill) : (tween.vars.immediateRender && !tween.vars.autoRevert) || tween._startAt.render(totalTime, true, force)),\n\t_hasNoPausedAncestors = animation => !animation || (animation._ts && _hasNoPausedAncestors(animation.parent)),\n\t_elapsedCycleDuration = animation => animation._repeat ? _animationCycle(animation._tTime, (animation = animation.duration() + animation._rDelay)) * animation : 0,\n\t// feed in the totalTime and cycleDuration and it'll return the cycle (iteration minus 1) and if the playhead is exactly at the very END, it will NOT bump up to the next cycle.\n\t_animationCycle = (tTime, cycleDuration) => {\n\t\tlet whole = Math.floor(tTime = _roundPrecise(tTime / cycleDuration));\n\t\treturn tTime && (whole === tTime) ? whole - 1 : whole;\n\t},\n\t_parentToChildTotalTime = (parentTime, child) => (parentTime - child._start) * child._ts + (child._ts >= 0 ? 0 : (child._dirty ? child.totalDuration() : child._tDur)),\n\t_setEnd = animation => (animation._end = _roundPrecise(animation._start + ((animation._tDur / Math.abs(animation._ts || animation._rts || _tinyNum)) || 0))),\n\t_alignPlayhead = (animation, totalTime) => { // adjusts the animation's _start and _end according to the provided totalTime (only if the parent's smoothChildTiming is true and the animation isn't paused). It doesn't do any rendering or forcing things back into parent timelines, etc. - that's what totalTime() is for.\n\t\tlet parent = animation._dp;\n\t\tif (parent && parent.smoothChildTiming && animation._ts) {\n\t\t\tanimation._start = _roundPrecise(parent._time - (animation._ts > 0 ? totalTime / animation._ts : ((animation._dirty ? animation.totalDuration() : animation._tDur) - totalTime) / -animation._ts));\n\t\t\t_setEnd(animation);\n\t\t\tparent._dirty || _uncache(parent, animation); //for performance improvement. If the parent's cache is already dirty, it already took care of marking the ancestors as dirty too, so skip the function call here.\n\t\t}\n\t\treturn animation;\n\t},\n\t/*\n\t_totalTimeToTime = (clampedTotalTime, duration, repeat, repeatDelay, yoyo) => {\n\t\tlet cycleDuration = duration + repeatDelay,\n\t\t\ttime = _round(clampedTotalTime % cycleDuration);\n\t\tif (time > duration) {\n\t\t\ttime = duration;\n\t\t}\n\t\treturn (yoyo && (~~(clampedTotalTime / cycleDuration) & 1)) ? duration - time : time;\n\t},\n\t*/\n\t_postAddChecks = (timeline, child) => {\n\t\tlet t;\n\t\tif (child._time || (!child._dur && child._initted) || (child._start < timeline._time && (child._dur || !child.add))) { // in case, for example, the _start is moved on a tween that has already rendered, or if it's being inserted into a timeline BEFORE where the playhead is currently. Imagine it's at its end state, then the startTime is moved WAY later (after the end of this timeline), it should render at its beginning. Special case: if it's a timeline (has .add() method) and no duration, we can skip rendering because the user may be populating it AFTER adding it to a parent timeline (unconventional, but possible, and we wouldn't want it to get removed if the parent's autoRemoveChildren is true).\n\t\t\tt = _parentToChildTotalTime(timeline.rawTime(), child);\n\t\t\tif (!child._dur || _clamp(0, child.totalDuration(), t) - child._tTime > _tinyNum) {\n\t\t\t\tchild.render(t, true);\n\t\t\t}\n\t\t}\n\t\t//if the timeline has already ended but the inserted tween/timeline extends the duration, we should enable this timeline again so that it renders properly. We should also align the playhead with the parent timeline's when appropriate.\n\t\tif (_uncache(timeline, child)._dp && timeline._initted && timeline._time >= timeline._dur && timeline._ts) {\n\t\t\t//in case any of the ancestors had completed but should now be enabled...\n\t\t\tif (timeline._dur < timeline.duration()) {\n\t\t\t\tt = timeline;\n\t\t\t\twhile (t._dp) {\n\t\t\t\t\t(t.rawTime() >= 0) && t.totalTime(t._tTime); //moves the timeline (shifts its startTime) if necessary, and also enables it. If it's currently zero, though, it may not be scheduled to render until later so there's no need to force it to align with the current playhead position. Only move to catch up with the playhead.\n\t\t\t\t\tt = t._dp;\n\t\t\t\t}\n\t\t\t}\n\t\t\ttimeline._zTime = -_tinyNum; // helps ensure that the next render() will be forced (crossingStart = true in render()), even if the duration hasn't changed (we're adding a child which would need to get rendered). Definitely an edge case. Note: we MUST do this AFTER the loop above where the totalTime() might trigger a render() because this _addToTimeline() method gets called from the Animation constructor, BEFORE tweens even record their targets, etc. so we wouldn't want things to get triggered in the wrong order.\n\t\t}\n\t},\n\t_addToTimeline = (timeline, child, position, skipChecks) => {\n\t\tchild.parent && _removeFromParent(child);\n\t\tchild._start = _roundPrecise((_isNumber(position) ? position : position || timeline !== _globalTimeline ? _parsePosition(timeline, position, child) : timeline._time) + child._delay);\n\t\tchild._end = _roundPrecise(child._start + ((child.totalDuration() / Math.abs(child.timeScale())) || 0));\n\t\t_addLinkedListItem(timeline, child, \"_first\", \"_last\", timeline._sort ? \"_start\" : 0);\n\t\t_isFromOrFromStart(child) || (timeline._recent = child);\n\t\tskipChecks || _postAddChecks(timeline, child);\n\t\ttimeline._ts < 0 && _alignPlayhead(timeline, timeline._tTime); // if the timeline is reversed and the new child makes it longer, we may need to adjust the parent's _start (push it back)\n\t\treturn timeline;\n\t},\n\t_scrollTrigger = (animation, trigger) => (_globals.ScrollTrigger || _missingPlugin(\"scrollTrigger\", trigger)) && _globals.ScrollTrigger.create(trigger, animation),\n\t_attemptInitTween = (tween, time, force, suppressEvents, tTime) => {\n\t\t_initTween(tween, time, tTime);\n\t\tif (!tween._initted) {\n\t\t\treturn 1;\n\t\t}\n\t\tif (!force && tween._pt && !_reverting && ((tween._dur && tween.vars.lazy !== false) || (!tween._dur && tween.vars.lazy)) && _lastRenderedFrame !== _ticker.frame) {\n\t\t\t_lazyTweens.push(tween);\n\t\t\ttween._lazy = [tTime, suppressEvents];\n\t\t\treturn 1;\n\t\t}\n\t},\n\t_parentPlayheadIsBeforeStart = ({parent}) => parent && parent._ts && parent._initted && !parent._lock && (parent.rawTime() < 0 || _parentPlayheadIsBeforeStart(parent)), // check parent's _lock because when a timeline repeats/yoyos and does its artificial wrapping, we shouldn't force the ratio back to 0\n\t_isFromOrFromStart = ({data}) => data === \"isFromStart\" || data === \"isStart\",\n\t_renderZeroDurationTween = (tween, totalTime, suppressEvents, force) => {\n\t\tlet prevRatio = tween.ratio,\n\t\t\tratio = totalTime < 0 || (!totalTime && ((!tween._start && _parentPlayheadIsBeforeStart(tween) && !(!tween._initted && _isFromOrFromStart(tween))) || ((tween._ts < 0 || tween._dp._ts < 0) && !_isFromOrFromStart(tween)))) ? 0 : 1, // if the tween or its parent is reversed and the totalTime is 0, we should go to a ratio of 0. Edge case: if a from() or fromTo() stagger tween is placed later in a timeline, the \"startAt\" zero-duration tween could initially render at a time when the parent timeline's playhead is technically BEFORE where this tween is, so make sure that any \"from\" and \"fromTo\" startAt tweens are rendered the first time at a ratio of 1.\n\t\t\trepeatDelay = tween._rDelay,\n\t\t\ttTime = 0,\n\t\t\tpt, iteration, prevIteration;\n\t\tif (repeatDelay && tween._repeat) { // in case there's a zero-duration tween that has a repeat with a repeatDelay\n\t\t\ttTime = _clamp(0, tween._tDur, totalTime);\n\t\t\titeration = _animationCycle(tTime, repeatDelay);\n\t\t\ttween._yoyo && (iteration & 1) && (ratio = 1 - ratio);\n\t\t\tif (iteration !== _animationCycle(tween._tTime, repeatDelay)) { // if iteration changed\n\t\t\t\tprevRatio = 1 - ratio;\n\t\t\t\ttween.vars.repeatRefresh && tween._initted && tween.invalidate();\n\t\t\t}\n\t\t}\n\t\tif (ratio !== prevRatio || _reverting || force || tween._zTime === _tinyNum || (!totalTime && tween._zTime)) {\n\t\t\tif (!tween._initted && _attemptInitTween(tween, totalTime, force, suppressEvents, tTime)) { // if we render the very beginning (time == 0) of a fromTo(), we must force the render (normal tweens wouldn't need to render at a time of 0 when the prevTime was also 0). This is also mandatory to make sure overwriting kicks in immediately.\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tprevIteration = tween._zTime;\n\t\t\ttween._zTime = totalTime || (suppressEvents ? _tinyNum : 0); // when the playhead arrives at EXACTLY time 0 (right on top) of a zero-duration tween, we need to discern if events are suppressed so that when the playhead moves again (next time), it'll trigger the callback. If events are NOT suppressed, obviously the callback would be triggered in this render. Basically, the callback should fire either when the playhead ARRIVES or LEAVES this exact spot, not both. Imagine doing a timeline.seek(0) and there's a callback that sits at 0. Since events are suppressed on that seek() by default, nothing will fire, but when the playhead moves off of that position, the callback should fire. This behavior is what people intuitively expect.\n\t\t\tsuppressEvents || (suppressEvents = totalTime && !prevIteration); // if it was rendered previously at exactly 0 (_zTime) and now the playhead is moving away, DON'T fire callbacks otherwise they'll seem like duplicates.\n\t\t\ttween.ratio = ratio;\n\t\t\ttween._from && (ratio = 1 - ratio);\n\t\t\ttween._time = 0;\n\t\t\ttween._tTime = tTime;\n\t\t\tpt = tween._pt;\n\t\t\twhile (pt) {\n\t\t\t\tpt.r(ratio, pt.d);\n\t\t\t\tpt = pt._next;\n\t\t\t}\n\t\t\ttotalTime < 0 && _rewindStartAt(tween, totalTime, suppressEvents, true);\n\t\t\ttween._onUpdate && !suppressEvents && _callback(tween, \"onUpdate\");\n\t\t\ttTime && tween._repeat && !suppressEvents && tween.parent && _callback(tween, \"onRepeat\");\n\t\t\tif ((totalTime >= tween._tDur || totalTime < 0) && tween.ratio === ratio) {\n\t\t\t\tratio && _removeFromParent(tween, 1);\n\t\t\t\tif (!suppressEvents && !_reverting) {\n\t\t\t\t\t_callback(tween, (ratio ? \"onComplete\" : \"onReverseComplete\"), true);\n\t\t\t\t\ttween._prom && tween._prom();\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (!tween._zTime) {\n\t\t\ttween._zTime = totalTime;\n\t\t}\n\t},\n\t_findNextPauseTween = (animation, prevTime, time) => {\n\t\tlet child;\n\t\tif (time > prevTime) {\n\t\t\tchild = animation._first;\n\t\t\twhile (child && child._start <= time) {\n\t\t\t\tif (child.data === \"isPause\" && child._start > prevTime) {\n\t\t\t\t\treturn child;\n\t\t\t\t}\n\t\t\t\tchild = child._next;\n\t\t\t}\n\t\t} else {\n\t\t\tchild = animation._last;\n\t\t\twhile (child && child._start >= time) {\n\t\t\t\tif (child.data === \"isPause\" && child._start < prevTime) {\n\t\t\t\t\treturn child;\n\t\t\t\t}\n\t\t\t\tchild = child._prev;\n\t\t\t}\n\t\t}\n\t},\n\t_setDuration = (animation, duration, skipUncache, leavePlayhead) => {\n\t\tlet repeat = animation._repeat,\n\t\t\tdur = _roundPrecise(duration) || 0,\n\t\t\ttotalProgress = animation._tTime / animation._tDur;\n\t\ttotalProgress && !leavePlayhead && (animation._time *= dur / animation._dur);\n\t\tanimation._dur = dur;\n\t\tanimation._tDur = !repeat ? dur : repeat < 0 ? 1e10 : _roundPrecise(dur * (repeat + 1) + (animation._rDelay * repeat));\n\t\ttotalProgress > 0 && !leavePlayhead && _alignPlayhead(animation, (animation._tTime = animation._tDur * totalProgress));\n\t\tanimation.parent && _setEnd(animation);\n\t\tskipUncache || _uncache(animation.parent, animation);\n\t\treturn animation;\n\t},\n\t_onUpdateTotalDuration = animation => (animation instanceof Timeline) ? _uncache(animation) : _setDuration(animation, animation._dur),\n\t_zeroPosition = {_start:0, endTime:_emptyFunc, totalDuration:_emptyFunc},\n\t_parsePosition = (animation, position, percentAnimation) => {\n\t\tlet labels = animation.labels,\n\t\t\trecent = animation._recent || _zeroPosition,\n\t\t\tclippedDuration = animation.duration() >= _bigNum ? recent.endTime(false) : animation._dur, //in case there's a child that infinitely repeats, users almost never intend for the insertion point of a new child to be based on a SUPER long value like that so we clip it and assume the most recently-added child's endTime should be used instead.\n\t\t\ti, offset, isPercent;\n\t\tif (_isString(position) && (isNaN(position) || (position in labels))) { //if the string is a number like \"1\", check to see if there's a label with that name, otherwise interpret it as a number (absolute value).\n\t\t\toffset = position.charAt(0);\n\t\t\tisPercent = position.substr(-1) === \"%\";\n\t\t\ti = position.indexOf(\"=\");\n\t\t\tif (offset === \"<\" || offset === \">\") {\n\t\t\t\ti >= 0 && (position = position.replace(/=/, \"\"));\n\t\t\t\treturn (offset === \"<\" ? recent._start : recent.endTime(recent._repeat >= 0)) + (parseFloat(position.substr(1)) || 0) * (isPercent ? (i < 0 ? recent : percentAnimation).totalDuration() / 100 : 1);\n\t\t\t}\n\t\t\tif (i < 0) {\n\t\t\t\t(position in labels) || (labels[position] = clippedDuration);\n\t\t\t\treturn labels[position];\n\t\t\t}\n\t\t\toffset = parseFloat(position.charAt(i-1) + position.substr(i+1));\n\t\t\tif (isPercent && percentAnimation) {\n\t\t\t\toffset = offset / 100 * (_isArray(percentAnimation) ? percentAnimation[0] : percentAnimation).totalDuration();\n\t\t\t}\n\t\t\treturn (i > 1) ? _parsePosition(animation, position.substr(0, i-1), percentAnimation) + offset : clippedDuration + offset;\n\t\t}\n\t\treturn (position == null) ? clippedDuration : +position;\n\t},\n\t_createTweenType = (type, params, timeline) => {\n\t\tlet isLegacy = _isNumber(params[1]),\n\t\t\tvarsIndex = (isLegacy ? 2 : 1) + (type < 2 ? 0 : 1),\n\t\t\tvars = params[varsIndex],\n\t\t\tirVars, parent;\n\t\tisLegacy && (vars.duration = params[1]);\n\t\tvars.parent = timeline;\n\t\tif (type) {\n\t\t\tirVars = vars;\n\t\t\tparent = timeline;\n\t\t\twhile (parent && !(\"immediateRender\" in irVars)) { // inheritance hasn't happened yet, but someone may have set a default in an ancestor timeline. We could do vars.immediateRender = _isNotFalse(_inheritDefaults(vars).immediateRender) but that'd exact a slight performance penalty because _inheritDefaults() also runs in the Tween constructor. We're paying a small kb price here to gain speed.\n\t\t\t\tirVars = parent.vars.defaults || {};\n\t\t\t\tparent = _isNotFalse(parent.vars.inherit) && parent.parent;\n\t\t\t}\n\t\t\tvars.immediateRender = _isNotFalse(irVars.immediateRender);\n\t\t\ttype < 2 ? (vars.runBackwards = 1) : (vars.startAt = params[varsIndex - 1]); // \"from\" vars\n\t\t}\n\t\treturn new Tween(params[0], vars, params[varsIndex + 1]);\n\t},\n\t_conditionalReturn = (value, func) => value || value === 0 ? func(value) : func,\n\t_clamp = (min, max, value) => value < min ? min : value > max ? max : value,\n\tgetUnit = (value, v) => !_isString(value) || !(v = _unitExp.exec(value)) ? \"\" : v[1], // note: protect against padded numbers as strings, like \"100.100\". That shouldn't return \"00\" as the unit. If it's numeric, return no unit.\n\tclamp = (min, max, value) => _conditionalReturn(value, v => _clamp(min, max, v)),\n\t_slice = [].slice,\n\t_isArrayLike = (value, nonEmpty) => value && (_isObject(value) && \"length\" in value && ((!nonEmpty && !value.length) || ((value.length - 1) in value && _isObject(value[0]))) && !value.nodeType && value !== _win),\n\t_flatten = (ar, leaveStrings, accumulator = []) => ar.forEach(value => (_isString(value) && !leaveStrings) || _isArrayLike(value, 1) ? accumulator.push(...toArray(value)) : accumulator.push(value)) || accumulator,\n\t//takes any value and returns an array. If it's a string (and leaveStrings isn't true), it'll use document.querySelectorAll() and convert that to an array. It'll also accept iterables like jQuery objects.\n\ttoArray = (value, scope, leaveStrings) => _context && !scope && _context.selector ? _context.selector(value) : _isString(value) && !leaveStrings && (_coreInitted || !_wake()) ? _slice.call((scope || _doc).querySelectorAll(value), 0) : _isArray(value) ? _flatten(value, leaveStrings) : _isArrayLike(value) ? _slice.call(value, 0) : value ? [value] : [],\n\tselector = value => {\n\t\tvalue = toArray(value)[0] || _warn(\"Invalid scope\") || {};\n\t\treturn v => {\n\t\t\tlet el = value.current || value.nativeElement || value;\n\t\t\treturn toArray(v, el.querySelectorAll ? el : el === value ? _warn(\"Invalid scope\") || _doc.createElement(\"div\") : value);\n\t\t};\n\t},\n\tshuffle = a => a.sort(() => .5 - Math.random()), // alternative that's a bit faster and more reliably diverse but bigger: for (let j, v, i = a.length; i; j = (Math.random() * i) | 0, v = a[--i], a[i] = a[j], a[j] = v); return a;\n\t//for distributing values across an array. Can accept a number, a function or (most commonly) a function which can contain the following properties: {base, amount, from, ease, grid, axis, length, each}. Returns a function that expects the following parameters: index, target, array. Recognizes the following\n\tdistribute = v => {\n\t\tif (_isFunction(v)) {\n\t\t\treturn v;\n\t\t}\n\t\tlet vars = _isObject(v) ? v : {each:v}, //n:1 is just to indicate v was a number; we leverage that later to set v according to the length we get. If a number is passed in, we treat it like the old stagger value where 0.1, for example, would mean that things would be distributed with 0.1 between each element in the array rather than a total \"amount\" that's chunked out among them all.\n\t\t\tease = _parseEase(vars.ease),\n\t\t\tfrom = vars.from || 0,\n\t\t\tbase = parseFloat(vars.base) || 0,\n\t\t\tcache = {},\n\t\t\tisDecimal = (from > 0 && from < 1),\n\t\t\tratios = isNaN(from) || isDecimal,\n\t\t\taxis = vars.axis,\n\t\t\tratioX = from,\n\t\t\tratioY = from;\n\t\tif (_isString(from)) {\n\t\t\tratioX = ratioY = {center:.5, edges:.5, end:1}[from] || 0;\n\t\t} else if (!isDecimal && ratios) {\n\t\t\tratioX = from[0];\n\t\t\tratioY = from[1];\n\t\t}\n\t\treturn (i, target, a) => {\n\t\t\tlet l = (a || vars).length,\n\t\t\t\tdistances = cache[l],\n\t\t\t\toriginX, originY, x, y, d, j, max, min, wrapAt;\n\t\t\tif (!distances) {\n\t\t\t\twrapAt = (vars.grid === \"auto\") ? 0 : (vars.grid || [1, _bigNum])[1];\n\t\t\t\tif (!wrapAt) {\n\t\t\t\t\tmax = -_bigNum;\n\t\t\t\t\twhile (max < (max = a[wrapAt++].getBoundingClientRect().left) && wrapAt < l) { }\n\t\t\t\t\twrapAt < l && wrapAt--;\n\t\t\t\t}\n\t\t\t\tdistances = cache[l] = [];\n\t\t\t\toriginX = ratios ? (Math.min(wrapAt, l) * ratioX) - .5 : from % wrapAt;\n\t\t\t\toriginY = wrapAt === _bigNum ? 0 : ratios ? l * ratioY / wrapAt - .5 : (from / wrapAt) | 0;\n\t\t\t\tmax = 0;\n\t\t\t\tmin = _bigNum;\n\t\t\t\tfor (j = 0; j < l; j++) {\n\t\t\t\t\tx = (j % wrapAt) - originX;\n\t\t\t\t\ty = originY - ((j / wrapAt) | 0);\n\t\t\t\t\tdistances[j] = d = !axis ? _sqrt(x * x + y * y) : Math.abs((axis === \"y\") ? y : x);\n\t\t\t\t\t(d > max) && (max = d);\n\t\t\t\t\t(d < min) && (min = d);\n\t\t\t\t}\n\t\t\t\t(from === \"random\") && shuffle(distances);\n\t\t\t\tdistances.max = max - min;\n\t\t\t\tdistances.min = min;\n\t\t\t\tdistances.v = l = (parseFloat(vars.amount) || (parseFloat(vars.each) * (wrapAt > l ? l - 1 : !axis ? Math.max(wrapAt, l / wrapAt) : axis === \"y\" ? l / wrapAt : wrapAt)) || 0) * (from === \"edges\" ? -1 : 1);\n\t\t\t\tdistances.b = (l < 0) ? base - l : base;\n\t\t\t\tdistances.u = getUnit(vars.amount || vars.each) || 0; //unit\n\t\t\t\tease = (ease && l < 0) ? _invertEase(ease) : ease;\n\t\t\t}\n\t\t\tl = ((distances[i] - distances.min) / distances.max) || 0;\n\t\t\treturn _roundPrecise(distances.b + (ease ? ease(l) : l) * distances.v) + distances.u; //round in order to work around floating point errors\n\t\t};\n\t},\n\t_roundModifier = v => { //pass in 0.1 get a function that'll round to the nearest tenth, or 5 to round to the closest 5, or 0.001 to the closest 1000th, etc.\n\t\tlet p = Math.pow(10, ((v + \"\").split(\".\")[1] || \"\").length); //to avoid floating point math errors (like 24 * 0.1 == 2.4000000000000004), we chop off at a specific number of decimal places (much faster than toFixed())\n\t\treturn raw => {\n\t\t\tlet n = _roundPrecise(Math.round(parseFloat(raw) / v) * v * p);\n\t\t\treturn (n - n % 1) / p + (_isNumber(raw) ? 0 : getUnit(raw)); // n - n % 1 replaces Math.floor() in order to handle negative values properly. For example, Math.floor(-150.00000000000003) is 151!\n\t\t};\n\t},\n\tsnap = (snapTo, value) => {\n\t\tlet isArray = _isArray(snapTo),\n\t\t\tradius, is2D;\n\t\tif (!isArray && _isObject(snapTo)) {\n\t\t\tradius = isArray = snapTo.radius || _bigNum;\n\t\t\tif (snapTo.values) {\n\t\t\t\tsnapTo = toArray(snapTo.values);\n\t\t\t\tif ((is2D = !_isNumber(snapTo[0]))) {\n\t\t\t\t\tradius *= radius; //performance optimization so we don't have to Math.sqrt() in the loop.\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsnapTo = _roundModifier(snapTo.increment);\n\t\t\t}\n\t\t}\n\t\treturn _conditionalReturn(value, !isArray ? _roundModifier(snapTo) : _isFunction(snapTo) ? raw => {is2D = snapTo(raw); return Math.abs(is2D - raw) <= radius ? is2D : raw; } : raw => {\n\t\t\tlet x = parseFloat(is2D ? raw.x : raw),\n\t\t\t\ty = parseFloat(is2D ? raw.y : 0),\n\t\t\t\tmin = _bigNum,\n\t\t\t\tclosest = 0,\n\t\t\t\ti = snapTo.length,\n\t\t\t\tdx, dy;\n\t\t\twhile (i--) {\n\t\t\t\tif (is2D) {\n\t\t\t\t\tdx = snapTo[i].x - x;\n\t\t\t\t\tdy = snapTo[i].y - y;\n\t\t\t\t\tdx = dx * dx + dy * dy;\n\t\t\t\t} else {\n\t\t\t\t\tdx = Math.abs(snapTo[i] - x);\n\t\t\t\t}\n\t\t\t\tif (dx < min) {\n\t\t\t\t\tmin = dx;\n\t\t\t\t\tclosest = i;\n\t\t\t\t}\n\t\t\t}\n\t\t\tclosest = (!radius || min <= radius) ? snapTo[closest] : raw;\n\t\t\treturn (is2D || closest === raw || _isNumber(raw)) ? closest : closest + getUnit(raw);\n\t\t});\n\t},\n\trandom = (min, max, roundingIncrement, returnFunction) => _conditionalReturn(_isArray(min) ? !max : roundingIncrement === true ? !!(roundingIncrement = 0) : !returnFunction, () => _isArray(min) ? min[~~(Math.random() * min.length)] : (roundingIncrement = roundingIncrement || 1e-5) && (returnFunction = roundingIncrement < 1 ? 10 ** ((roundingIncrement + \"\").length - 2) : 1) && (Math.floor(Math.round((min - roundingIncrement / 2 + Math.random() * (max - min + roundingIncrement * .99)) / roundingIncrement) * roundingIncrement * returnFunction) / returnFunction)),\n\tpipe = (...functions) => value => functions.reduce((v, f) => f(v), value),\n\tunitize = (func, unit) => value => func(parseFloat(value)) + (unit || getUnit(value)),\n\tnormalize = (min, max, value) => mapRange(min, max, 0, 1, value),\n\t_wrapArray = (a, wrapper, value) => _conditionalReturn(value, index => a[~~wrapper(index)]),\n\twrap = function(min, max, value) { // NOTE: wrap() CANNOT be an arrow function! A very odd compiling bug causes problems (unrelated to GSAP).\n\t\tlet range = max - min;\n\t\treturn _isArray(min) ? _wrapArray(min, wrap(0, min.length), max) : _conditionalReturn(value, value => ((range + (value - min) % range) % range) + min);\n\t},\n\twrapYoyo = (min, max, value) => {\n\t\tlet range = max - min,\n\t\t\ttotal = range * 2;\n\t\treturn _isArray(min) ? _wrapArray(min, wrapYoyo(0, min.length - 1), max) : _conditionalReturn(value, value => {\n\t\t\tvalue = (total + (value - min) % total) % total || 0;\n\t\t\treturn min + ((value > range) ? (total - value) : value);\n\t\t});\n\t},\n\t_replaceRandom = value => { //replaces all occurrences of random(...) in a string with the calculated random value. can be a range like random(-100, 100, 5) or an array like random([0, 100, 500])\n\t\tlet prev = 0,\n\t\t\ts = \"\",\n\t\t\ti, nums, end, isArray;\n\t\twhile (~(i = value.indexOf(\"random(\", prev))) {\n\t\t\tend = value.indexOf(\")\", i);\n\t\t\tisArray = value.charAt(i + 7) === \"[\";\n\t\t\tnums = value.substr(i + 7, end - i - 7).match(isArray ? _delimitedValueExp : _strictNumExp);\n\t\t\ts += value.substr(prev, i - prev) + random(isArray ? nums : +nums[0], isArray ? 0 : +nums[1], +nums[2] || 1e-5);\n\t\t\tprev = end + 1;\n\t\t}\n\t\treturn s + value.substr(prev, value.length - prev);\n\t},\n\tmapRange = (inMin, inMax, outMin, outMax, value) => {\n\t\tlet inRange = inMax - inMin,\n\t\t\toutRange = outMax - outMin;\n\t\treturn _conditionalReturn(value, value => outMin + ((((value - inMin) / inRange) * outRange) || 0));\n\t},\n\tinterpolate = (start, end, progress, mutate) => {\n\t\tlet func = isNaN(start + end) ? 0 : p => (1 - p) * start + p * end;\n\t\tif (!func) {\n\t\t\tlet isString = _isString(start),\n\t\t\t\tmaster = {},\n\t\t\t\tp, i, interpolators, l, il;\n\t\t\tprogress === true && (mutate = 1) && (progress = null);\n\t\t\tif (isString) {\n\t\t\t\tstart = {p: start};\n\t\t\t\tend = {p: end};\n\n\t\t\t} else if (_isArray(start) && !_isArray(end)) {\n\t\t\t\tinterpolators = [];\n\t\t\t\tl = start.length;\n\t\t\t\til = l - 2;\n\t\t\t\tfor (i = 1; i < l; i++) {\n\t\t\t\t\tinterpolators.push(interpolate(start[i-1], start[i])); //build the interpolators up front as a performance optimization so that when the function is called many times, it can just reuse them.\n\t\t\t\t}\n\t\t\t\tl--;\n\t\t\t\tfunc = p => {\n\t\t\t\t\tp *= l;\n\t\t\t\t\tlet i = Math.min(il, ~~p);\n\t\t\t\t\treturn interpolators[i](p - i);\n\t\t\t\t};\n\t\t\t\tprogress = end;\n\t\t\t} else if (!mutate) {\n\t\t\t\tstart = _merge(_isArray(start) ? [] : {}, start);\n\t\t\t}\n\t\t\tif (!interpolators) {\n\t\t\t\tfor (p in end) {\n\t\t\t\t\t_addPropTween.call(master, start, p, \"get\", end[p]);\n\t\t\t\t}\n\t\t\t\tfunc = p => _renderPropTweens(p, master) || (isString ? start.p : start);\n\t\t\t}\n\t\t}\n\t\treturn _conditionalReturn(progress, func);\n\t},\n\t_getLabelInDirection = (timeline, fromTime, backward) => { //used for nextLabel() and previousLabel()\n\t\tlet labels = timeline.labels,\n\t\t\tmin = _bigNum,\n\t\t\tp, distance, label;\n\t\tfor (p in labels) {\n\t\t\tdistance = labels[p] - fromTime;\n\t\t\tif ((distance < 0) === !!backward && distance && min > (distance = Math.abs(distance))) {\n\t\t\t\tlabel = p;\n\t\t\t\tmin = distance;\n\t\t\t}\n\t\t}\n\t\treturn label;\n\t},\n\t_callback = (animation, type, executeLazyFirst) => {\n\t\tlet v = animation.vars,\n\t\t\tcallback = v[type],\n\t\t\tprevContext = _context,\n\t\t\tcontext = animation._ctx,\n\t\t\tparams, scope, result;\n\t\tif (!callback) {\n\t\t\treturn;\n\t\t}\n\t\tparams = v[type + \"Params\"];\n\t\tscope = v.callbackScope || animation;\n\t\texecuteLazyFirst && _lazyTweens.length && _lazyRender(); //in case rendering caused any tweens to lazy-init, we should render them because typically when a timeline finishes, users expect things to have rendered fully. Imagine an onUpdate on a timeline that reports/checks tweened values.\n\t\tcontext && (_context = context);\n\t\tresult = params ? callback.apply(scope, params) : callback.call(scope);\n\t\t_context = prevContext;\n\t\treturn result;\n\t},\n\t_interrupt = animation => {\n\t\t_removeFromParent(animation);\n\t\tanimation.scrollTrigger && animation.scrollTrigger.kill(!!_reverting);\n\t\tanimation.progress() < 1 && _callback(animation, \"onInterrupt\");\n\t\treturn animation;\n\t},\n\t_quickTween,\n\t_registerPluginQueue = [],\n\t_createPlugin = config => {\n\t\tif (!config) return;\n\t\tconfig = (!config.name && config.default) || config; // UMD packaging wraps things oddly, so for example MotionPathHelper becomes {MotionPathHelper:MotionPathHelper, default:MotionPathHelper}.\n\t\tif (_windowExists() || config.headless) { // edge case: some build tools may pass in a null/undefined value\n\t\t\tlet name = config.name,\n\t\t\t\tisFunc = _isFunction(config),\n\t\t\t\tPlugin = (name && !isFunc && config.init) ? function () {\n\t\t\t\t\tthis._props = [];\n\t\t\t\t} : config, //in case someone passes in an object that's not a plugin, like CustomEase\n\t\t\t\tinstanceDefaults = {init: _emptyFunc, render: _renderPropTweens, add: _addPropTween, kill: _killPropTweensOf, modifier: _addPluginModifier, rawVars: 0},\n\t\t\t\tstatics = {targetTest: 0, get: 0, getSetter: _getSetter, aliases: {}, register: 0};\n\t\t\t_wake();\n\t\t\tif (config !== Plugin) {\n\t\t\t\tif (_plugins[name]) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t_setDefaults(Plugin, _setDefaults(_copyExcluding(config, instanceDefaults), statics)); //static methods\n\t\t\t\t_merge(Plugin.prototype, _merge(instanceDefaults, _copyExcluding(config, statics))); //instance methods\n\t\t\t\t_plugins[(Plugin.prop = name)] = Plugin;\n\t\t\t\tif (config.targetTest) {\n\t\t\t\t\t_harnessPlugins.push(Plugin);\n\t\t\t\t\t_reservedProps[name] = 1;\n\t\t\t\t}\n\t\t\t\tname = (name === \"css\" ? \"CSS\" : name.charAt(0).toUpperCase() + name.substr(1)) + \"Plugin\"; //for the global name. \"motionPath\" should become MotionPathPlugin\n\t\t\t}\n\t\t\t_addGlobal(name, Plugin);\n\t\t\tconfig.register && config.register(gsap, Plugin, PropTween);\n\t\t} else {\n\t\t\t_registerPluginQueue.push(config);\n\t\t}\n\t},\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n/*\n * --------------------------------------------------------------------------------------\n * COLORS\n * --------------------------------------------------------------------------------------\n */\n\n\t_255 = 255,\n\t_colorLookup = {\n\t\taqua:[0,_255,_255],\n\t\tlime:[0,_255,0],\n\t\tsilver:[192,192,192],\n\t\tblack:[0,0,0],\n\t\tmaroon:[128,0,0],\n\t\tteal:[0,128,128],\n\t\tblue:[0,0,_255],\n\t\tnavy:[0,0,128],\n\t\twhite:[_255,_255,_255],\n\t\tolive:[128,128,0],\n\t\tyellow:[_255,_255,0],\n\t\torange:[_255,165,0],\n\t\tgray:[128,128,128],\n\t\tpurple:[128,0,128],\n\t\tgreen:[0,128,0],\n\t\tred:[_255,0,0],\n\t\tpink:[_255,192,203],\n\t\tcyan:[0,_255,_255],\n\t\ttransparent:[_255,_255,_255,0]\n\t},\n\t// possible future idea to replace the hard-coded color name values - put this in the ticker.wake() where we set the _doc:\n\t// let ctx = _doc.createElement(\"canvas\").getContext(\"2d\");\n\t// _forEachName(\"aqua,lime,silver,black,maroon,teal,blue,navy,white,olive,yellow,orange,gray,purple,green,red,pink,cyan\", color => {ctx.fillStyle = color; _colorLookup[color] = splitColor(ctx.fillStyle)});\n\t_hue = (h, m1, m2) => {\n\t\th += h < 0 ? 1 : h > 1 ? -1 : 0;\n\t\treturn ((((h * 6 < 1) ? m1 + (m2 - m1) * h * 6 : h < .5 ? m2 : (h * 3 < 2) ? m1 + (m2 - m1) * (2 / 3 - h) * 6 : m1) * _255) + .5) | 0;\n\t},\n\tsplitColor = (v, toHSL, forceAlpha) => {\n\t\tlet a = !v ? _colorLookup.black : _isNumber(v) ? [v >> 16, (v >> 8) & _255, v & _255] : 0,\n\t\t\tr, g, b, h, s, l, max, min, d, wasHSL;\n\t\tif (!a) {\n\t\t\tif (v.substr(-1) === \",\") { //sometimes a trailing comma is included and we should chop it off (typically from a comma-delimited list of values like a textShadow:\"2px 2px 2px blue, 5px 5px 5px rgb(255,0,0)\" - in this example \"blue,\" has a trailing comma. We could strip it out inside parseComplex() but we'd need to do it to the beginning and ending values plus it wouldn't provide protection from other potential scenarios like if the user passes in a similar value.\n\t\t\t\tv = v.substr(0, v.length - 1);\n\t\t\t}\n\t\t\tif (_colorLookup[v]) {\n\t\t\t\ta = _colorLookup[v];\n\t\t\t} else if (v.charAt(0) === \"#\") {\n\t\t\t\tif (v.length < 6) { //for shorthand like #9F0 or #9F0F (could have alpha)\n\t\t\t\t\tr = v.charAt(1);\n\t\t\t\t\tg = v.charAt(2);\n\t\t\t\t\tb = v.charAt(3);\n\t\t\t\t\tv = \"#\" + r + r + g + g + b + b + (v.length === 5 ? v.charAt(4) + v.charAt(4) : \"\");\n\t\t\t\t}\n\t\t\t\tif (v.length === 9) { // hex with alpha, like #fd5e53ff\n\t\t\t\t\ta = parseInt(v.substr(1, 6), 16);\n\t\t\t\t\treturn [a >> 16, (a >> 8) & _255, a & _255, parseInt(v.substr(7), 16) / 255];\n\t\t\t\t}\n\t\t\t\tv = parseInt(v.substr(1), 16);\n\t\t\t\ta = [v >> 16, (v >> 8) & _255, v & _255];\n\t\t\t} else if (v.substr(0, 3) === \"hsl\") {\n\t\t\t\ta = wasHSL = v.match(_strictNumExp);\n\t\t\t\tif (!toHSL) {\n\t\t\t\t\th = (+a[0] % 360) / 360;\n\t\t\t\t\ts = +a[1] / 100;\n\t\t\t\t\tl = +a[2] / 100;\n\t\t\t\t\tg = (l <= .5) ? l * (s + 1) : l + s - l * s;\n\t\t\t\t\tr = l * 2 - g;\n\t\t\t\t\ta.length > 3 && (a[3] *= 1); //cast as number\n\t\t\t\t\ta[0] = _hue(h + 1 / 3, r, g);\n\t\t\t\t\ta[1] = _hue(h, r, g);\n\t\t\t\t\ta[2] = _hue(h - 1 / 3, r, g);\n\t\t\t\t} else if (~v.indexOf(\"=\")) { //if relative values are found, just return the raw strings with the relative prefixes in place.\n\t\t\t\t\ta = v.match(_numExp);\n\t\t\t\t\tforceAlpha && a.length < 4 && (a[3] = 1);\n\t\t\t\t\treturn a;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ta = v.match(_strictNumExp) || _colorLookup.transparent;\n\t\t\t}\n\t\t\ta = a.map(Number);\n\t\t}\n\t\tif (toHSL && !wasHSL) {\n\t\t\tr = a[0] / _255;\n\t\t\tg = a[1] / _255;\n\t\t\tb = a[2] / _255;\n\t\t\tmax = Math.max(r, g, b);\n\t\t\tmin = Math.min(r, g, b);\n\t\t\tl = (max + min) / 2;\n\t\t\tif (max === min) {\n\t\t\t\th = s = 0;\n\t\t\t} else {\n\t\t\t\td = max - min;\n\t\t\t\ts = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n\t\t\t\th = max === r ? (g - b) / d + (g < b ? 6 : 0) : max === g ? (b - r) / d + 2 : (r - g) / d + 4;\n\t\t\t\th *= 60;\n\t\t\t}\n\t\t\ta[0] = ~~(h + .5);\n\t\t\ta[1] = ~~(s * 100 + .5);\n\t\t\ta[2] = ~~(l * 100 + .5);\n\t\t}\n\t\tforceAlpha && a.length < 4 && (a[3] = 1);\n\t\treturn a;\n\t},\n\t_colorOrderData = v => { // strips out the colors from the string, finds all the numeric slots (with units) and returns an array of those. The Array also has a \"c\" property which is an Array of the index values where the colors belong. This is to help work around issues where there's a mis-matched order of color/numeric data like drop-shadow(#f00 0px 1px 2px) and drop-shadow(0x 1px 2px #f00). This is basically a helper function used in _formatColors()\n\t\tlet values = [],\n\t\t\tc = [],\n\t\t\ti = -1;\n\t\tv.split(_colorExp).forEach(v => {\n\t\t\tlet a = v.match(_numWithUnitExp) || [];\n\t\t\tvalues.push(...a);\n\t\t\tc.push(i += a.length + 1);\n\t\t});\n\t\tvalues.c = c;\n\t\treturn values;\n\t},\n\t_formatColors = (s, toHSL, orderMatchData) => {\n\t\tlet result = \"\",\n\t\t\tcolors = (s + result).match(_colorExp),\n\t\t\ttype = toHSL ? \"hsla(\" : \"rgba(\",\n\t\t\ti = 0,\n\t\t\tc, shell, d, l;\n\t\tif (!colors) {\n\t\t\treturn s;\n\t\t}\n\t\tcolors = colors.map(color => (color = splitColor(color, toHSL, 1)) && type + (toHSL ? color[0] + \",\" + color[1] + \"%,\" + color[2] + \"%,\" + color[3] : color.join(\",\")) + \")\");\n\t\tif (orderMatchData) {\n\t\t\td = _colorOrderData(s);\n\t\t\tc = orderMatchData.c;\n\t\t\tif (c.join(result) !== d.c.join(result)) {\n\t\t\t\tshell = s.replace(_colorExp, \"1\").split(_numWithUnitExp);\n\t\t\t\tl = shell.length - 1;\n\t\t\t\tfor (; i < l; i++) {\n\t\t\t\t\tresult += shell[i] + (~c.indexOf(i) ? colors.shift() || type + \"0,0,0,0)\" : (d.length ? d : colors.length ? colors : orderMatchData).shift());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (!shell) {\n\t\t\tshell = s.split(_colorExp);\n\t\t\tl = shell.length - 1;\n\t\t\tfor (; i < l; i++) {\n\t\t\t\tresult += shell[i] + colors[i];\n\t\t\t}\n\t\t}\n\t\treturn result + shell[l];\n\t},\n\t_colorExp = (function() {\n\t\tlet s = \"(?:\\\\b(?:(?:rgb|rgba|hsl|hsla)\\\\(.+?\\\\))|\\\\B#(?:[0-9a-f]{3,4}){1,2}\\\\b\", //we'll dynamically build this Regular Expression to conserve file size. After building it, it will be able to find rgb(), rgba(), # (hexadecimal), and named color values like red, blue, purple, etc.,\n\t\t\tp;\n\t\tfor (p in _colorLookup) {\n\t\t\ts += \"|\" + p + \"\\\\b\";\n\t\t}\n\t\treturn new RegExp(s + \")\", \"gi\");\n\t})(),\n\t_hslExp = /hsl[a]?\\(/,\n\t_colorStringFilter = a => {\n\t\tlet combined = a.join(\" \"),\n\t\t\ttoHSL;\n\t\t_colorExp.lastIndex = 0;\n\t\tif (_colorExp.test(combined)) {\n\t\t\ttoHSL = _hslExp.test(combined);\n\t\t\ta[1] = _formatColors(a[1], toHSL);\n\t\t\ta[0] = _formatColors(a[0], toHSL, _colorOrderData(a[1])); // make sure the order of numbers/colors match with the END value.\n\t\t\treturn true;\n\t\t}\n\t},\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n/*\n * --------------------------------------------------------------------------------------\n * TICKER\n * --------------------------------------------------------------------------------------\n */\n\t_tickerActive,\n\t_ticker = (function() {\n\t\tlet _getTime = Date.now,\n\t\t\t_lagThreshold = 500,\n\t\t\t_adjustedLag = 33,\n\t\t\t_startTime = _getTime(),\n\t\t\t_lastUpdate = _startTime,\n\t\t\t_gap = 1000 / 240,\n\t\t\t_nextTime = _gap,\n\t\t\t_listeners = [],\n\t\t\t_id, _req, _raf, _self, _delta, _i,\n\t\t\t_tick = v => {\n\t\t\t\tlet elapsed = _getTime() - _lastUpdate,\n\t\t\t\t\tmanual = v === true,\n\t\t\t\t\toverlap, dispatch, time, frame;\n\t\t\t\t(elapsed > _lagThreshold || elapsed < 0) && (_startTime += elapsed - _adjustedLag);\n\t\t\t\t_lastUpdate += elapsed;\n\t\t\t\ttime = _lastUpdate - _startTime;\n\t\t\t\toverlap = time - _nextTime;\n\t\t\t\tif (overlap > 0 || manual) {\n\t\t\t\t\tframe = ++_self.frame;\n\t\t\t\t\t_delta = time - _self.time * 1000;\n\t\t\t\t\t_self.time = time = time / 1000;\n\t\t\t\t\t_nextTime += overlap + (overlap >= _gap ? 4 : _gap - overlap);\n\t\t\t\t\tdispatch = 1;\n\t\t\t\t}\n\t\t\t\tmanual || (_id = _req(_tick)); //make sure the request is made before we dispatch the \"tick\" event so that timing is maintained. Otherwise, if processing the \"tick\" requires a bunch of time (like 15ms) and we're using a setTimeout() that's based on 16.7ms, it'd technically take 31.7ms between frames otherwise.\n\t\t\t\tif (dispatch) {\n\t\t\t\t\tfor (_i = 0; _i < _listeners.length; _i++) { // use _i and check _listeners.length instead of a variable because a listener could get removed during the loop, and if that happens to an element less than the current index, it'd throw things off in the loop.\n\t\t\t\t\t\t_listeners[_i](time, _delta, frame, v);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t_self = {\n\t\t\ttime:0,\n\t\t\tframe:0,\n\t\t\ttick() {\n\t\t\t\t_tick(true);\n\t\t\t},\n\t\t\tdeltaRatio(fps) {\n\t\t\t\treturn _delta / (1000 / (fps || 60));\n\t\t\t},\n\t\t\twake() {\n\t\t\t\tif (_coreReady) {\n\t\t\t\t\tif (!_coreInitted && _windowExists()) {\n\t\t\t\t\t\t_win = _coreInitted = window;\n\t\t\t\t\t\t_doc = _win.document || {};\n\t\t\t\t\t\t_globals.gsap = gsap;\n\t\t\t\t\t\t(_win.gsapVersions || (_win.gsapVersions = [])).push(gsap.version);\n\t\t\t\t\t\t_install(_installScope || _win.GreenSockGlobals || (!_win.gsap && _win) || {});\n\t\t\t\t\t\t_registerPluginQueue.forEach(_createPlugin);\n\t\t\t\t\t}\n\t\t\t\t\t_raf = typeof(requestAnimationFrame) !== \"undefined\" && requestAnimationFrame;\n\t\t\t\t\t_id && _self.sleep();\n\t\t\t\t\t_req = _raf || (f => setTimeout(f, (_nextTime - _self.time * 1000 + 1) | 0));\n\t\t\t\t\t_tickerActive = 1;\n\t\t\t\t\t_tick(2);\n\t\t\t\t}\n\t\t\t},\n\t\t\tsleep() {\n\t\t\t\t(_raf ? cancelAnimationFrame : clearTimeout)(_id);\n\t\t\t\t_tickerActive = 0;\n\t\t\t\t_req = _emptyFunc;\n\t\t\t},\n\t\t\tlagSmoothing(threshold, adjustedLag) {\n\t\t\t\t_lagThreshold = threshold || Infinity; // zero should be interpreted as basically unlimited\n\t\t\t\t_adjustedLag = Math.min(adjustedLag || 33, _lagThreshold);\n\t\t\t},\n\t\t\tfps(fps) {\n\t\t\t\t_gap = 1000 / (fps || 240);\n\t\t\t\t_nextTime = _self.time * 1000 + _gap;\n\t\t\t},\n\t\t\tadd(callback, once, prioritize) {\n\t\t\t\tlet func = once ? (t, d, f, v) => {callback(t, d, f, v); _self.remove(func);} : callback;\n\t\t\t\t_self.remove(callback);\n\t\t\t\t_listeners[prioritize ? \"unshift\" : \"push\"](func);\n\t\t\t\t_wake();\n\t\t\t\treturn func;\n\t\t\t},\n\t\t\tremove(callback, i) {\n\t\t\t\t~(i = _listeners.indexOf(callback)) && _listeners.splice(i, 1) && _i >= i && _i--;\n\t\t\t},\n\t\t\t_listeners:_listeners\n\t\t};\n\t\treturn _self;\n\t})(),\n\t_wake = () => !_tickerActive && _ticker.wake(), //also ensures the core classes are initialized.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n/*\n* -------------------------------------------------\n* EASING\n* -------------------------------------------------\n*/\n\t_easeMap = {},\n\t_customEaseExp = /^[\\d.\\-M][\\d.\\-,\\s]/,\n\t_quotesExp = /[\"']/g,\n\t_parseObjectInString = value => { //takes a string like \"{wiggles:10, type:anticipate})\" and turns it into a real object. Notice it ends in \")\" and includes the {} wrappers. This is because we only use this function for parsing ease configs and prioritized optimization rather than reusability.\n\t\tlet obj = {},\n\t\t\tsplit = value.substr(1, value.length-3).split(\":\"),\n\t\t\tkey = split[0],\n\t\t\ti = 1,\n\t\t\tl = split.length,\n\t\t\tindex, val, parsedVal;\n\t\tfor (; i < l; i++) {\n\t\t\tval = split[i];\n\t\t\tindex = i !== l-1 ? val.lastIndexOf(\",\") : val.length;\n\t\t\tparsedVal = val.substr(0, index);\n\t\t\tobj[key] = isNaN(parsedVal) ? parsedVal.replace(_quotesExp, \"\").trim() : +parsedVal;\n\t\t\tkey = val.substr(index+1).trim();\n\t\t}\n\t\treturn obj;\n\t},\n\t_valueInParentheses = value => {\n\t\tlet open = value.indexOf(\"(\") + 1,\n\t\t\tclose = value.indexOf(\")\"),\n\t\t\tnested = value.indexOf(\"(\", open);\n\t\treturn value.substring(open, ~nested && nested < close ? value.indexOf(\")\", close + 1) : close);\n\t},\n\t_configEaseFromString = name => { //name can be a string like \"elastic.out(1,0.5)\", and pass in _easeMap as obj and it'll parse it out and call the actual function like _easeMap.Elastic.easeOut.config(1,0.5). It will also parse custom ease strings as long as CustomEase is loaded and registered (internally as _easeMap._CE).\n\t\tlet split = (name + \"\").split(\"(\"),\n\t\t\tease = _easeMap[split[0]];\n\t\treturn (ease && split.length > 1 && ease.config) ? ease.config.apply(null, ~name.indexOf(\"{\") ? [_parseObjectInString(split[1])] : _valueInParentheses(name).split(\",\").map(_numericIfPossible)) : (_easeMap._CE && _customEaseExp.test(name)) ? _easeMap._CE(\"\", name) : ease;\n\t},\n\t_invertEase = ease => p => 1 - ease(1 - p),\n\t// allow yoyoEase to be set in children and have those affected when the parent/ancestor timeline yoyos.\n\t_propagateYoyoEase = (timeline, isYoyo) => {\n\t\tlet child = timeline._first, ease;\n\t\twhile (child) {\n\t\t\tif (child instanceof Timeline) {\n\t\t\t\t_propagateYoyoEase(child, isYoyo);\n\t\t\t} else if (child.vars.yoyoEase && (!child._yoyo || !child._repeat) && child._yoyo !== isYoyo) {\n\t\t\t\tif (child.timeline) {\n\t\t\t\t\t_propagateYoyoEase(child.timeline, isYoyo);\n\t\t\t\t} else {\n\t\t\t\t\tease = child._ease;\n\t\t\t\t\tchild._ease = child._yEase;\n\t\t\t\t\tchild._yEase = ease;\n\t\t\t\t\tchild._yoyo = isYoyo;\n\t\t\t\t}\n\t\t\t}\n\t\t\tchild = child._next;\n\t\t}\n\t},\n\t_parseEase = (ease, defaultEase) => !ease ? defaultEase : (_isFunction(ease) ? ease : _easeMap[ease] || _configEaseFromString(ease)) || defaultEase,\n\t_insertEase = (names, easeIn, easeOut = p => 1 - easeIn(1 - p), easeInOut = (p => p < .5 ? easeIn(p * 2) / 2 : 1 - easeIn((1 - p) * 2) / 2)) => {\n\t\tlet ease = {easeIn, easeOut, easeInOut},\n\t\t\tlowercaseName;\n\t\t_forEachName(names, name => {\n\t\t\t_easeMap[name] = _globals[name] = ease;\n\t\t\t_easeMap[(lowercaseName = name.toLowerCase())] = easeOut;\n\t\t\tfor (let p in ease) {\n\t\t\t\t_easeMap[lowercaseName + (p === \"easeIn\" ? \".in\" : p === \"easeOut\" ? \".out\" : \".inOut\")] = _easeMap[name + \".\" + p] = ease[p];\n\t\t\t}\n\t\t});\n\t\treturn ease;\n\t},\n\t_easeInOutFromOut = easeOut => (p => p < .5 ? (1 - easeOut(1 - (p * 2))) / 2 : .5 + easeOut((p - .5) * 2) / 2),\n\t_configElastic = (type, amplitude, period) => {\n\t\tlet p1 = (amplitude >= 1) ? amplitude : 1, //note: if amplitude is < 1, we simply adjust the period for a more natural feel. Otherwise the math doesn't work right and the curve starts at 1.\n\t\t\tp2 = (period || (type ? .3 : .45)) / (amplitude < 1 ? amplitude : 1),\n\t\t\tp3 = p2 / _2PI * (Math.asin(1 / p1) || 0),\n\t\t\teaseOut = p => p === 1 ? 1 : p1 * (2 ** (-10 * p)) * _sin((p - p3) * p2) + 1,\n\t\t\tease = (type === \"out\") ? easeOut : (type === \"in\") ? p => 1 - easeOut(1 - p) : _easeInOutFromOut(easeOut);\n\t\tp2 = _2PI / p2; //precalculate to optimize\n\t\tease.config = (amplitude, period) => _configElastic(type, amplitude, period);\n\t\treturn ease;\n\t},\n\t_configBack = (type, overshoot = 1.70158) => {\n\t\tlet easeOut = p => p ? ((--p) * p * ((overshoot + 1) * p + overshoot) + 1) : 0,\n\t\t\tease = type === \"out\" ? easeOut : type === \"in\" ? p => 1 - easeOut(1 - p) : _easeInOutFromOut(easeOut);\n\t\tease.config = overshoot => _configBack(type, overshoot);\n\t\treturn ease;\n\t};\n\t// a cheaper (kb and cpu) but more mild way to get a parameterized weighted ease by feeding in a value between -1 (easeIn) and 1 (easeOut) where 0 is linear.\n\t// _weightedEase = ratio => {\n\t// \tlet y = 0.5 + ratio / 2;\n\t// \treturn p => (2 * (1 - p) * p * y + p * p);\n\t// },\n\t// a stronger (but more expensive kb/cpu) parameterized weighted ease that lets you feed in a value between -1 (easeIn) and 1 (easeOut) where 0 is linear.\n\t// _weightedEaseStrong = ratio => {\n\t// \tratio = .5 + ratio / 2;\n\t// \tlet o = 1 / 3 * (ratio < .5 ? ratio : 1 - ratio),\n\t// \t\tb = ratio - o,\n\t// \t\tc = ratio + o;\n\t// \treturn p => p === 1 ? p : 3 * b * (1 - p) * (1 - p) * p + 3 * c * (1 - p) * p * p + p * p * p;\n\t// };\n\n_forEachName(\"Linear,Quad,Cubic,Quart,Quint,Strong\", (name, i) => {\n\tlet power = i < 5 ? i + 1 : i;\n\t_insertEase(name + \",Power\" + (power - 1), i ? p => p ** power : p => p, p => 1 - (1 - p) ** power, p => p < .5 ? (p * 2) ** power / 2 : 1 - ((1 - p) * 2) ** power / 2);\n});\n_easeMap.Linear.easeNone = _easeMap.none = _easeMap.Linear.easeIn;\n_insertEase(\"Elastic\", _configElastic(\"in\"), _configElastic(\"out\"), _configElastic());\n((n, c) => {\n\tlet n1 = 1 / c,\n\t\tn2 = 2 * n1,\n\t\tn3 = 2.5 * n1,\n\t\teaseOut = p => (p < n1) ? n * p * p : (p < n2) ? n * (p - 1.5 / c) ** 2 + .75 : (p < n3) ? n * (p -= 2.25 / c) * p + .9375 : n * (p - 2.625 / c) ** 2 + .984375;\n\t_insertEase(\"Bounce\", p => 1 - easeOut(1 - p), easeOut);\n})(7.5625, 2.75);\n_insertEase(\"Expo\", p => (2 ** (10 * (p - 1))) * p + p * p * p * p * p * p * (1-p)); // previously 2 ** (10 * (p - 1)) but that doesn't end up with the value quite at the right spot so we do a blended ease to ensure it lands where it should perfectly.\n_insertEase(\"Circ\", p => -(_sqrt(1 - (p * p)) - 1));\n_insertEase(\"Sine\", p => p === 1 ? 1 : -_cos(p * _HALF_PI) + 1);\n_insertEase(\"Back\", _configBack(\"in\"), _configBack(\"out\"), _configBack());\n_easeMap.SteppedEase = _easeMap.steps = _globals.SteppedEase = {\n\tconfig(steps = 1, immediateStart) {\n\t\tlet p1 = 1 / steps,\n\t\t\tp2 = steps + (immediateStart ? 0 : 1),\n\t\t\tp3 = immediateStart ? 1 : 0,\n\t\t\tmax = 1 - _tinyNum;\n\t\treturn p => (((p2 * _clamp(0, max, p)) | 0) + p3) * p1;\n\t}\n};\n_defaults.ease = _easeMap[\"quad.out\"];\n\n\n_forEachName(\"onComplete,onUpdate,onStart,onRepeat,onReverseComplete,onInterrupt\", name => _callbackNames += name + \",\" + name + \"Params,\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n/*\n * --------------------------------------------------------------------------------------\n * CACHE\n * --------------------------------------------------------------------------------------\n */\nexport class GSCache {\n\n\tconstructor(target, harness) {\n\t\tthis.id = _gsID++;\n\t\ttarget._gsap = this;\n\t\tthis.target = target;\n\t\tthis.harness = harness;\n\t\tthis.get = harness ? harness.get : _getProperty;\n\t\tthis.set = harness ? harness.getSetter : _getSetter;\n\t}\n\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n/*\n * --------------------------------------------------------------------------------------\n * ANIMATION\n * --------------------------------------------------------------------------------------\n */\n\nexport class Animation {\n\n\tconstructor(vars) {\n\t\tthis.vars = vars;\n\t\tthis._delay = +vars.delay || 0;\n\t\tif ((this._repeat = vars.repeat === Infinity ? -2 : vars.repeat || 0)) { // TODO: repeat: Infinity on a timeline's children must flag that timeline internally and affect its totalDuration, otherwise it'll stop in the negative direction when reaching the start.\n\t\t\tthis._rDelay = vars.repeatDelay || 0;\n\t\t\tthis._yoyo = !!vars.yoyo || !!vars.yoyoEase;\n\t\t}\n\t\tthis._ts = 1;\n\t\t_setDuration(this, +vars.duration, 1, 1);\n\t\tthis.data = vars.data;\n\t\tif (_context) {\n\t\t\tthis._ctx = _context;\n\t\t\t_context.data.push(this);\n\t\t}\n\t\t_tickerActive || _ticker.wake();\n\t}\n\n\tdelay(value) {\n\t\tif (value || value === 0) {\n\t\t\tthis.parent && this.parent.smoothChildTiming && (this.startTime(this._start + value - this._delay));\n\t\t\tthis._delay = value;\n\t\t\treturn this;\n\t\t}\n\t\treturn this._delay;\n\t}\n\n\tduration(value) {\n\t\treturn arguments.length ? this.totalDuration(this._repeat > 0 ? value + (value + this._rDelay) * this._repeat : value) : this.totalDuration() && this._dur;\n\t}\n\n\ttotalDuration(value) {\n\t\tif (!arguments.length) {\n\t\t\treturn this._tDur;\n\t\t}\n\t\tthis._dirty = 0;\n\t\treturn _setDuration(this, this._repeat < 0 ? value : (value - (this._repeat * this._rDelay)) / (this._repeat + 1));\n\t}\n\n\ttotalTime(totalTime, suppressEvents) {\n\t\t_wake();\n\t\tif (!arguments.length) {\n\t\t\treturn this._tTime;\n\t\t}\n\t\tlet parent = this._dp;\n\t\tif (parent && parent.smoothChildTiming && this._ts) {\n\t\t\t_alignPlayhead(this, totalTime);\n\t\t\t!parent._dp || parent.parent || _postAddChecks(parent, this); // edge case: if this is a child of a timeline that already completed, for example, we must re-activate the parent.\n\t\t\t//in case any of the ancestor timelines had completed but should now be enabled, we should reset their totalTime() which will also ensure that they're lined up properly and enabled. Skip for animations that are on the root (wasteful). Example: a TimelineLite.exportRoot() is performed when there's a paused tween on the root, the export will not complete until that tween is unpaused, but imagine a child gets restarted later, after all [unpaused] tweens have completed. The start of that child would get pushed out, but one of the ancestors may have completed.\n\t\t\twhile (parent && parent.parent) {\n\t\t\t\tif (parent.parent._time !== parent._start + (parent._ts >= 0 ? parent._tTime / parent._ts : (parent.totalDuration() - parent._tTime) / -parent._ts)) {\n\t\t\t\t\tparent.totalTime(parent._tTime, true);\n\t\t\t\t}\n\t\t\t\tparent = parent.parent;\n\t\t\t}\n\t\t\tif (!this.parent && this._dp.autoRemoveChildren && ((this._ts > 0 && totalTime < this._tDur) || (this._ts < 0 && totalTime > 0) || (!this._tDur && !totalTime) )) { //if the animation doesn't have a parent, put it back into its last parent (recorded as _dp for exactly cases like this). Limit to parents with autoRemoveChildren (like globalTimeline) so that if the user manually removes an animation from a timeline and then alters its playhead, it doesn't get added back in.\n\t\t\t\t_addToTimeline(this._dp, this, this._start - this._delay);\n\t\t\t}\n\t\t}\n if (this._tTime !== totalTime || (!this._dur && !suppressEvents) || (this._initted && Math.abs(this._zTime) === _tinyNum) || (!totalTime && !this._initted && (this.add || this._ptLookup))) { // check for _ptLookup on a Tween instance to ensure it has actually finished being instantiated, otherwise if this.reverse() gets called in the Animation constructor, it could trigger a render() here even though the _targets weren't populated, thus when _init() is called there won't be any PropTweens (it'll act like the tween is non-functional)\n \tthis._ts || (this._pTime = totalTime); // otherwise, if an animation is paused, then the playhead is moved back to zero, then resumed, it'd revert back to the original time at the pause\n\t //if (!this._lock) { // avoid endless recursion (not sure we need this yet or if it's worth the performance hit)\n\t\t // this._lock = 1;\n\t\t _lazySafeRender(this, totalTime, suppressEvents);\n\t\t // this._lock = 0;\n\t //}\n\t\t}\n\t\treturn this;\n\t}\n\n\ttime(value, suppressEvents) {\n\t\treturn arguments.length ? this.totalTime((Math.min(this.totalDuration(), value + _elapsedCycleDuration(this)) % (this._dur + this._rDelay)) || (value ? this._dur : 0), suppressEvents) : this._time; // note: if the modulus results in 0, the playhead could be exactly at the end or the beginning, and we always defer to the END with a non-zero value, otherwise if you set the time() to the very end (duration()), it would render at the START!\n\t}\n\n\ttotalProgress(value, suppressEvents) {\n\t\treturn arguments.length ? this.totalTime( this.totalDuration() * value, suppressEvents) : this.totalDuration() ? Math.min(1, this._tTime / this._tDur) : this.rawTime() >= 0 && this._initted ? 1 : 0;\n\t}\n\n\tprogress(value, suppressEvents) {\n\t\treturn arguments.length ? this.totalTime( this.duration() * (this._yoyo && !(this.iteration() & 1) ? 1 - value : value) + _elapsedCycleDuration(this), suppressEvents) : (this.duration() ? Math.min(1, this._time / this._dur) : this.rawTime() > 0 ? 1 : 0);\n\t}\n\n\titeration(value, suppressEvents) {\n\t\tlet cycleDuration = this.duration() + this._rDelay;\n\t\treturn arguments.length ? this.totalTime(this._time + (value - 1) * cycleDuration, suppressEvents) : this._repeat ? _animationCycle(this._tTime, cycleDuration) + 1 : 1;\n\t}\n\n\t// potential future addition:\n\t// isPlayingBackwards() {\n\t// \tlet animation = this,\n\t// \t\torientation = 1; // 1 = forward, -1 = backward\n\t// \twhile (animation) {\n\t// \t\torientation *= animation.reversed() || (animation.repeat() && !(animation.iteration() & 1)) ? -1 : 1;\n\t// \t\tanimation = animation.parent;\n\t// \t}\n\t// \treturn orientation < 0;\n\t// }\n\n\ttimeScale(value, suppressEvents) {\n\t\tif (!arguments.length) {\n\t\t\treturn this._rts === -_tinyNum ? 0 : this._rts; // recorded timeScale. Special case: if someone calls reverse() on an animation with timeScale of 0, we assign it -_tinyNum to remember it's reversed.\n\t\t}\n\t\tif (this._rts === value) {\n\t\t\treturn this;\n\t\t}\n\t\tlet tTime = this.parent && this._ts ? _parentToChildTotalTime(this.parent._time, this) : this._tTime; // make sure to do the parentToChildTotalTime() BEFORE setting the new _ts because the old one must be used in that calculation.\n\n\t\t// future addition? Up side: fast and minimal file size. Down side: only works on this animation; if a timeline is reversed, for example, its childrens' onReverse wouldn't get called.\n\t\t//(+value < 0 && this._rts >= 0) && _callback(this, \"onReverse\", true);\n\n\t\t// prioritize rendering where the parent's playhead lines up instead of this._tTime because there could be a tween that's animating another tween's timeScale in the same rendering loop (same parent), thus if the timeScale tween renders first, it would alter _start BEFORE _tTime was set on that tick (in the rendering loop), effectively freezing it until the timeScale tween finishes.\n\t\tthis._rts = +value || 0;\n\t\tthis._ts = (this._ps || value === -_tinyNum) ? 0 : this._rts; // _ts is the functional timeScale which would be 0 if the animation is paused.\n\t\tthis.totalTime(_clamp(-Math.abs(this._delay), this._tDur, tTime), suppressEvents !== false);\n\t\t_setEnd(this); // if parent.smoothChildTiming was false, the end time didn't get updated in the _alignPlayhead() method, so do it here.\n\t\treturn _recacheAncestors(this);\n\t}\n\n\tpaused(value) {\n\t\tif (!arguments.length) {\n\t\t\treturn this._ps;\n\t\t}\n\t\t// possible future addition - if an animation is removed from its parent and then .restart() or .play() or .resume() is called, perhaps we should force it back into the globalTimeline but be careful because what if it's already at its end? We don't want it to just persist forever and not get released for GC.\n\t\t// !this.parent && !value && this._tTime < this._tDur && this !== _globalTimeline && _globalTimeline.add(this);\n\t\tif (this._ps !== value) {\n\t\t\tthis._ps = value;\n\t\t\tif (value) {\n\t\t\t\tthis._pTime = this._tTime || Math.max(-this._delay, this.rawTime()); // if the pause occurs during the delay phase, make sure that's factored in when resuming.\n\t\t\t\tthis._ts = this._act = 0; // _ts is the functional timeScale, so a paused tween would effectively have a timeScale of 0. We record the \"real\" timeScale as _rts (recorded time scale)\n\t\t\t} else {\n\t\t\t\t_wake();\n\t\t\t\tthis._ts = this._rts;\n\t\t\t\t//only defer to _pTime (pauseTime) if tTime is zero. Remember, someone could pause() an animation, then scrub the playhead and resume(). If the parent doesn't have smoothChildTiming, we render at the rawTime() because the startTime won't get updated.\n\t\t\t\tthis.totalTime(this.parent && !this.parent.smoothChildTiming ? this.rawTime() : this._tTime || this._pTime, (this.progress() === 1) && Math.abs(this._zTime) !== _tinyNum && (this._tTime -= _tinyNum)); // edge case: animation.progress(1).pause().play() wouldn't render again because the playhead is already at the end, but the call to totalTime() below will add it back to its parent...and not remove it again (since removing only happens upon rendering at a new time). Offsetting the _tTime slightly is done simply to cause the final render in totalTime() that'll pop it off its timeline (if autoRemoveChildren is true, of course). Check to make sure _zTime isn't -_tinyNum to avoid an edge case where the playhead is pushed to the end but INSIDE a tween/callback, the timeline itself is paused thus halting rendering and leaving a few unrendered. When resuming, it wouldn't render those otherwise.\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\tstartTime(value) {\n\t\tif (arguments.length) {\n\t\t\tthis._start = value;\n\t\t\tlet parent = this.parent || this._dp;\n\t\t\tparent && (parent._sort || !this.parent) && _addToTimeline(parent, this, value - this._delay);\n\t\t\treturn this;\n\t\t}\n\t\treturn this._start;\n\t}\n\n\tendTime(includeRepeats) {\n\t\treturn this._start + (_isNotFalse(includeRepeats) ? this.totalDuration() : this.duration()) / Math.abs(this._ts || 1);\n\t}\n\n\trawTime(wrapRepeats) {\n\t\tlet parent = this.parent || this._dp; // _dp = detached parent\n\t\treturn !parent ? this._tTime : (wrapRepeats && (!this._ts || (this._repeat && this._time && this.totalProgress() < 1))) ? this._tTime % (this._dur + this._rDelay) : !this._ts ? this._tTime : _parentToChildTotalTime(parent.rawTime(wrapRepeats), this);\n\t}\n\n\trevert(config= _revertConfig) {\n\t\tlet prevIsReverting = _reverting;\n\t\t_reverting = config;\n\t\tif (this._initted || this._startAt) {\n\t\t\tthis.timeline && this.timeline.revert(config);\n\t\t\tthis.totalTime(-0.01, config.suppressEvents);\n\t\t}\n\t\tthis.data !== \"nested\" && config.kill !== false && this.kill();\n\t\t_reverting = prevIsReverting;\n\t\treturn this;\n\t}\n\n\tglobalTime(rawTime) {\n\t\tlet animation = this,\n\t\t\ttime = arguments.length ? rawTime : animation.rawTime();\n\t\twhile (animation) {\n\t\t\ttime = animation._start + time / (Math.abs(animation._ts) || 1);\n\t\t\tanimation = animation._dp;\n\t\t}\n\t\treturn !this.parent && this._sat ? this._sat.globalTime(rawTime) : time; // the _startAt tweens for .fromTo() and .from() that have immediateRender should always be FIRST in the timeline (important for context.revert()). \"_sat\" stands for _startAtTween, referring to the parent tween that created the _startAt. We must discern if that tween had immediateRender so that we can know whether or not to prioritize it in revert().\n\t}\n\n\trepeat(value) {\n\t\tif (arguments.length) {\n\t\t\tthis._repeat = value === Infinity ? -2 : value;\n\t\t\treturn _onUpdateTotalDuration(this);\n\t\t}\n\t\treturn this._repeat === -2 ? Infinity : this._repeat;\n\t}\n\n\trepeatDelay(value) {\n\t\tif (arguments.length) {\n\t\t\tlet time = this._time;\n\t\t\tthis._rDelay = value;\n\t\t\t_onUpdateTotalDuration(this);\n\t\t\treturn time ? this.time(time) : this;\n\t\t}\n\t\treturn this._rDelay;\n\t}\n\n\tyoyo(value) {\n\t\tif (arguments.length) {\n\t\t\tthis._yoyo = value;\n\t\t\treturn this;\n\t\t}\n\t\treturn this._yoyo;\n\t}\n\n\tseek(position, suppressEvents) {\n\t\treturn this.totalTime(_parsePosition(this, position), _isNotFalse(suppressEvents));\n\t}\n\n\trestart(includeDelay, suppressEvents) {\n\t\tthis.play().totalTime(includeDelay ? -this._delay : 0, _isNotFalse(suppressEvents));\n\t\tthis._dur || (this._zTime = -_tinyNum); // ensures onComplete fires on a zero-duration animation that gets restarted.\n\t\treturn this;\n\t}\n\n\tplay(from, suppressEvents) {\n\t\tfrom != null && this.seek(from, suppressEvents);\n\t\treturn this.reversed(false).paused(false);\n\t}\n\n\treverse(from, suppressEvents) {\n\t\tfrom != null && this.seek(from || this.totalDuration(), suppressEvents);\n\t\treturn this.reversed(true).paused(false);\n\t}\n\n\tpause(atTime, suppressEvents) {\n\t\tatTime != null && this.seek(atTime, suppressEvents);\n\t\treturn this.paused(true);\n\t}\n\n\tresume() {\n\t\treturn this.paused(false);\n\t}\n\n\treversed(value) {\n\t\tif (arguments.length) {\n\t\t\t!!value !== this.reversed() && this.timeScale(-this._rts || (value ? -_tinyNum : 0)); // in case timeScale is zero, reversing would have no effect so we use _tinyNum.\n\t\t\treturn this;\n\t\t}\n\t\treturn this._rts < 0;\n\t}\n\n\tinvalidate() {\n\t\tthis._initted = this._act = 0;\n\t\tthis._zTime = -_tinyNum;\n\t\treturn this;\n\t}\n\n\tisActive() {\n\t\tlet parent = this.parent || this._dp,\n\t\t\tstart = this._start,\n\t\t\trawTime;\n\t\treturn !!(!parent || (this._ts && this._initted && parent.isActive() && (rawTime = parent.rawTime(true)) >= start && rawTime < this.endTime(true) - _tinyNum));\n\t}\n\n\teventCallback(type, callback, params) {\n\t\tlet vars = this.vars;\n\t\tif (arguments.length > 1) {\n\t\t\tif (!callback) {\n\t\t\t\tdelete vars[type];\n\t\t\t} else {\n\t\t\t\tvars[type] = callback;\n\t\t\t\tparams && (vars[type + \"Params\"] = params);\n\t\t\t\ttype === \"onUpdate\" && (this._onUpdate = callback);\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\treturn vars[type];\n\t}\n\n\tthen(onFulfilled) {\n\t\tlet self = this;\n\t\treturn new Promise(resolve => {\n\t\t\tlet f = _isFunction(onFulfilled) ? onFulfilled : _passThrough,\n\t\t\t\t_resolve = () => {\n\t\t\t\t\tlet _then = self.then;\n\t\t\t\t\tself.then = null; // temporarily null the then() method to avoid an infinite loop (see https://github.com/greensock/GSAP/issues/322)\n\t\t\t\t\t_isFunction(f) && (f = f(self)) && (f.then || f === self) && (self.then = _then);\n\t\t\t\t\tresolve(f);\n\t\t\t\t\tself.then = _then;\n\t\t\t\t};\n\t\t\tif (self._initted && (self.totalProgress() === 1 && self._ts >= 0) || (!self._tTime && self._ts < 0)) {\n\t\t\t\t_resolve();\n\t\t\t} else {\n\t\t\t\tself._prom = _resolve;\n\t\t\t}\n\t\t});\n\t}\n\n\tkill() {\n\t\t_interrupt(this);\n\t}\n\n}\n\n_setDefaults(Animation.prototype, {_time:0, _start:0, _end:0, _tTime:0, _tDur:0, _dirty:0, _repeat:0, _yoyo:false, parent:null, _initted:false, _rDelay:0, _ts:1, _dp:0, ratio:0, _zTime:-_tinyNum, _prom:0, _ps:false, _rts:1});\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n/*\n * -------------------------------------------------\n * TIMELINE\n * -------------------------------------------------\n */\n\nexport class Timeline extends Animation {\n\n\tconstructor(vars = {}, position) {\n\t\tsuper(vars);\n\t\tthis.labels = {};\n\t\tthis.smoothChildTiming = !!vars.smoothChildTiming;\n\t\tthis.autoRemoveChildren = !!vars.autoRemoveChildren;\n\t\tthis._sort = _isNotFalse(vars.sortChildren);\n\t\t_globalTimeline && _addToTimeline(vars.parent || _globalTimeline, this, position);\n\t\tvars.reversed && this.reverse();\n\t\tvars.paused && this.paused(true);\n\t\tvars.scrollTrigger && _scrollTrigger(this, vars.scrollTrigger);\n\t}\n\n\tto(targets, vars, position) {\n\t\t_createTweenType(0, arguments, this);\n\t\treturn this;\n\t}\n\n\tfrom(targets, vars, position) {\n\t\t_createTweenType(1, arguments, this);\n\t\treturn this;\n\t}\n\n\tfromTo(targets, fromVars, toVars, position) {\n\t\t_createTweenType(2, arguments, this);\n\t\treturn this;\n\t}\n\n\tset(targets, vars, position) {\n\t\tvars.duration = 0;\n\t\tvars.parent = this;\n\t\t_inheritDefaults(vars).repeatDelay || (vars.repeat = 0);\n\t\tvars.immediateRender = !!vars.immediateRender;\n\t\tnew Tween(targets, vars, _parsePosition(this, position), 1);\n\t\treturn this;\n\t}\n\n\tcall(callback, params, position) {\n\t\treturn _addToTimeline(this, Tween.delayedCall(0, callback, params), position);\n\t}\n\n\t//ONLY for backward compatibility! Maybe delete?\n\tstaggerTo(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams) {\n\t\tvars.duration = duration;\n\t\tvars.stagger = vars.stagger || stagger;\n\t\tvars.onComplete = onCompleteAll;\n\t\tvars.onCompleteParams = onCompleteAllParams;\n\t\tvars.parent = this;\n\t\tnew Tween(targets, vars, _parsePosition(this, position));\n\t\treturn this;\n\t}\n\n\tstaggerFrom(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams) {\n\t\tvars.runBackwards = 1;\n\t\t_inheritDefaults(vars).immediateRender = _isNotFalse(vars.immediateRender);\n\t\treturn this.staggerTo(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams);\n\t}\n\n\tstaggerFromTo(targets, duration, fromVars, toVars, stagger, position, onCompleteAll, onCompleteAllParams) {\n\t\ttoVars.startAt = fromVars;\n\t\t_inheritDefaults(toVars).immediateRender = _isNotFalse(toVars.immediateRender);\n\t\treturn this.staggerTo(targets, duration, toVars, stagger, position, onCompleteAll, onCompleteAllParams);\n\t}\n\n\trender(totalTime, suppressEvents, force) {\n\t\tlet prevTime = this._time,\n\t\t\ttDur = this._dirty ? this.totalDuration() : this._tDur,\n\t\t\tdur = this._dur,\n\t\t\ttTime = totalTime <= 0 ? 0 : _roundPrecise(totalTime), // if a paused timeline is resumed (or its _start is updated for another reason...which rounds it), that could result in the playhead shifting a **tiny** amount and a zero-duration child at that spot may get rendered at a different ratio, like its totalTime in render() may be 1e-17 instead of 0, for example.\n\t\t\tcrossingStart = (this._zTime < 0) !== (totalTime < 0) && (this._initted || !dur),\n\t\t\ttime, child, next, iteration, cycleDuration, prevPaused, pauseTween, timeScale, prevStart, prevIteration, yoyo, isYoyo;\n\t\tthis !== _globalTimeline && tTime > tDur && totalTime >= 0 && (tTime = tDur);\n\t\tif (tTime !== this._tTime || force || crossingStart) {\n\t\t\tif (prevTime !== this._time && dur) { //if totalDuration() finds a child with a negative startTime and smoothChildTiming is true, things get shifted around internally so we need to adjust the time accordingly. For example, if a tween starts at -30 we must shift EVERYTHING forward 30 seconds and move this timeline's startTime backward by 30 seconds so that things align with the playhead (no jump).\n\t\t\t\ttTime += this._time - prevTime;\n\t\t\t\ttotalTime += this._time - prevTime;\n\t\t\t}\n\t\t\ttime = tTime;\n\t\t\tprevStart = this._start;\n\t\t\ttimeScale = this._ts;\n\t\t\tprevPaused = !timeScale;\n\t\t\tif (crossingStart) {\n\t\t\t\tdur || (prevTime = this._zTime);\n\t\t\t\t //when the playhead arrives at EXACTLY time 0 (right on top) of a zero-duration timeline, we need to discern if events are suppressed so that when the playhead moves again (next time), it'll trigger the callback. If events are NOT suppressed, obviously the callback would be triggered in this render. Basically, the callback should fire either when the playhead ARRIVES or LEAVES this exact spot, not both. Imagine doing a timeline.seek(0) and there's a callback that sits at 0. Since events are suppressed on that seek() by default, nothing will fire, but when the playhead moves off of that position, the callback should fire. This behavior is what people intuitively expect.\n\t\t\t\t(totalTime || !suppressEvents) && (this._zTime = totalTime);\n\t\t\t}\n\t\t\tif (this._repeat) { //adjust the time for repeats and yoyos\n\t\t\t\tyoyo = this._yoyo;\n\t\t\t\tcycleDuration = dur + this._rDelay;\n\t\t\t\tif (this._repeat < -1 && totalTime < 0) {\n\t\t\t\t\treturn this.totalTime(cycleDuration * 100 + totalTime, suppressEvents, force);\n\t\t\t\t}\n\t\t\t\ttime = _roundPrecise(tTime % cycleDuration); //round to avoid floating point errors. (4 % 0.8 should be 0 but some browsers report it as 0.79999999!)\n\t\t\t\tif (tTime === tDur) { // the tDur === tTime is for edge cases where there's a lengthy decimal on the duration and it may reach the very end but the time is rendered as not-quite-there (remember, tDur is rounded to 4 decimals whereas dur isn't)\n\t\t\t\t\titeration = this._repeat;\n\t\t\t\t\ttime = dur;\n\t\t\t\t} else {\n\t\t\t\t\tprevIteration = _roundPrecise(tTime / cycleDuration); // full decimal version of iterations, not the previous iteration (we're reusing prevIteration variable for efficiency)\n\t\t\t\t\titeration = ~~prevIteration;\n\t\t\t\t\tif (iteration && iteration === prevIteration) {\n\t\t\t\t\t\ttime = dur;\n\t\t\t\t\t\titeration--;\n\t\t\t\t\t}\n\t\t\t\t\ttime > dur && (time = dur);\n\t\t\t\t}\n\t\t\t\tprevIteration = _animationCycle(this._tTime, cycleDuration);\n\t\t\t\t!prevTime && this._tTime && prevIteration !== iteration && this._tTime - prevIteration * cycleDuration - this._dur <= 0 && (prevIteration = iteration); // edge case - if someone does addPause() at the very beginning of a repeating timeline, that pause is technically at the same spot as the end which causes this._time to get set to 0 when the totalTime would normally place the playhead at the end. See https://gsap.com/forums/topic/23823-closing-nav-animation-not-working-on-ie-and-iphone-6-maybe-other-older-browser/?tab=comments#comment-113005 also, this._tTime - prevIteration * cycleDuration - this._dur <= 0 just checks to make sure it wasn't previously in the \"repeatDelay\" portion\n\t\t\t\tif (yoyo && (iteration & 1)) {\n\t\t\t\t\ttime = dur - time;\n\t\t\t\t\tisYoyo = 1;\n\t\t\t\t}\n\t\t\t\t/*\n\t\t\t\tmake sure children at the end/beginning of the timeline are rendered properly. If, for example,\n\t\t\t\ta 3-second long timeline rendered at 2.9 seconds previously, and now renders at 3.2 seconds (which\n\t\t\t\twould get translated to 2.8 seconds if the timeline yoyos or 0.2 seconds if it just repeats), there\n\t\t\t\tcould be a callback or a short tween that's at 2.95 or 3 seconds in which wouldn't render. So\n\t\t\t\twe need to push the timeline to the end (and/or beginning depending on its yoyo value). Also we must\n\t\t\t\tensure that zero-duration tweens at the very beginning or end of the Timeline work.\n\t\t\t\t*/\n\t\t\t\tif (iteration !== prevIteration && !this._lock) {\n\t\t\t\t\tlet rewinding = (yoyo && (prevIteration & 1)),\n\t\t\t\t\t\tdoesWrap = (rewinding === (yoyo && (iteration & 1)));\n\t\t\t\t\titeration < prevIteration && (rewinding = !rewinding);\n\t\t\t\t\tprevTime = rewinding ? 0 : tTime % dur ? dur : tTime; // if the playhead is landing exactly at the end of an iteration, use that totalTime rather than only the duration, otherwise it'll skip the 2nd render since it's effectively at the same time.\n\t\t\t\t\tthis._lock = 1;\n\t\t\t\t\tthis.render(prevTime || (isYoyo ? 0 : _roundPrecise(iteration * cycleDuration)), suppressEvents, !dur)._lock = 0;\n\t\t\t\t\tthis._tTime = tTime; // if a user gets the iteration() inside the onRepeat, for example, it should be accurate.\n\t\t\t\t\t!suppressEvents && this.parent && _callback(this, \"onRepeat\");\n\t\t\t\t\tthis.vars.repeatRefresh && !isYoyo && (this.invalidate()._lock = 1);\n\t\t\t\t\tif ((prevTime && prevTime !== this._time) || prevPaused !== !this._ts || (this.vars.onRepeat && !this.parent && !this._act)) { // if prevTime is 0 and we render at the very end, _time will be the end, thus won't match. So in this edge case, prevTime won't match _time but that's okay. If it gets killed in the onRepeat, eject as well.\n\t\t\t\t\t\treturn this;\n\t\t\t\t\t}\n\t\t\t\t\tdur = this._dur; // in case the duration changed in the onRepeat\n\t\t\t\t\ttDur = this._tDur;\n\t\t\t\t\tif (doesWrap) {\n\t\t\t\t\t\tthis._lock = 2;\n\t\t\t\t\t\tprevTime = rewinding ? dur : -0.0001;\n\t\t\t\t\t\tthis.render(prevTime, true);\n\t\t\t\t\t\tthis.vars.repeatRefresh && !isYoyo && this.invalidate();\n\t\t\t\t\t}\n\t\t\t\t\tthis._lock = 0;\n\t\t\t\t\tif (!this._ts && !prevPaused) {\n\t\t\t\t\t\treturn this;\n\t\t\t\t\t}\n\t\t\t\t\t//in order for yoyoEase to work properly when there's a stagger, we must swap out the ease in each sub-tween.\n\t\t\t\t\t_propagateYoyoEase(this, isYoyo);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this._hasPause && !this._forcing && this._lock < 2) {\n\t\t\t\tpauseTween = _findNextPauseTween(this, _roundPrecise(prevTime), _roundPrecise(time));\n\t\t\t\tif (pauseTween) {\n\t\t\t\t\ttTime -= time - (time = pauseTween._start);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis._tTime = tTime;\n\t\t\tthis._time = time;\n\t\t\tthis._act = !timeScale; //as long as it's not paused, force it to be active so that if the user renders independent of the parent timeline, it'll be forced to re-render on the next tick.\n\n\t\t\tif (!this._initted) {\n\t\t\t\tthis._onUpdate = this.vars.onUpdate;\n\t\t\t\tthis._initted = 1;\n\t\t\t\tthis._zTime = totalTime;\n\t\t\t\tprevTime = 0; // upon init, the playhead should always go forward; someone could invalidate() a completed timeline and then if they restart(), that would make child tweens render in reverse order which could lock in the wrong starting values if they build on each other, like tl.to(obj, {x: 100}).to(obj, {x: 0}).\n\t\t\t}\n\t\t\tif (!prevTime && time && !suppressEvents && !iteration) {\n\t\t\t\t_callback(this, \"onStart\");\n\t\t\t\tif (this._tTime !== tTime) { // in case the onStart triggered a render at a different spot, eject. Like if someone did animation.pause(0.5) or something inside the onStart.\n\t\t\t\t\treturn this;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (time >= prevTime && totalTime >= 0) {\n\t\t\t\tchild = this._first;\n\t\t\t\twhile (child) {\n\t\t\t\t\tnext = child._next;\n\t\t\t\t\tif ((child._act || time >= child._start) && child._ts && pauseTween !== child) {\n\t\t\t\t\t\tif (child.parent !== this) { // an extreme edge case - the child's render could do something like kill() the \"next\" one in the linked list, or reparent it. In that case we must re-initiate the whole render to be safe.\n\t\t\t\t\t\t\treturn this.render(totalTime, suppressEvents, force);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tchild.render(child._ts > 0 ? (time - child._start) * child._ts : (child._dirty ? child.totalDuration() : child._tDur) + (time - child._start) * child._ts, suppressEvents, force);\n\t\t\t\t\t\tif (time !== this._time || (!this._ts && !prevPaused)) { //in case a tween pauses or seeks the timeline when rendering, like inside of an onUpdate/onComplete\n\t\t\t\t\t\t\tpauseTween = 0;\n\t\t\t\t\t\t\tnext && (tTime += (this._zTime = -_tinyNum)); // it didn't finish rendering, so flag zTime as negative so that the next time render() is called it'll be forced (to render any remaining children)\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tchild = next;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tchild = this._last;\n\t\t\t\tlet adjustedTime = totalTime < 0 ? totalTime : time; //when the playhead goes backward beyond the start of this timeline, we must pass that information down to the child animations so that zero-duration tweens know whether to render their starting or ending values.\n\t\t\t\twhile (child) {\n\t\t\t\t\tnext = child._prev;\n\t\t\t\t\tif ((child._act || adjustedTime <= child._end) && child._ts && pauseTween !== child) {\n\t\t\t\t\t\tif (child.parent !== this) { // an extreme edge case - the child's render could do something like kill() the \"next\" one in the linked list, or reparent it. In that case we must re-initiate the whole render to be safe.\n\t\t\t\t\t\t\treturn this.render(totalTime, suppressEvents, force);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tchild.render(child._ts > 0 ? (adjustedTime - child._start) * child._ts : (child._dirty ? child.totalDuration() : child._tDur) + (adjustedTime - child._start) * child._ts, suppressEvents, force || (_reverting && (child._initted || child._startAt))); // if reverting, we should always force renders of initted tweens (but remember that .fromTo() or .from() may have a _startAt but not _initted yet). If, for example, a .fromTo() tween with a stagger (which creates an internal timeline) gets reverted BEFORE some of its child tweens render for the first time, it may not properly trigger them to revert.\n\t\t\t\t\t\tif (time !== this._time || (!this._ts && !prevPaused)) { //in case a tween pauses or seeks the timeline when rendering, like inside of an onUpdate/onComplete\n\t\t\t\t\t\t\tpauseTween = 0;\n\t\t\t\t\t\t\tnext && (tTime += (this._zTime = adjustedTime ? -_tinyNum : _tinyNum)); // it didn't finish rendering, so adjust zTime so that so that the next time render() is called it'll be forced (to render any remaining children)\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tchild = next;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (pauseTween && !suppressEvents) {\n\t\t\t\tthis.pause();\n\t\t\t\tpauseTween.render(time >= prevTime ? 0 : -_tinyNum)._zTime = time >= prevTime ? 1 : -1;\n\t\t\t\tif (this._ts) { //the callback resumed playback! So since we may have held back the playhead due to where the pause is positioned, go ahead and jump to where it's SUPPOSED to be (if no pause happened).\n\t\t\t\t\tthis._start = prevStart; //if the pause was at an earlier time and the user resumed in the callback, it could reposition the timeline (changing its startTime), throwing things off slightly, so we make sure the _start doesn't shift.\n\t\t\t\t\t_setEnd(this);\n\t\t\t\t\treturn this.render(totalTime, suppressEvents, force);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis._onUpdate && !suppressEvents && _callback(this, \"onUpdate\", true);\n\t\t\tif ((tTime === tDur && this._tTime >= this.totalDuration()) || (!tTime && prevTime)) if (prevStart === this._start || Math.abs(timeScale) !== Math.abs(this._ts)) if (!this._lock) { // remember, a child's callback may alter this timeline's playhead or timeScale which is why we need to add some of these checks.\n\t\t\t\t(totalTime || !dur) && ((tTime === tDur && this._ts > 0) || (!tTime && this._ts < 0)) && _removeFromParent(this, 1); // don't remove if the timeline is reversed and the playhead isn't at 0, otherwise tl.progress(1).reverse() won't work. Only remove if the playhead is at the end and timeScale is positive, or if the playhead is at 0 and the timeScale is negative.\n\t\t\t\tif (!suppressEvents && !(totalTime < 0 && !prevTime) && (tTime || prevTime || !tDur)) {\n\t\t\t\t\t_callback(this, (tTime === tDur && totalTime >= 0 ? \"onComplete\" : \"onReverseComplete\"), true);\n\t\t\t\t\tthis._prom && !(tTime < tDur && this.timeScale() > 0) && this._prom();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\tadd(child, position) {\n\t\t_isNumber(position) || (position = _parsePosition(this, position, child));\n\t\tif (!(child instanceof Animation)) {\n\t\t\tif (_isArray(child)) {\n\t\t\t\tchild.forEach(obj => this.add(obj, position));\n\t\t\t\treturn this;\n\t\t\t}\n\t\t\tif (_isString(child)) {\n\t\t\t\treturn this.addLabel(child, position);\n\t\t\t}\n\t\t\tif (_isFunction(child)) {\n\t\t\t\tchild = Tween.delayedCall(0, child);\n\t\t\t} else {\n\t\t\t\treturn this;\n\t\t\t}\n\t\t}\n\t\treturn this !== child ? _addToTimeline(this, child, position) : this; //don't allow a timeline to be added to itself as a child!\n\t}\n\n\tgetChildren(nested = true, tweens = true, timelines = true, ignoreBeforeTime = -_bigNum) {\n\t\tlet a = [],\n\t\t\tchild = this._first;\n\t\twhile (child) {\n\t\t\tif (child._start >= ignoreBeforeTime) {\n\t\t\t\tif (child instanceof Tween) {\n\t\t\t\t\ttweens && a.push(child);\n\t\t\t\t} else {\n\t\t\t\t\ttimelines && a.push(child);\n\t\t\t\t\tnested && a.push(...child.getChildren(true, tweens, timelines));\n\t\t\t\t}\n\t\t\t}\n\t\t\tchild = child._next;\n\t\t}\n\t\treturn a;\n\t}\n\n\tgetById(id) {\n\t\tlet animations = this.getChildren(1, 1, 1),\n\t\t\ti = animations.length;\n\t\twhile(i--) {\n\t\t\tif (animations[i].vars.id === id) {\n\t\t\t\treturn animations[i];\n\t\t\t}\n\t\t}\n\t}\n\n\tremove(child) {\n\t\tif (_isString(child)) {\n\t\t\treturn this.removeLabel(child);\n\t\t}\n\t\tif (_isFunction(child)) {\n\t\t\treturn this.killTweensOf(child);\n\t\t}\n\t\tchild.parent === this && _removeLinkedListItem(this, child);\n\t\tif (child === this._recent) {\n\t\t\tthis._recent = this._last;\n\t\t}\n\t\treturn _uncache(this);\n\t}\n\n\ttotalTime(totalTime, suppressEvents) {\n\t\tif (!arguments.length) {\n\t\t\treturn this._tTime;\n\t\t}\n\t\tthis._forcing = 1;\n\t\tif (!this._dp && this._ts) { //special case for the global timeline (or any other that has no parent or detached parent).\n\t\t\tthis._start = _roundPrecise(_ticker.time - (this._ts > 0 ? totalTime / this._ts : (this.totalDuration() - totalTime) / -this._ts));\n\t\t}\n\t\tsuper.totalTime(totalTime, suppressEvents);\n\t\tthis._forcing = 0;\n\t\treturn this;\n\t}\n\n\taddLabel(label, position) {\n\t\tthis.labels[label] = _parsePosition(this, position);\n\t\treturn this;\n\t}\n\n\tremoveLabel(label) {\n\t\tdelete this.labels[label];\n\t\treturn this;\n\t}\n\n\taddPause(position, callback, params) {\n\t\tlet t = Tween.delayedCall(0, callback || _emptyFunc, params);\n\t\tt.data = \"isPause\";\n\t\tthis._hasPause = 1;\n\t\treturn _addToTimeline(this, t, _parsePosition(this, position));\n\t}\n\n\tremovePause(position) {\n\t\tlet child = this._first;\n\t\tposition = _parsePosition(this, position);\n\t\twhile (child) {\n\t\t\tif (child._start === position && child.data === \"isPause\") {\n\t\t\t\t_removeFromParent(child);\n\t\t\t}\n\t\t\tchild = child._next;\n\t\t}\n\t}\n\n\tkillTweensOf(targets, props, onlyActive) {\n\t\tlet tweens = this.getTweensOf(targets, onlyActive),\n\t\t\ti = tweens.length;\n\t\twhile (i--) {\n\t\t\t(_overwritingTween !== tweens[i]) && tweens[i].kill(targets, props);\n\t\t}\n\t\treturn this;\n\t}\n\n\tgetTweensOf(targets, onlyActive) {\n\t\tlet a = [],\n\t\t\tparsedTargets = toArray(targets),\n\t\t\tchild = this._first,\n\t\t\tisGlobalTime = _isNumber(onlyActive), // a number is interpreted as a global time. If the animation spans\n\t\t\tchildren;\n\t\twhile (child) {\n\t\t\tif (child instanceof Tween) {\n\t\t\t\tif (_arrayContainsAny(child._targets, parsedTargets) && (isGlobalTime ? (!_overwritingTween || (child._initted && child._ts)) && child.globalTime(0) <= onlyActive && child.globalTime(child.totalDuration()) > onlyActive : !onlyActive || child.isActive())) { // note: if this is for overwriting, it should only be for tweens that aren't paused and are initted.\n\t\t\t\t\ta.push(child);\n\t\t\t\t}\n\t\t\t} else if ((children = child.getTweensOf(parsedTargets, onlyActive)).length) {\n\t\t\t\ta.push(...children);\n\t\t\t}\n\t\t\tchild = child._next;\n\t\t}\n\t\treturn a;\n\t}\n\n\t// potential future feature - targets() on timelines\n\t// targets() {\n\t// \tlet result = [];\n\t// \tthis.getChildren(true, true, false).forEach(t => result.push(...t.targets()));\n\t// \treturn result.filter((v, i) => result.indexOf(v) === i);\n\t// }\n\n\ttweenTo(position, vars) {\n\t\tvars = vars || {};\n\t\tlet tl = this,\n\t\t\tendTime = _parsePosition(tl, position),\n\t\t\t{ startAt, onStart, onStartParams, immediateRender } = vars,\n\t\t\tinitted,\n\t\t\ttween = Tween.to(tl, _setDefaults({\n\t\t\t\tease: vars.ease || \"none\",\n\t\t\t\tlazy: false,\n\t\t\t\timmediateRender: false,\n\t\t\t\ttime: endTime,\n\t\t\t\toverwrite: \"auto\",\n\t\t\t\tduration: vars.duration || (Math.abs((endTime - ((startAt && \"time\" in startAt) ? startAt.time : tl._time)) / tl.timeScale())) || _tinyNum,\n\t\t\t\tonStart: () => {\n\t\t\t\t\ttl.pause();\n\t\t\t\t\tif (!initted) {\n\t\t\t\t\t\tlet duration = vars.duration || Math.abs((endTime - ((startAt && \"time\" in startAt) ? startAt.time : tl._time)) / tl.timeScale());\n\t\t\t\t\t\t(tween._dur !== duration) && _setDuration(tween, duration, 0, 1).render(tween._time, true, true);\n\t\t\t\t\t\tinitted = 1;\n\t\t\t\t\t}\n\t\t\t\t\tonStart && onStart.apply(tween, onStartParams || []); //in case the user had an onStart in the vars - we don't want to overwrite it.\n\t\t\t\t}\n\t\t\t}, vars));\n\t\treturn immediateRender ? tween.render(0) : tween;\n\t}\n\n\ttweenFromTo(fromPosition, toPosition, vars) {\n\t\treturn this.tweenTo(toPosition, _setDefaults({startAt:{time:_parsePosition(this, fromPosition)}}, vars));\n\t}\n\n\trecent() {\n\t\treturn this._recent;\n\t}\n\n\tnextLabel(afterTime = this._time) {\n\t\treturn _getLabelInDirection(this, _parsePosition(this, afterTime));\n\t}\n\n\tpreviousLabel(beforeTime = this._time) {\n\t\treturn _getLabelInDirection(this, _parsePosition(this, beforeTime), 1);\n\t}\n\n\tcurrentLabel(value) {\n\t\treturn arguments.length ? this.seek(value, true) : this.previousLabel(this._time + _tinyNum);\n\t}\n\n\tshiftChildren(amount, adjustLabels, ignoreBeforeTime = 0) {\n\t\tlet child = this._first,\n\t\t\tlabels = this.labels,\n\t\t\tp;\n\t\twhile (child) {\n\t\t\tif (child._start >= ignoreBeforeTime) {\n\t\t\t\tchild._start += amount;\n\t\t\t\tchild._end += amount;\n\t\t\t}\n\t\t\tchild = child._next;\n\t\t}\n\t\tif (adjustLabels) {\n\t\t\tfor (p in labels) {\n\t\t\t\tif (labels[p] >= ignoreBeforeTime) {\n\t\t\t\t\tlabels[p] += amount;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn _uncache(this);\n\t}\n\n\tinvalidate(soft) {\n\t\tlet child = this._first;\n\t\tthis._lock = 0;\n\t\twhile (child) {\n\t\t\tchild.invalidate(soft);\n\t\t\tchild = child._next;\n\t\t}\n\t\treturn super.invalidate(soft);\n\t}\n\n\tclear(includeLabels = true) {\n\t\tlet child = this._first,\n\t\t\tnext;\n\t\twhile (child) {\n\t\t\tnext = child._next;\n\t\t\tthis.remove(child);\n\t\t\tchild = next;\n\t\t}\n\t\tthis._dp && (this._time = this._tTime = this._pTime = 0);\n\t\tincludeLabels && (this.labels = {});\n\t\treturn _uncache(this);\n\t}\n\n\ttotalDuration(value) {\n\t\tlet max = 0,\n\t\t\tself = this,\n\t\t\tchild = self._last,\n\t\t\tprevStart = _bigNum,\n\t\t\tprev, start, parent;\n\t\tif (arguments.length) {\n\t\t\treturn self.timeScale((self._repeat < 0 ? self.duration() : self.totalDuration()) / (self.reversed() ? -value : value));\n\t\t}\n\t\tif (self._dirty) {\n\t\t\tparent = self.parent;\n\t\t\twhile (child) {\n\t\t\t\tprev = child._prev; //record it here in case the tween changes position in the sequence...\n\t\t\t\tchild._dirty && child.totalDuration(); //could change the tween._startTime, so make sure the animation's cache is clean before analyzing it.\n\t\t\t\tstart = child._start;\n\t\t\t\tif (start > prevStart && self._sort && child._ts && !self._lock) { //in case one of the tweens shifted out of order, it needs to be re-inserted into the correct position in the sequence\n\t\t\t\t\tself._lock = 1; //prevent endless recursive calls - there are methods that get triggered that check duration/totalDuration when we add().\n\t\t\t\t\t_addToTimeline(self, child, start - child._delay, 1)._lock = 0;\n\t\t\t\t} else {\n\t\t\t\t\tprevStart = start;\n\t\t\t\t}\n\t\t\t\tif (start < 0 && child._ts) { //children aren't allowed to have negative startTimes unless smoothChildTiming is true, so adjust here if one is found.\n\t\t\t\t\tmax -= start;\n\t\t\t\t\tif ((!parent && !self._dp) || (parent && parent.smoothChildTiming)) {\n\t\t\t\t\t\tself._start += start / self._ts;\n\t\t\t\t\t\tself._time -= start;\n\t\t\t\t\t\tself._tTime -= start;\n\t\t\t\t\t}\n\t\t\t\t\tself.shiftChildren(-start, false, -1e999);\n\t\t\t\t\tprevStart = 0;\n\t\t\t\t}\n\t\t\t\tchild._end > max && child._ts && (max = child._end);\n\t\t\t\tchild = prev;\n\t\t\t}\n\t\t\t_setDuration(self, (self === _globalTimeline && self._time > max) ? self._time : max, 1, 1);\n\t\t\tself._dirty = 0;\n\t\t}\n\t\treturn self._tDur;\n\t}\n\n\tstatic updateRoot(time) {\n\t\tif (_globalTimeline._ts) {\n\t\t\t_lazySafeRender(_globalTimeline, _parentToChildTotalTime(time, _globalTimeline));\n\t\t\t_lastRenderedFrame = _ticker.frame;\n\t\t}\n\t\tif (_ticker.frame >= _nextGCFrame) {\n\t\t\t_nextGCFrame += _config.autoSleep || 120;\n\t\t\tlet child = _globalTimeline._first;\n\t\t\tif (!child || !child._ts) if (_config.autoSleep && _ticker._listeners.length < 2) {\n\t\t\t\twhile (child && !child._ts) {\n\t\t\t\t\tchild = child._next;\n\t\t\t\t}\n\t\t\t\tchild || _ticker.sleep();\n\t\t\t}\n\t\t}\n\t}\n\n}\n\n_setDefaults(Timeline.prototype, {_lock:0, _hasPause:0, _forcing:0});\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nlet _addComplexStringPropTween = function(target, prop, start, end, setter, stringFilter, funcParam) { //note: we call _addComplexStringPropTween.call(tweenInstance...) to ensure that it's scoped properly. We may call it from within a plugin too, thus \"this\" would refer to the plugin.\n\t\tlet pt = new PropTween(this._pt, target, prop, 0, 1, _renderComplexString, null, setter),\n\t\t\tindex = 0,\n\t\t\tmatchIndex = 0,\n\t\t\tresult,\tstartNums, color, endNum, chunk, startNum, hasRandom, a;\n\t\tpt.b = start;\n\t\tpt.e = end;\n\t\tstart += \"\"; //ensure values are strings\n\t\tend += \"\";\n\t\tif ((hasRandom = ~end.indexOf(\"random(\"))) {\n\t\t\tend = _replaceRandom(end);\n\t\t}\n\t\tif (stringFilter) {\n\t\t\ta = [start, end];\n\t\t\tstringFilter(a, target, prop); //pass an array with the starting and ending values and let the filter do whatever it needs to the values.\n\t\t\tstart = a[0];\n\t\t\tend = a[1];\n\t\t}\n\t\tstartNums = start.match(_complexStringNumExp) || [];\n\t\twhile ((result = _complexStringNumExp.exec(end))) {\n\t\t\tendNum = result[0];\n\t\t\tchunk = end.substring(index, result.index);\n\t\t\tif (color) {\n\t\t\t\tcolor = (color + 1) % 5;\n\t\t\t} else if (chunk.substr(-5) === \"rgba(\") {\n\t\t\t\tcolor = 1;\n\t\t\t}\n\t\t\tif (endNum !== startNums[matchIndex++]) {\n\t\t\t\tstartNum = parseFloat(startNums[matchIndex-1]) || 0;\n\t\t\t\t//these nested PropTweens are handled in a special way - we'll never actually call a render or setter method on them. We'll just loop through them in the parent complex string PropTween's render method.\n\t\t\t\tpt._pt = {\n\t\t\t\t\t_next: pt._pt,\n\t\t\t\t\tp: (chunk || matchIndex === 1) ? chunk : \",\", //note: SVG spec allows omission of comma/space when a negative sign is wedged between two numbers, like 2.5-5.3 instead of 2.5,-5.3 but when tweening, the negative value may switch to positive, so we insert the comma just in case.\n\t\t\t\t\ts: startNum,\n\t\t\t\t\tc: endNum.charAt(1) === \"=\" ? _parseRelative(startNum, endNum) - startNum : parseFloat(endNum) - startNum,\n\t\t\t\t\tm: (color && color < 4) ? Math.round : 0\n\t\t\t\t};\n\t\t\t\tindex = _complexStringNumExp.lastIndex;\n\t\t\t}\n\t\t}\n\t\tpt.c = (index < end.length) ? end.substring(index, end.length) : \"\"; //we use the \"c\" of the PropTween to store the final part of the string (after the last number)\n\t\tpt.fp = funcParam;\n\t\tif (_relExp.test(end) || hasRandom) {\n\t\t\tpt.e = 0; //if the end string contains relative values or dynamic random(...) values, delete the end it so that on the final render we don't actually set it to the string with += or -= characters (forces it to use the calculated value).\n\t\t}\n\t\tthis._pt = pt; //start the linked list with this new PropTween. Remember, we call _addComplexStringPropTween.call(tweenInstance...) to ensure that it's scoped properly. We may call it from within a plugin too, thus \"this\" would refer to the plugin.\n\t\treturn pt;\n\t},\n\t_addPropTween = function(target, prop, start, end, index, targets, modifier, stringFilter, funcParam, optional) {\n\t\t_isFunction(end) && (end = end(index || 0, target, targets));\n\t\tlet currentValue = target[prop],\n\t\t\tparsedStart = (start !== \"get\") ? start : !_isFunction(currentValue) ? currentValue : (funcParam ? target[(prop.indexOf(\"set\") || !_isFunction(target[\"get\" + prop.substr(3)])) ? prop : \"get\" + prop.substr(3)](funcParam) : target[prop]()),\n\t\t\tsetter = !_isFunction(currentValue) ? _setterPlain : funcParam ? _setterFuncWithParam : _setterFunc,\n\t\t\tpt;\n\t\tif (_isString(end)) {\n\t\t\tif (~end.indexOf(\"random(\")) {\n\t\t\t\tend = _replaceRandom(end);\n\t\t\t}\n\t\t\tif (end.charAt(1) === \"=\") {\n\t\t\t\tpt = _parseRelative(parsedStart, end) + (getUnit(parsedStart) || 0);\n\t\t\t\tif (pt || pt === 0) { // to avoid isNaN, like if someone passes in a value like \"!= whatever\"\n\t\t\t\t\tend = pt;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (!optional || parsedStart !== end || _forceAllPropTweens) {\n\t\t\tif (!isNaN(parsedStart * end) && end !== \"\") { // fun fact: any number multiplied by \"\" is evaluated as the number 0!\n\t\t\t\tpt = new PropTween(this._pt, target, prop, +parsedStart || 0, end - (parsedStart || 0), typeof(currentValue) === \"boolean\" ? _renderBoolean : _renderPlain, 0, setter);\n\t\t\t\tfuncParam && (pt.fp = funcParam);\n\t\t\t\tmodifier && pt.modifier(modifier, this, target);\n\t\t\t\treturn (this._pt = pt);\n\t\t\t}\n\t\t\t!currentValue && !(prop in target) && _missingPlugin(prop, end);\n\t\t\treturn _addComplexStringPropTween.call(this, target, prop, parsedStart, end, setter, stringFilter || _config.stringFilter, funcParam);\n\t\t}\n\t},\n\t//creates a copy of the vars object and processes any function-based values (putting the resulting values directly into the copy) as well as strings with \"random()\" in them. It does NOT process relative values.\n\t_processVars = (vars, index, target, targets, tween) => {\n\t\t_isFunction(vars) && (vars = _parseFuncOrString(vars, tween, index, target, targets));\n\t\tif (!_isObject(vars) || (vars.style && vars.nodeType) || _isArray(vars) || _isTypedArray(vars)) {\n\t\t\treturn _isString(vars) ? _parseFuncOrString(vars, tween, index, target, targets) : vars;\n\t\t}\n\t\tlet copy = {},\n\t\t\tp;\n\t\tfor (p in vars) {\n\t\t\tcopy[p] = _parseFuncOrString(vars[p], tween, index, target, targets);\n\t\t}\n\t\treturn copy;\n\t},\n\t_checkPlugin = (property, vars, tween, index, target, targets) => {\n\t\tlet plugin, pt, ptLookup, i;\n\t\tif (_plugins[property] && (plugin = new _plugins[property]()).init(target, plugin.rawVars ? vars[property] : _processVars(vars[property], index, target, targets, tween), tween, index, targets) !== false) {\n\t\t\ttween._pt = pt = new PropTween(tween._pt, target, property, 0, 1, plugin.render, plugin, 0, plugin.priority);\n\t\t\tif (tween !== _quickTween) {\n\t\t\t\tptLookup = tween._ptLookup[tween._targets.indexOf(target)]; //note: we can't use tween._ptLookup[index] because for staggered tweens, the index from the fullTargets array won't match what it is in each individual tween that spawns from the stagger.\n\t\t\t\ti = plugin._props.length;\n\t\t\t\twhile (i--) {\n\t\t\t\t\tptLookup[plugin._props[i]] = pt;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn plugin;\n\t},\n\t_overwritingTween, //store a reference temporarily so we can avoid overwriting itself.\n\t_forceAllPropTweens,\n\t_initTween = (tween, time, tTime) => {\n\t\tlet vars = tween.vars,\n\t\t\t{ ease, startAt, immediateRender, lazy, onUpdate, runBackwards, yoyoEase, keyframes, autoRevert } = vars,\n\t\t\tdur = tween._dur,\n\t\t\tprevStartAt = tween._startAt,\n\t\t\ttargets = tween._targets,\n\t\t\tparent = tween.parent,\n\t\t\t//when a stagger (or function-based duration/delay) is on a Tween instance, we create a nested timeline which means that the \"targets\" of that tween don't reflect the parent. This function allows us to discern when it's a nested tween and in that case, return the full targets array so that function-based values get calculated properly. Also remember that if the tween has a stagger AND keyframes, it could be multiple levels deep which is why we store the targets Array in the vars of the timeline.\n\t\t\tfullTargets = (parent && parent.data === \"nested\") ? parent.vars.targets : targets,\n\t\t\tautoOverwrite = (tween._overwrite === \"auto\") && !_suppressOverwrites,\n\t\t\ttl = tween.timeline,\n\t\t\tcleanVars, i, p, pt, target, hasPriority, gsData, harness, plugin, ptLookup, index, harnessVars, overwritten;\n\t\ttl && (!keyframes || !ease) && (ease = \"none\");\n\t\ttween._ease = _parseEase(ease, _defaults.ease);\n\t\ttween._yEase = yoyoEase ? _invertEase(_parseEase(yoyoEase === true ? ease : yoyoEase, _defaults.ease)) : 0;\n\t\tif (yoyoEase && tween._yoyo && !tween._repeat) { //there must have been a parent timeline with yoyo:true that is currently in its yoyo phase, so flip the eases.\n\t\t\tyoyoEase = tween._yEase;\n\t\t\ttween._yEase = tween._ease;\n\t\t\ttween._ease = yoyoEase;\n\t\t}\n\t\ttween._from = !tl && !!vars.runBackwards; //nested timelines should never run backwards - the backwards-ness is in the child tweens.\n\t\tif (!tl || (keyframes && !vars.stagger)) { //if there's an internal timeline, skip all the parsing because we passed that task down the chain.\n\t\t\tharness = targets[0] ? _getCache(targets[0]).harness : 0;\n\t\t\tharnessVars = harness && vars[harness.prop]; //someone may need to specify CSS-specific values AND non-CSS values, like if the element has an \"x\" property plus it's a standard DOM element. We allow people to distinguish by wrapping plugin-specific stuff in a css:{} object for example.\n\t\t\tcleanVars = _copyExcluding(vars, _reservedProps);\n\t\t\tif (prevStartAt) {\n\t\t\t\tprevStartAt._zTime < 0 && prevStartAt.progress(1); // in case it's a lazy startAt that hasn't rendered yet.\n\t\t\t\t(time < 0 && runBackwards && immediateRender && !autoRevert) ? prevStartAt.render(-1, true) : prevStartAt.revert(runBackwards && dur ? _revertConfigNoKill : _startAtRevertConfig); // if it's a \"startAt\" (not \"from()\" or runBackwards: true), we only need to do a shallow revert (keep transforms cached in CSSPlugin)\n\t\t\t\t// don't just _removeFromParent(prevStartAt.render(-1, true)) because that'll leave inline styles. We're creating a new _startAt for \"startAt\" tweens that re-capture things to ensure that if the pre-tween values changed since the tween was created, they're recorded.\n\t\t\t\tprevStartAt._lazy = 0;\n\t\t\t}\n\t\t\tif (startAt) {\n\t\t\t\t_removeFromParent(tween._startAt = Tween.set(targets, _setDefaults({data: \"isStart\", overwrite: false, parent: parent, immediateRender: true, lazy: !prevStartAt && _isNotFalse(lazy), startAt: null, delay: 0, onUpdate: onUpdate && (() => _callback(tween, \"onUpdate\")), stagger: 0}, startAt))); //copy the properties/values into a new object to avoid collisions, like var to = {x:0}, from = {x:500}; timeline.fromTo(e, from, to).fromTo(e, to, from);\n\t\t\t\ttween._startAt._dp = 0; // don't allow it to get put back into root timeline! Like when revert() is called and totalTime() gets set.\n\t\t\t\ttween._startAt._sat = tween; // used in globalTime(). _sat stands for _startAtTween\n\t\t\t\t(time < 0 && (_reverting || (!immediateRender && !autoRevert))) && tween._startAt.revert(_revertConfigNoKill); // rare edge case, like if a render is forced in the negative direction of a non-initted tween.\n\t\t\t\tif (immediateRender) {\n\t\t\t\t\tif (dur && time <= 0 && tTime <= 0) { // check tTime here because in the case of a yoyo tween whose playhead gets pushed to the end like tween.progress(1), we should allow it through so that the onComplete gets fired properly.\n\t\t\t\t\t\ttime && (tween._zTime = time);\n\t\t\t\t\t\treturn; //we skip initialization here so that overwriting doesn't occur until the tween actually begins. Otherwise, if you create several immediateRender:true tweens of the same target/properties to drop into a Timeline, the last one created would overwrite the first ones because they didn't get placed into the timeline yet before the first render occurs and kicks in overwriting.\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (runBackwards && dur) {\n\t\t\t\t//from() tweens must be handled uniquely: their beginning values must be rendered but we don't want overwriting to occur yet (when time is still 0). Wait until the tween actually begins before doing all the routines like overwriting. At that time, we should render at the END of the tween to ensure that things initialize correctly (remember, from() tweens go backwards)\n\t\t\t\tif (!prevStartAt) {\n\t\t\t\t\ttime && (immediateRender = false); //in rare cases (like if a from() tween runs and then is invalidate()-ed), immediateRender could be true but the initial forced-render gets skipped, so there's no need to force the render in this context when the _time is greater than 0\n\t\t\t\t\tp = _setDefaults({\n\t\t\t\t\t\toverwrite: false,\n\t\t\t\t\t\tdata: \"isFromStart\", //we tag the tween with as \"isFromStart\" so that if [inside a plugin] we need to only do something at the very END of a tween, we have a way of identifying this tween as merely the one that's setting the beginning values for a \"from()\" tween. For example, clearProps in CSSPlugin should only get applied at the very END of a tween and without this tag, from(...{height:100, clearProps:\"height\", delay:1}) would wipe the height at the beginning of the tween and after 1 second, it'd kick back in.\n\t\t\t\t\t\tlazy: immediateRender && !prevStartAt && _isNotFalse(lazy),\n\t\t\t\t\t\timmediateRender: immediateRender, //zero-duration tweens render immediately by default, but if we're not specifically instructed to render this tween immediately, we should skip this and merely _init() to record the starting values (rendering them immediately would push them to completion which is wasteful in that case - we'd have to render(-1) immediately after)\n\t\t\t\t\t\tstagger: 0,\n\t\t\t\t\t\tparent: parent //ensures that nested tweens that had a stagger are handled properly, like gsap.from(\".class\", {y: gsap.utils.wrap([-100,100]), stagger: 0.5})\n\t\t\t\t\t}, cleanVars);\n\t\t\t\t\tharnessVars && (p[harness.prop] = harnessVars); // in case someone does something like .from(..., {css:{}})\n\t\t\t\t\t_removeFromParent(tween._startAt = Tween.set(targets, p));\n\t\t\t\t\ttween._startAt._dp = 0; // don't allow it to get put back into root timeline!\n\t\t\t\t\ttween._startAt._sat = tween; // used in globalTime()\n\t\t\t\t\t(time < 0) && (_reverting ? tween._startAt.revert(_revertConfigNoKill) : tween._startAt.render(-1, true));\n\t\t\t\t\ttween._zTime = time;\n\t\t\t\t\tif (!immediateRender) {\n\t\t\t\t\t\t_initTween(tween._startAt, _tinyNum, _tinyNum); //ensures that the initial values are recorded\n\t\t\t\t\t} else if (!time) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttween._pt = tween._ptCache = 0;\n\t\t\tlazy = (dur && _isNotFalse(lazy)) || (lazy && !dur);\n\t\t\tfor (i = 0; i < targets.length; i++) {\n\t\t\t\ttarget = targets[i];\n\t\t\t\tgsData = target._gsap || _harness(targets)[i]._gsap;\n\t\t\t\ttween._ptLookup[i] = ptLookup = {};\n\t\t\t\t_lazyLookup[gsData.id] && _lazyTweens.length && _lazyRender(); //if other tweens of the same target have recently initted but haven't rendered yet, we've got to force the render so that the starting values are correct (imagine populating a timeline with a bunch of sequential tweens and then jumping to the end)\n\t\t\t\tindex = fullTargets === targets ? i : fullTargets.indexOf(target);\n\t\t\t\tif (harness && (plugin = new harness()).init(target, harnessVars || cleanVars, tween, index, fullTargets) !== false) {\n\t\t\t\t\ttween._pt = pt = new PropTween(tween._pt, target, plugin.name, 0, 1, plugin.render, plugin, 0, plugin.priority);\n\t\t\t\t\tplugin._props.forEach(name => {ptLookup[name] = pt;});\n\t\t\t\t\tplugin.priority && (hasPriority = 1);\n\t\t\t\t}\n\t\t\t\tif (!harness || harnessVars) {\n\t\t\t\t\tfor (p in cleanVars) {\n\t\t\t\t\t\tif (_plugins[p] && (plugin = _checkPlugin(p, cleanVars, tween, index, target, fullTargets))) {\n\t\t\t\t\t\t\tplugin.priority && (hasPriority = 1);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tptLookup[p] = pt = _addPropTween.call(tween, target, p, \"get\", cleanVars[p], index, fullTargets, 0, vars.stringFilter);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ttween._op && tween._op[i] && tween.kill(target, tween._op[i]);\n\t\t\t\tif (autoOverwrite && tween._pt) {\n\t\t\t\t\t_overwritingTween = tween;\n\t\t\t\t\t_globalTimeline.killTweensOf(target, ptLookup, tween.globalTime(time)); // make sure the overwriting doesn't overwrite THIS tween!!!\n\t\t\t\t\toverwritten = !tween.parent;\n\t\t\t\t\t_overwritingTween = 0;\n\t\t\t\t}\n\t\t\t\ttween._pt && lazy && (_lazyLookup[gsData.id] = 1);\n\t\t\t}\n\t\t\thasPriority && _sortPropTweensByPriority(tween);\n\t\t\ttween._onInit && tween._onInit(tween); //plugins like RoundProps must wait until ALL of the PropTweens are instantiated. In the plugin's init() function, it sets the _onInit on the tween instance. May not be pretty/intuitive, but it's fast and keeps file size down.\n\t\t}\n\t\ttween._onUpdate = onUpdate;\n\t\ttween._initted = (!tween._op || tween._pt) && !overwritten; // if overwrittenProps resulted in the entire tween being killed, do NOT flag it as initted or else it may render for one tick.\n\t\t(keyframes && time <= 0) && tl.render(_bigNum, true, true); // if there's a 0% keyframe, it'll render in the \"before\" state for any staggered/delayed animations thus when the following tween initializes, it'll use the \"before\" state instead of the \"after\" state as the initial values.\n\t},\n\t_updatePropTweens = (tween, property, value, start, startIsRelative, ratio, time, skipRecursion) => {\n\t\tlet ptCache = ((tween._pt && tween._ptCache) || (tween._ptCache = {}))[property],\n\t\t\tpt, rootPT, lookup, i;\n\t\tif (!ptCache) {\n\t\t\tptCache = tween._ptCache[property] = [];\n\t\t\tlookup = tween._ptLookup;\n\t\t\ti = tween._targets.length;\n\t\t\twhile (i--) {\n\t\t\t\tpt = lookup[i][property];\n\t\t\t\tif (pt && pt.d && pt.d._pt) { // it's a plugin, so find the nested PropTween\n\t\t\t\t\tpt = pt.d._pt;\n\t\t\t\t\twhile (pt && pt.p !== property && pt.fp !== property) { // \"fp\" is functionParam for things like setting CSS variables which require .setProperty(\"--var-name\", value)\n\t\t\t\t\t\tpt = pt._next;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!pt) { // there is no PropTween associated with that property, so we must FORCE one to be created and ditch out of this\n\t\t\t\t\t// if the tween has other properties that already rendered at new positions, we'd normally have to rewind to put them back like tween.render(0, true) before forcing an _initTween(), but that can create another edge case like tweening a timeline's progress would trigger onUpdates to fire which could move other things around. It's better to just inform users that .resetTo() should ONLY be used for tweens that already have that property. For example, you can't gsap.to(...{ y: 0 }) and then tween.restTo(\"x\", 200) for example.\n\t\t\t\t\t_forceAllPropTweens = 1; // otherwise, when we _addPropTween() and it finds no change between the start and end values, it skips creating a PropTween (for efficiency...why tween when there's no difference?) but in this case we NEED that PropTween created so we can edit it.\n\t\t\t\t\ttween.vars[property] = \"+=0\";\n\t\t\t\t\t_initTween(tween, time);\n\t\t\t\t\t_forceAllPropTweens = 0;\n\t\t\t\t\treturn skipRecursion ? _warn(property + \" not eligible for reset\") : 1; // if someone tries to do a quickTo() on a special property like borderRadius which must get split into 4 different properties, that's not eligible for .resetTo().\n\t\t\t\t}\n\t\t\t\tptCache.push(pt);\n\t\t\t}\n\t\t}\n\t\ti = ptCache.length;\n\t\twhile (i--) {\n\t\t\trootPT = ptCache[i];\n\t\t\tpt = rootPT._pt || rootPT; // complex values may have nested PropTweens. We only accommodate the FIRST value.\n\t\t\tpt.s = (start || start === 0) && !startIsRelative ? start : pt.s + (start || 0) + ratio * pt.c;\n\t\t\tpt.c = value - pt.s;\n\t\t\trootPT.e && (rootPT.e = _round(value) + getUnit(rootPT.e)); // mainly for CSSPlugin (end value)\n\t\t\trootPT.b && (rootPT.b = pt.s + getUnit(rootPT.b)); // (beginning value)\n\t\t}\n\t},\n\t_addAliasesToVars = (targets, vars) => {\n\t\tlet harness = targets[0] ? _getCache(targets[0]).harness : 0,\n\t\t\tpropertyAliases = (harness && harness.aliases),\n\t\t\tcopy, p, i, aliases;\n\t\tif (!propertyAliases) {\n\t\t\treturn vars;\n\t\t}\n\t\tcopy = _merge({}, vars);\n\t\tfor (p in propertyAliases) {\n\t\t\tif (p in copy) {\n\t\t\t\taliases = propertyAliases[p].split(\",\");\n\t\t\t\ti = aliases.length;\n\t\t\t\twhile(i--) {\n\t\t\t\t\tcopy[aliases[i]] = copy[p];\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\treturn copy;\n\t},\n\t// parses multiple formats, like {\"0%\": {x: 100}, {\"50%\": {x: -20}} and { x: {\"0%\": 100, \"50%\": -20} }, and an \"ease\" can be set on any object. We populate an \"allProps\" object with an Array for each property, like {x: [{}, {}], y:[{}, {}]} with data for each property tween. The objects have a \"t\" (time), \"v\", (value), and \"e\" (ease) property. This allows us to piece together a timeline later.\n\t_parseKeyframe = (prop, obj, allProps, easeEach) => {\n\t\tlet ease = obj.ease || easeEach || \"power1.inOut\",\n\t\t\tp, a;\n\t\tif (_isArray(obj)) {\n\t\t\ta = allProps[prop] || (allProps[prop] = []);\n\t\t\t// t = time (out of 100), v = value, e = ease\n\t\t\tobj.forEach((value, i) => a.push({t: i / (obj.length - 1) * 100, v: value, e: ease}));\n\t\t} else {\n\t\t\tfor (p in obj) {\n\t\t\t\ta = allProps[p] || (allProps[p] = []);\n\t\t\t\tp === \"ease\" || a.push({t: parseFloat(prop), v: obj[p], e: ease});\n\t\t\t}\n\t\t}\n\t},\n\t_parseFuncOrString = (value, tween, i, target, targets) => (_isFunction(value) ? value.call(tween, i, target, targets) : (_isString(value) && ~value.indexOf(\"random(\")) ? _replaceRandom(value) : value),\n\t_staggerTweenProps = _callbackNames + \"repeat,repeatDelay,yoyo,repeatRefresh,yoyoEase,autoRevert\",\n\t_staggerPropsToSkip = {};\n_forEachName(_staggerTweenProps + \",id,stagger,delay,duration,paused,scrollTrigger\", name => _staggerPropsToSkip[name] = 1);\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n/*\n * --------------------------------------------------------------------------------------\n * TWEEN\n * --------------------------------------------------------------------------------------\n */\n\nexport class Tween extends Animation {\n\n\tconstructor(targets, vars, position, skipInherit) {\n\t\tif (typeof(vars) === \"number\") {\n\t\t\tposition.duration = vars;\n\t\t\tvars = position;\n\t\t\tposition = null;\n\t\t}\n\t\tsuper(skipInherit ? vars : _inheritDefaults(vars));\n\t\tlet { duration, delay, immediateRender, stagger, overwrite, keyframes, defaults, scrollTrigger, yoyoEase } = this.vars,\n\t\t\tparent = vars.parent || _globalTimeline,\n\t\t\tparsedTargets = (_isArray(targets) || _isTypedArray(targets) ? _isNumber(targets[0]) : (\"length\" in vars)) ? [targets] : toArray(targets), // edge case: someone might try animating the \"length\" of an object with a \"length\" property that's initially set to 0 so don't interpret that as an empty Array-like object.\n\t\t\ttl, i, copy, l, p, curTarget, staggerFunc, staggerVarsToMerge;\n\t\tthis._targets = parsedTargets.length ? _harness(parsedTargets) : _warn(\"GSAP target \" + targets + \" not found. https://gsap.com\", !_config.nullTargetWarn) || [];\n\t\tthis._ptLookup = []; //PropTween lookup. An array containing an object for each target, having keys for each tweening property\n\t\tthis._overwrite = overwrite;\n\t\tif (keyframes || stagger || _isFuncOrString(duration) || _isFuncOrString(delay)) {\n\t\t\tvars = this.vars;\n\t\t\ttl = this.timeline = new Timeline({data: \"nested\", defaults: defaults || {}, targets: parent && parent.data === \"nested\" ? parent.vars.targets : parsedTargets}); // we need to store the targets because for staggers and keyframes, we end up creating an individual tween for each but function-based values need to know the index and the whole Array of targets.\n\t\t\ttl.kill();\n\t\t\ttl.parent = tl._dp = this;\n\t\t\ttl._start = 0;\n\t\t\tif (stagger || _isFuncOrString(duration) || _isFuncOrString(delay)) {\n\t\t\t\tl = parsedTargets.length;\n\t\t\t\tstaggerFunc = stagger && distribute(stagger);\n\t\t\t\tif (_isObject(stagger)) { //users can pass in callbacks like onStart/onComplete in the stagger object. These should fire with each individual tween.\n\t\t\t\t\tfor (p in stagger) {\n\t\t\t\t\t\tif (~_staggerTweenProps.indexOf(p)) {\n\t\t\t\t\t\t\tstaggerVarsToMerge || (staggerVarsToMerge = {});\n\t\t\t\t\t\t\tstaggerVarsToMerge[p] = stagger[p];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (i = 0; i < l; i++) {\n\t\t\t\t\tcopy = _copyExcluding(vars, _staggerPropsToSkip);\n\t\t\t\t\tcopy.stagger = 0;\n\t\t\t\t\tyoyoEase && (copy.yoyoEase = yoyoEase);\n\t\t\t\t\tstaggerVarsToMerge && _merge(copy, staggerVarsToMerge);\n\t\t\t\t\tcurTarget = parsedTargets[i];\n\t\t\t\t\t//don't just copy duration or delay because if they're a string or function, we'd end up in an infinite loop because _isFuncOrString() would evaluate as true in the child tweens, entering this loop, etc. So we parse the value straight from vars and default to 0.\n\t\t\t\t\tcopy.duration = +_parseFuncOrString(duration, this, i, curTarget, parsedTargets);\n\t\t\t\t\tcopy.delay = (+_parseFuncOrString(delay, this, i, curTarget, parsedTargets) || 0) - this._delay;\n\t\t\t\t\tif (!stagger && l === 1 && copy.delay) { // if someone does delay:\"random(1, 5)\", repeat:-1, for example, the delay shouldn't be inside the repeat.\n\t\t\t\t\t\tthis._delay = delay = copy.delay;\n\t\t\t\t\t\tthis._start += delay;\n\t\t\t\t\t\tcopy.delay = 0;\n\t\t\t\t\t}\n\t\t\t\t\ttl.to(curTarget, copy, staggerFunc ? staggerFunc(i, curTarget, parsedTargets) : 0);\n\t\t\t\t\ttl._ease = _easeMap.none;\n\t\t\t\t}\n\t\t\t\ttl.duration() ? (duration = delay = 0) : (this.timeline = 0); // if the timeline's duration is 0, we don't need a timeline internally!\n\t\t\t} else if (keyframes) {\n\t\t\t\t_inheritDefaults(_setDefaults(tl.vars.defaults, {ease:\"none\"}));\n\t\t\t\ttl._ease = _parseEase(keyframes.ease || vars.ease || \"none\");\n\t\t\t\tlet time = 0,\n\t\t\t\t\ta, kf, v;\n\t\t\t\tif (_isArray(keyframes)) {\n\t\t\t\t\tkeyframes.forEach(frame => tl.to(parsedTargets, frame, \">\"));\n\t\t\t\t\ttl.duration(); // to ensure tl._dur is cached because we tap into it for performance purposes in the render() method.\n\t\t\t\t} else {\n\t\t\t\t\tcopy = {};\n\t\t\t\t\tfor (p in keyframes) {\n\t\t\t\t\t\tp === \"ease\" || p === \"easeEach\" || _parseKeyframe(p, keyframes[p], copy, keyframes.easeEach);\n\t\t\t\t\t}\n\t\t\t\t\tfor (p in copy) {\n\t\t\t\t\t\ta = copy[p].sort((a, b) => a.t - b.t);\n\t\t\t\t\t\ttime = 0;\n\t\t\t\t\t\tfor (i = 0; i < a.length; i++) {\n\t\t\t\t\t\t\tkf = a[i];\n\t\t\t\t\t\t\tv = {ease: kf.e, duration: (kf.t - (i ? a[i - 1].t : 0)) / 100 * duration};\n\t\t\t\t\t\t\tv[p] = kf.v;\n\t\t\t\t\t\t\ttl.to(parsedTargets, v, time);\n\t\t\t\t\t\t\ttime += v.duration;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\ttl.duration() < duration && tl.to({}, {duration: duration - tl.duration()}); // in case keyframes didn't go to 100%\n\t\t\t\t}\n\t\t\t}\n\t\t\tduration || this.duration((duration = tl.duration()));\n\n\t\t} else {\n\t\t\tthis.timeline = 0; //speed optimization, faster lookups (no going up the prototype chain)\n\t\t}\n\n\t\tif (overwrite === true && !_suppressOverwrites) {\n\t\t\t_overwritingTween = this;\n\t\t\t_globalTimeline.killTweensOf(parsedTargets);\n\t\t\t_overwritingTween = 0;\n\t\t}\n\t\t_addToTimeline(parent, this, position);\n\t\tvars.reversed && this.reverse();\n\t\tvars.paused && this.paused(true);\n\t\tif (immediateRender || (!duration && !keyframes && this._start === _roundPrecise(parent._time) && _isNotFalse(immediateRender) && _hasNoPausedAncestors(this) && parent.data !== \"nested\")) {\n\t\t\tthis._tTime = -_tinyNum; //forces a render without having to set the render() \"force\" parameter to true because we want to allow lazying by default (using the \"force\" parameter always forces an immediate full render)\n\t\t\tthis.render(Math.max(0, -delay) || 0); //in case delay is negative\n\t\t}\n\t\tscrollTrigger && _scrollTrigger(this, scrollTrigger);\n\t}\n\n\trender(totalTime, suppressEvents, force) {\n\t\tlet prevTime = this._time,\n\t\t\ttDur = this._tDur,\n\t\t\tdur = this._dur,\n\t\t\tisNegative = totalTime < 0,\n\t\t\ttTime = (totalTime > tDur - _tinyNum && !isNegative) ? tDur : (totalTime < _tinyNum) ? 0 : totalTime,\n\t\t\ttime, pt, iteration, cycleDuration, prevIteration, isYoyo, ratio, timeline, yoyoEase;\n\t\tif (!dur) {\n\t\t\t_renderZeroDurationTween(this, totalTime, suppressEvents, force);\n\t\t} else if (tTime !== this._tTime || !totalTime || force || (!this._initted && this._tTime) || (this._startAt && (this._zTime < 0) !== isNegative) || this._lazy) { // this senses if we're crossing over the start time, in which case we must record _zTime and force the render, but we do it in this lengthy conditional way for performance reasons (usually we can skip the calculations): this._initted && (this._zTime < 0) !== (totalTime < 0)\n\t\t\ttime = tTime;\n\t\t\ttimeline = this.timeline;\n\t\t\tif (this._repeat) { //adjust the time for repeats and yoyos\n\t\t\t\tcycleDuration = dur + this._rDelay;\n\t\t\t\tif (this._repeat < -1 && isNegative) {\n\t\t\t\t\treturn this.totalTime(cycleDuration * 100 + totalTime, suppressEvents, force);\n\t\t\t\t}\n\t\t\t\ttime = _roundPrecise(tTime % cycleDuration); //round to avoid floating point errors. (4 % 0.8 should be 0 but some browsers report it as 0.79999999!)\n\t\t\t\tif (tTime === tDur) { // the tDur === tTime is for edge cases where there's a lengthy decimal on the duration and it may reach the very end but the time is rendered as not-quite-there (remember, tDur is rounded to 4 decimals whereas dur isn't)\n\t\t\t\t\titeration = this._repeat;\n\t\t\t\t\ttime = dur;\n\t\t\t\t} else {\n\t\t\t\t\tprevIteration = _roundPrecise(tTime / cycleDuration); // full decimal version of iterations, not the previous iteration (we're reusing prevIteration variable for efficiency)\n\t\t\t\t\titeration = ~~prevIteration;\n\t\t\t\t\tif (iteration && iteration === prevIteration) {\n\t\t\t\t\t\ttime = dur;\n\t\t\t\t\t\titeration--;\n\t\t\t\t\t} else if (time > dur) {\n\t\t\t\t\t\ttime = dur;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tisYoyo = this._yoyo && (iteration & 1);\n\t\t\t\tif (isYoyo) {\n\t\t\t\t\tyoyoEase = this._yEase;\n\t\t\t\t\ttime = dur - time;\n\t\t\t\t}\n\t\t\t\tprevIteration = _animationCycle(this._tTime, cycleDuration);\n\t\t\t\tif (time === prevTime && !force && this._initted && iteration === prevIteration) {\n\t\t\t\t\t//could be during the repeatDelay part. No need to render and fire callbacks.\n\t\t\t\t\tthis._tTime = tTime;\n\t\t\t\t\treturn this;\n\t\t\t\t}\n\t\t\t\tif (iteration !== prevIteration) {\n\t\t\t\t\ttimeline && this._yEase && _propagateYoyoEase(timeline, isYoyo);\n\t\t\t\t\t//repeatRefresh functionality\n\t\t\t\t\tif (this.vars.repeatRefresh && !isYoyo && !this._lock && time !== cycleDuration && this._initted) { // this._time will === cycleDuration when we render at EXACTLY the end of an iteration. Without this condition, it'd often do the repeatRefresh render TWICE (again on the very next tick).\n\t\t\t\t\t\tthis._lock = force = 1; //force, otherwise if lazy is true, the _attemptInitTween() will return and we'll jump out and get caught bouncing on each tick.\n\t\t\t\t\t\tthis.render(_roundPrecise(cycleDuration * iteration), true).invalidate()._lock = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!this._initted) {\n\t\t\t\tif (_attemptInitTween(this, isNegative ? totalTime : time, force, suppressEvents, tTime)) {\n\t\t\t\t\tthis._tTime = 0; // in constructor if immediateRender is true, we set _tTime to -_tinyNum to have the playhead cross the starting point but we can't leave _tTime as a negative number.\n\t\t\t\t\treturn this;\n\t\t\t\t}\n\t\t\t\tif (prevTime !== this._time && !(force && this.vars.repeatRefresh && iteration !== prevIteration)) { // rare edge case - during initialization, an onUpdate in the _startAt (.fromTo()) might force this tween to render at a different spot in which case we should ditch this render() call so that it doesn't revert the values. But we also don't want to dump if we're doing a repeatRefresh render!\n\t\t\t\t\treturn this;\n\t\t\t\t}\n\t\t\t\tif (dur !== this._dur) { // while initting, a plugin like InertiaPlugin might alter the duration, so rerun from the start to ensure everything renders as it should.\n\t\t\t\t\treturn this.render(totalTime, suppressEvents, force);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis._tTime = tTime;\n\t\t\tthis._time = time;\n\n\t\t\tif (!this._act && this._ts) {\n\t\t\t\tthis._act = 1; //as long as it's not paused, force it to be active so that if the user renders independent of the parent timeline, it'll be forced to re-render on the next tick.\n\t\t\t\tthis._lazy = 0;\n\t\t\t}\n\n\t\t\tthis.ratio = ratio = (yoyoEase || this._ease)(time / dur);\n\t\t\tif (this._from) {\n\t\t\t\tthis.ratio = ratio = 1 - ratio;\n\t\t\t}\n\n\t\t\tif (time && !prevTime && !suppressEvents && !iteration) {\n\t\t\t\t_callback(this, \"onStart\");\n\t\t\t\tif (this._tTime !== tTime) { // in case the onStart triggered a render at a different spot, eject. Like if someone did animation.pause(0.5) or something inside the onStart.\n\t\t\t\t\treturn this;\n\t\t\t\t}\n\t\t\t}\n\t\t\tpt = this._pt;\n\t\t\twhile (pt) {\n\t\t\t\tpt.r(ratio, pt.d);\n\t\t\t\tpt = pt._next;\n\t\t\t}\n\t\t\t(timeline && timeline.render(totalTime < 0 ? totalTime : timeline._dur * timeline._ease(time / this._dur), suppressEvents, force)) || (this._startAt && (this._zTime = totalTime));\n\n\t\t\tif (this._onUpdate && !suppressEvents) {\n\t\t\t\tisNegative && _rewindStartAt(this, totalTime, suppressEvents, force); //note: for performance reasons, we tuck this conditional logic inside less traveled areas (most tweens don't have an onUpdate). We'd just have it at the end before the onComplete, but the values should be updated before any onUpdate is called, so we ALSO put it here and then if it's not called, we do so later near the onComplete.\n\t\t\t\t_callback(this, \"onUpdate\");\n\t\t\t}\n\n\t\t\tthis._repeat && iteration !== prevIteration && this.vars.onRepeat && !suppressEvents && this.parent && _callback(this, \"onRepeat\");\n\n\t\t\tif ((tTime === this._tDur || !tTime) && this._tTime === tTime) {\n\t\t\t\tisNegative && !this._onUpdate && _rewindStartAt(this, totalTime, true, true);\n\t\t\t\t(totalTime || !dur) && ((tTime === this._tDur && this._ts > 0) || (!tTime && this._ts < 0)) && _removeFromParent(this, 1); // don't remove if we're rendering at exactly a time of 0, as there could be autoRevert values that should get set on the next tick (if the playhead goes backward beyond the startTime, negative totalTime). Don't remove if the timeline is reversed and the playhead isn't at 0, otherwise tl.progress(1).reverse() won't work. Only remove if the playhead is at the end and timeScale is positive, or if the playhead is at 0 and the timeScale is negative.\n\t\t\t if (!suppressEvents && !(isNegative && !prevTime) && (tTime || prevTime || isYoyo)) { // if prevTime and tTime are zero, we shouldn't fire the onReverseComplete. This could happen if you gsap.to(... {paused:true}).play();\n\t\t\t\t\t_callback(this, (tTime === tDur ? \"onComplete\" : \"onReverseComplete\"), true);\n\t\t\t\t\tthis._prom && !(tTime < tDur && this.timeScale() > 0) && this._prom();\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\treturn this;\n\t}\n\n\ttargets() {\n\t\treturn this._targets;\n\t}\n\n\tinvalidate(soft) { // \"soft\" gives us a way to clear out everything EXCEPT the recorded pre-\"from\" portion of from() tweens. Otherwise, for example, if you tween.progress(1).render(0, true true).invalidate(), the \"from\" values would persist and then on the next render, the from() tweens would initialize and the current value would match the \"from\" values, thus animate from the same value to the same value (no animation). We tap into this in ScrollTrigger's refresh() where we must push a tween to completion and then back again but honor its init state in case the tween is dependent on another tween further up on the page.\n\t\t(!soft || !this.vars.runBackwards) && (this._startAt = 0)\n\t\tthis._pt = this._op = this._onUpdate = this._lazy = this.ratio = 0;\n\t\tthis._ptLookup = [];\n\t\tthis.timeline && this.timeline.invalidate(soft);\n\t\treturn super.invalidate(soft);\n\t}\n\n\tresetTo(property, value, start, startIsRelative, skipRecursion) {\n\t\t_tickerActive || _ticker.wake();\n\t\tthis._ts || this.play();\n\t\tlet time = Math.min(this._dur, (this._dp._time - this._start) * this._ts),\n\t\t\tratio;\n\t\tthis._initted || _initTween(this, time);\n\t\tratio = this._ease(time / this._dur); // don't just get tween.ratio because it may not have rendered yet.\n\t\t// possible future addition to allow an object with multiple values to update, like tween.resetTo({x: 100, y: 200}); At this point, it doesn't seem worth the added kb given the fact that most users will likely opt for the convenient gsap.quickTo() way of interacting with this method.\n\t\t// if (_isObject(property)) { // performance optimization\n\t\t// \tfor (p in property) {\n\t\t// \t\tif (_updatePropTweens(this, p, property[p], value ? value[p] : null, start, ratio, time)) {\n\t\t// \t\t\treturn this.resetTo(property, value, start, startIsRelative); // if a PropTween wasn't found for the property, it'll get forced with a re-initialization so we need to jump out and start over again.\n\t\t// \t\t}\n\t\t// \t}\n\t\t// } else {\n\t\t\tif (_updatePropTweens(this, property, value, start, startIsRelative, ratio, time, skipRecursion)) {\n\t\t\t\treturn this.resetTo(property, value, start, startIsRelative, 1); // if a PropTween wasn't found for the property, it'll get forced with a re-initialization so we need to jump out and start over again.\n\t\t\t}\n\t\t//}\n\t\t_alignPlayhead(this, 0);\n\t\tthis.parent || _addLinkedListItem(this._dp, this, \"_first\", \"_last\", this._dp._sort ? \"_start\" : 0);\n\t\treturn this.render(0);\n\t}\n\n\tkill(targets, vars = \"all\") {\n\t\tif (!targets && (!vars || vars === \"all\")) {\n\t\t\tthis._lazy = this._pt = 0;\n\t\t\tthis.parent ? _interrupt(this) : this.scrollTrigger && this.scrollTrigger.kill(!!_reverting);\n\t\t\treturn this;\n\t\t}\n\t\tif (this.timeline) {\n\t\t\tlet tDur = this.timeline.totalDuration();\n\t\t\tthis.timeline.killTweensOf(targets, vars, _overwritingTween && _overwritingTween.vars.overwrite !== true)._first || _interrupt(this); // if nothing is left tweening, interrupt.\n\t\t\tthis.parent && tDur !== this.timeline.totalDuration() && _setDuration(this, this._dur * this.timeline._tDur / tDur, 0, 1); // if a nested tween is killed that changes the duration, it should affect this tween's duration. We must use the ratio, though, because sometimes the internal timeline is stretched like for keyframes where they don't all add up to whatever the parent tween's duration was set to.\n\t\t\treturn this;\n\t\t}\n\t\tlet parsedTargets = this._targets,\n\t\t\tkillingTargets = targets ? toArray(targets) : parsedTargets,\n\t\t\tpropTweenLookup = this._ptLookup,\n\t\t\tfirstPT = this._pt,\n\t\t\toverwrittenProps, curLookup, curOverwriteProps, props, p, pt, i;\n\t\tif ((!vars || vars === \"all\") && _arraysMatch(parsedTargets, killingTargets)) {\n\t\t\tvars === \"all\" && (this._pt = 0);\n\t\t\treturn _interrupt(this);\n\t\t}\n\t\toverwrittenProps = this._op = this._op || [];\n\t\tif (vars !== \"all\") { //so people can pass in a comma-delimited list of property names\n\t\t\tif (_isString(vars)) {\n\t\t\t\tp = {};\n\t\t\t\t_forEachName(vars, name => p[name] = 1);\n\t\t\t\tvars = p;\n\t\t\t}\n\t\t\tvars = _addAliasesToVars(parsedTargets, vars);\n\t\t}\n\t\ti = parsedTargets.length;\n\t\twhile (i--) {\n\t\t\tif (~killingTargets.indexOf(parsedTargets[i])) {\n\t\t\t\tcurLookup = propTweenLookup[i];\n\t\t\t\tif (vars === \"all\") {\n\t\t\t\t\toverwrittenProps[i] = vars;\n\t\t\t\t\tprops = curLookup;\n\t\t\t\t\tcurOverwriteProps = {};\n\t\t\t\t} else {\n\t\t\t\t\tcurOverwriteProps = overwrittenProps[i] = overwrittenProps[i] || {};\n\t\t\t\t\tprops = vars;\n\t\t\t\t}\n\t\t\t\tfor (p in props) {\n\t\t\t\t\tpt = curLookup && curLookup[p];\n\t\t\t\t\tif (pt) {\n\t\t\t\t\t\tif (!(\"kill\" in pt.d) || pt.d.kill(p) === true) {\n\t\t\t\t\t\t\t_removeLinkedListItem(this, pt, \"_pt\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdelete curLookup[p];\n\t\t\t\t\t}\n\t\t\t\t\tif (curOverwriteProps !== \"all\") {\n\t\t\t\t\t\tcurOverwriteProps[p] = 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis._initted && !this._pt && firstPT && _interrupt(this); //if all tweening properties are killed, kill the tween. Without this line, if there's a tween with multiple targets and then you killTweensOf() each target individually, the tween would technically still remain active and fire its onComplete even though there aren't any more properties tweening.\n\t\treturn this;\n\t}\n\n\n\tstatic to(targets, vars) {\n\t\treturn new Tween(targets, vars, arguments[2]);\n\t}\n\n\tstatic from(targets, vars) {\n\t\treturn _createTweenType(1, arguments);\n\t}\n\n\tstatic delayedCall(delay, callback, params, scope) {\n\t\treturn new Tween(callback, 0, {immediateRender:false, lazy:false, overwrite:false, delay:delay, onComplete:callback, onReverseComplete:callback, onCompleteParams:params, onReverseCompleteParams:params, callbackScope:scope}); // we must use onReverseComplete too for things like timeline.add(() => {...}) which should be triggered in BOTH directions (forward and reverse)\n\t}\n\n\tstatic fromTo(targets, fromVars, toVars) {\n\t\treturn _createTweenType(2, arguments);\n\t}\n\n\tstatic set(targets, vars) {\n\t\tvars.duration = 0;\n\t\tvars.repeatDelay || (vars.repeat = 0);\n\t\treturn new Tween(targets, vars);\n\t}\n\n\tstatic killTweensOf(targets, props, onlyActive) {\n\t\treturn _globalTimeline.killTweensOf(targets, props, onlyActive);\n\t}\n}\n\n_setDefaults(Tween.prototype, {_targets:[], _lazy:0, _startAt:0, _op:0, _onInit:0});\n\n//add the pertinent timeline methods to Tween instances so that users can chain conveniently and create a timeline automatically. (removed due to concerns that it'd ultimately add to more confusion especially for beginners)\n// _forEachName(\"to,from,fromTo,set,call,add,addLabel,addPause\", name => {\n// \tTween.prototype[name] = function() {\n// \t\tlet tl = new Timeline();\n// \t\treturn _addToTimeline(tl, this)[name].apply(tl, toArray(arguments));\n// \t}\n// });\n\n//for backward compatibility. Leverage the timeline calls.\n_forEachName(\"staggerTo,staggerFrom,staggerFromTo\", name => {\n\tTween[name] = function() {\n\t\tlet tl = new Timeline(),\n\t\t\tparams = _slice.call(arguments, 0);\n\t\tparams.splice(name === \"staggerFromTo\" ? 5 : 4, 0, 0);\n\t\treturn tl[name].apply(tl, params);\n\t}\n});\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n/*\n * --------------------------------------------------------------------------------------\n * PROPTWEEN\n * --------------------------------------------------------------------------------------\n */\nlet _setterPlain = (target, property, value) => target[property] = value,\n\t_setterFunc = (target, property, value) => target[property](value),\n\t_setterFuncWithParam = (target, property, value, data) => target[property](data.fp, value),\n\t_setterAttribute = (target, property, value) => target.setAttribute(property, value),\n\t_getSetter = (target, property) => _isFunction(target[property]) ? _setterFunc : _isUndefined(target[property]) && target.setAttribute ? _setterAttribute : _setterPlain,\n\t_renderPlain = (ratio, data) => data.set(data.t, data.p, Math.round((data.s + data.c * ratio) * 1000000) / 1000000, data),\n\t_renderBoolean = (ratio, data) => data.set(data.t, data.p, !!(data.s + data.c * ratio), data),\n\t_renderComplexString = function(ratio, data) {\n\t\tlet pt = data._pt,\n\t\t\ts = \"\";\n\t\tif (!ratio && data.b) { //b = beginning string\n\t\t\ts = data.b;\n\t\t} else if (ratio === 1 && data.e) { //e = ending string\n\t\t\ts = data.e;\n\t\t} else {\n\t\t\twhile (pt) {\n\t\t\t\ts = pt.p + (pt.m ? pt.m(pt.s + pt.c * ratio) : (Math.round((pt.s + pt.c * ratio) * 10000) / 10000)) + s; //we use the \"p\" property for the text inbetween (like a suffix). And in the context of a complex string, the modifier (m) is typically just Math.round(), like for RGB colors.\n\t\t\t\tpt = pt._next;\n\t\t\t}\n\t\t\ts += data.c; //we use the \"c\" of the PropTween to store the final chunk of non-numeric text.\n\t\t}\n\t\tdata.set(data.t, data.p, s, data);\n\t},\n\t_renderPropTweens = function(ratio, data) {\n\t\tlet pt = data._pt;\n\t\twhile (pt) {\n\t\t\tpt.r(ratio, pt.d);\n\t\t\tpt = pt._next;\n\t\t}\n\t},\n\t_addPluginModifier = function(modifier, tween, target, property) {\n\t\tlet pt = this._pt,\n\t\t\tnext;\n\t\twhile (pt) {\n\t\t\tnext = pt._next;\n\t\t\tpt.p === property && pt.modifier(modifier, tween, target);\n\t\t\tpt = next;\n\t\t}\n\t},\n\t_killPropTweensOf = function(property) {\n\t\tlet pt = this._pt,\n\t\t\thasNonDependentRemaining, next;\n\t\twhile (pt) {\n\t\t\tnext = pt._next;\n\t\t\tif ((pt.p === property && !pt.op) || pt.op === property) {\n\t\t\t\t_removeLinkedListItem(this, pt, \"_pt\");\n\t\t\t} else if (!pt.dep) {\n\t\t\t\thasNonDependentRemaining = 1;\n\t\t\t}\n\t\t\tpt = next;\n\t\t}\n\t\treturn !hasNonDependentRemaining;\n\t},\n\t_setterWithModifier = (target, property, value, data) => {\n\t\tdata.mSet(target, property, data.m.call(data.tween, value, data.mt), data);\n\t},\n\t_sortPropTweensByPriority = parent => {\n\t\tlet pt = parent._pt,\n\t\t\tnext, pt2, first, last;\n\t\t//sorts the PropTween linked list in order of priority because some plugins need to do their work after ALL of the PropTweens were created (like RoundPropsPlugin and ModifiersPlugin)\n\t\twhile (pt) {\n\t\t\tnext = pt._next;\n\t\t\tpt2 = first;\n\t\t\twhile (pt2 && pt2.pr > pt.pr) {\n\t\t\t\tpt2 = pt2._next;\n\t\t\t}\n\t\t\tif ((pt._prev = pt2 ? pt2._prev : last)) {\n\t\t\t\tpt._prev._next = pt;\n\t\t\t} else {\n\t\t\t\tfirst = pt;\n\t\t\t}\n\t\t\tif ((pt._next = pt2)) {\n\t\t\t\tpt2._prev = pt;\n\t\t\t} else {\n\t\t\t\tlast = pt;\n\t\t\t}\n\t\t\tpt = next;\n\t\t}\n\t\tparent._pt = first;\n\t};\n\n//PropTween key: t = target, p = prop, r = renderer, d = data, s = start, c = change, op = overwriteProperty (ONLY populated when it's different than p), pr = priority, _next/_prev for the linked list siblings, set = setter, m = modifier, mSet = modifierSetter (the original setter, before a modifier was added)\nexport class PropTween {\n\n\tconstructor(next, target, prop, start, change, renderer, data, setter, priority) {\n\t\tthis.t = target;\n\t\tthis.s = start;\n\t\tthis.c = change;\n\t\tthis.p = prop;\n\t\tthis.r = renderer || _renderPlain;\n\t\tthis.d = data || this;\n\t\tthis.set = setter || _setterPlain;\n\t\tthis.pr = priority || 0;\n\t\tthis._next = next;\n\t\tif (next) {\n\t\t\tnext._prev = this;\n\t\t}\n\t}\n\n\tmodifier(func, tween, target) {\n\t\tthis.mSet = this.mSet || this.set; //in case it was already set (a PropTween can only have one modifier)\n\t\tthis.set = _setterWithModifier;\n\t\tthis.m = func;\n\t\tthis.mt = target; //modifier target\n\t\tthis.tween = tween;\n\t}\n}\n\n\n\n//Initialization tasks\n_forEachName(_callbackNames + \"parent,duration,ease,delay,overwrite,runBackwards,startAt,yoyo,immediateRender,repeat,repeatDelay,data,paused,reversed,lazy,callbackScope,stringFilter,id,yoyoEase,stagger,inherit,repeatRefresh,keyframes,autoRevert,scrollTrigger\", name => _reservedProps[name] = 1);\n_globals.TweenMax = _globals.TweenLite = Tween;\n_globals.TimelineLite = _globals.TimelineMax = Timeline;\n_globalTimeline = new Timeline({sortChildren: false, defaults: _defaults, autoRemoveChildren: true, id:\"root\", smoothChildTiming: true});\n_config.stringFilter = _colorStringFilter;\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nlet _media = [],\n\t_listeners = {},\n\t_emptyArray = [],\n\t_lastMediaTime = 0,\n\t_contextID = 0,\n\t_dispatch = type => (_listeners[type] || _emptyArray).map(f => f()),\n\t_onMediaChange = () => {\n\t\tlet time = Date.now(),\n\t\t\tmatches = [];\n\t\tif (time - _lastMediaTime > 2) {\n\t\t\t_dispatch(\"matchMediaInit\");\n\t\t\t_media.forEach(c => {\n\t\t\t\tlet queries = c.queries,\n\t\t\t\t\tconditions = c.conditions,\n\t\t\t\t\tmatch, p, anyMatch, toggled;\n\t\t\t\tfor (p in queries) {\n\t\t\t\t\tmatch = _win.matchMedia(queries[p]).matches; // Firefox doesn't update the \"matches\" property of the MediaQueryList object correctly - it only does so as it calls its change handler - so we must re-create a media query here to ensure it's accurate.\n\t\t\t\t\tmatch && (anyMatch = 1);\n\t\t\t\t\tif (match !== conditions[p]) {\n\t\t\t\t\t\tconditions[p] = match;\n\t\t\t\t\t\ttoggled = 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (toggled) {\n\t\t\t\t\tc.revert();\n\t\t\t\t\tanyMatch && matches.push(c);\n\t\t\t\t}\n\t\t\t});\n\t\t\t_dispatch(\"matchMediaRevert\");\n\t\t\tmatches.forEach(c => c.onMatch(c, func => c.add(null, func)));\n\t\t\t_lastMediaTime = time;\n\t\t\t_dispatch(\"matchMedia\");\n\t\t}\n\t};\n\nclass Context {\n\tconstructor(func, scope) {\n\t\tthis.selector = scope && selector(scope);\n\t\tthis.data = [];\n\t\tthis._r = []; // returned/cleanup functions\n\t\tthis.isReverted = false;\n\t\tthis.id = _contextID++; // to work around issues that frameworks like Vue cause by making things into Proxies which make it impossible to do something like _media.indexOf(this) because \"this\" would no longer refer to the Context instance itself - it'd refer to a Proxy! We needed a way to identify the context uniquely\n\t\tfunc && this.add(func);\n\t}\n\tadd(name, func, scope) {\n\t\t// possible future addition if we need the ability to add() an animation to a context and for whatever reason cannot create that animation inside of a context.add(() => {...}) function.\n\t\t// if (name && _isFunction(name.revert)) {\n\t\t// \tthis.data.push(name);\n\t\t// \treturn (name._ctx = this);\n\t\t// }\n\t\tif (_isFunction(name)) {\n\t\t\tscope = func;\n\t\t\tfunc = name;\n\t\t\tname = _isFunction;\n\t\t}\n\t\tlet self = this,\n\t\t\tf = function() {\n\t\t\t\tlet prev = _context,\n\t\t\t\t\tprevSelector = self.selector,\n\t\t\t\t\tresult;\n\t\t\t\tprev && prev !== self && prev.data.push(self);\n\t\t\t\tscope && (self.selector = selector(scope));\n\t\t\t\t_context = self;\n\t\t\t\tresult = func.apply(self, arguments);\n\t\t\t\t_isFunction(result) && self._r.push(result);\n\t\t\t\t_context = prev;\n\t\t\t\tself.selector = prevSelector;\n\t\t\t\tself.isReverted = false;\n\t\t\t\treturn result;\n\t\t\t};\n\t\tself.last = f;\n\t\treturn name === _isFunction ? f(self, func => self.add(null, func)) : name ? (self[name] = f) : f;\n\t}\n\tignore(func) {\n\t\tlet prev = _context;\n\t\t_context = null;\n\t\tfunc(this);\n\t\t_context = prev;\n\t}\n\tgetTweens() {\n\t\tlet a = [];\n\t\tthis.data.forEach(e => (e instanceof Context) ? a.push(...e.getTweens()) : (e instanceof Tween) && !(e.parent && e.parent.data === \"nested\") && a.push(e));\n\t\treturn a;\n\t}\n\tclear() {\n\t\tthis._r.length = this.data.length = 0;\n\t}\n\tkill(revert, matchMedia) {\n\t\tif (revert) {\n\t\t\tlet tweens = this.getTweens(),\n\t\t\t\ti = this.data.length,\n\t\t\t\tt;\n\t\t\twhile (i--) { // Flip plugin tweens are very different in that they should actually be pushed to their end. The plugin replaces the timeline's .revert() method to do exactly that. But we also need to remove any of those nested tweens inside the flip timeline so that they don't get individually reverted.\n\t\t\t\tt = this.data[i];\n\t\t\t\tif (t.data === \"isFlip\") {\n\t\t\t\t\tt.revert();\n\t\t\t\t\tt.getChildren(true, true, false).forEach(tween => tweens.splice(tweens.indexOf(tween), 1));\n\t\t\t\t}\n\t\t\t}\n\t\t\t// save as an object so that we can cache the globalTime for each tween to optimize performance during the sort\n\t\t\ttweens.map(t => { return {g: t._dur || t._delay || (t._sat && !t._sat.vars.immediateRender) ? t.globalTime(0) : -Infinity, t}}).sort((a, b) => b.g - a.g || -Infinity).forEach(o => o.t.revert(revert)); // note: all of the _startAt tweens should be reverted in reverse order that they were created, and they'll all have the same globalTime (-1) so the \" || -1\" in the sort keeps the order properly.\n\t\t\ti = this.data.length;\n\t\t\twhile (i--) { // make sure we loop backwards so that, for example, SplitTexts that were created later on the same element get reverted first\n\t\t\t\tt = this.data[i];\n\t\t\t\tif (t instanceof Timeline) {\n\t\t\t\t\tif (t.data !== \"nested\") {\n\t\t\t\t\t\tt.scrollTrigger && t.scrollTrigger.revert();\n\t\t\t\t\t\tt.kill(); // don't revert() the timeline because that's duplicating efforts since we already reverted all the tweens\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t!(t instanceof Tween) && t.revert && t.revert(revert)\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis._r.forEach(f => f(revert, this));\n\t\t\tthis.isReverted = true;\n\t\t} else {\n\t\t\tthis.data.forEach(e => e.kill && e.kill());\n\t\t}\n\t\tthis.clear();\n\t\tif (matchMedia) {\n\t\t\tlet i = _media.length;\n\t\t\twhile (i--) { // previously, we checked _media.indexOf(this), but some frameworks like Vue enforce Proxy objects that make it impossible to get the proper result that way, so we must use a unique ID number instead.\n\t\t\t\t_media[i].id === this.id && _media.splice(i, 1);\n\t\t\t}\n\t\t}\n\t}\n\n\t// killWithCleanup() {\n\t// \tthis.kill();\n\t// \tthis._r.forEach(f => f(false, this));\n\t// }\n\n\trevert(config) {\n\t\tthis.kill(config || {});\n\t}\n}\n\n\n\n\nclass MatchMedia {\n\tconstructor(scope) {\n\t\tthis.contexts = [];\n\t\tthis.scope = scope;\n\t\t_context && _context.data.push(this);\n\t}\n\tadd(conditions, func, scope) {\n\t\t_isObject(conditions) || (conditions = {matches: conditions});\n\t\tlet context = new Context(0, scope || this.scope),\n\t\t\tcond = context.conditions = {},\n\t\t\tmq, p, active;\n\t\t_context && !context.selector && (context.selector = _context.selector); // in case a context is created inside a context. Like a gsap.matchMedia() that's inside a scoped gsap.context()\n\t\tthis.contexts.push(context);\n\t\tfunc = context.add(\"onMatch\", func);\n\t\tcontext.queries = conditions;\n\t\tfor (p in conditions) {\n\t\t\tif (p === \"all\") {\n\t\t\t\tactive = 1;\n\t\t\t} else {\n\t\t\t\tmq = _win.matchMedia(conditions[p]);\n\t\t\t\tif (mq) {\n\t\t\t\t\t_media.indexOf(context) < 0 && _media.push(context);\n\t\t\t\t\t(cond[p] = mq.matches) && (active = 1);\n\t\t\t\t\tmq.addListener ? mq.addListener(_onMediaChange) : mq.addEventListener(\"change\", _onMediaChange);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tactive && func(context, f => context.add(null, f));\n\t\treturn this;\n\t}\n\t// refresh() {\n\t// \tlet time = _lastMediaTime,\n\t// \t\tmedia = _media;\n\t// \t_lastMediaTime = -1;\n\t// \t_media = this.contexts;\n\t// \t_onMediaChange();\n\t// \t_lastMediaTime = time;\n\t// \t_media = media;\n\t// }\n\trevert(config) {\n\t\tthis.kill(config || {});\n\t}\n\tkill(revert) {\n\t\tthis.contexts.forEach(c => c.kill(revert, true));\n\t}\n}\n\n\n\n/*\n * --------------------------------------------------------------------------------------\n * GSAP\n * --------------------------------------------------------------------------------------\n */\nconst _gsap = {\n\tregisterPlugin(...args) {\n\t\targs.forEach(config => _createPlugin(config));\n\t},\n\ttimeline(vars) {\n\t\treturn new Timeline(vars);\n\t},\n\tgetTweensOf(targets, onlyActive) {\n\t\treturn _globalTimeline.getTweensOf(targets, onlyActive);\n\t},\n\tgetProperty(target, property, unit, uncache) {\n\t\t_isString(target) && (target = toArray(target)[0]); //in case selector text or an array is passed in\n\t\tlet getter = _getCache(target || {}).get,\n\t\t\tformat = unit ? _passThrough : _numericIfPossible;\n\t\tunit === \"native\" && (unit = \"\");\n\t\treturn !target ? target : !property ? (property, unit, uncache) => format(((_plugins[property] && _plugins[property].get) || getter)(target, property, unit, uncache)) : format(((_plugins[property] && _plugins[property].get) || getter)(target, property, unit, uncache));\n\t},\n\tquickSetter(target, property, unit) {\n\t\ttarget = toArray(target);\n\t\tif (target.length > 1) {\n\t\t\tlet setters = target.map(t => gsap.quickSetter(t, property, unit)),\n\t\t\t\tl = setters.length;\n\t\t\treturn value => {\n\t\t\t\tlet i = l;\n\t\t\t\twhile(i--) {\n\t\t\t\t\tsetters[i](value);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\ttarget = target[0] || {};\n\t\tlet Plugin = _plugins[property],\n\t\t\tcache = _getCache(target),\n\t\t\tp = (cache.harness && (cache.harness.aliases || {})[property]) || property, // in case it's an alias, like \"rotate\" for \"rotation\".\n\t\t\tsetter = Plugin ? value => {\n\t\t\t\tlet p = new Plugin();\n\t\t\t\t_quickTween._pt = 0;\n\t\t\t\tp.init(target, unit ? value + unit : value, _quickTween, 0, [target]);\n\t\t\t\tp.render(1, p);\n\t\t\t\t_quickTween._pt && _renderPropTweens(1, _quickTween);\n\t\t\t} : cache.set(target, p);\n\t\treturn Plugin ? setter : value => setter(target, p, unit ? value + unit : value, cache, 1);\n\t},\n\tquickTo(target, property, vars) {\n\t\tlet tween = gsap.to(target, _setDefaults({[property]: \"+=0.1\", paused: true, stagger: 0}, vars || {})),\n\t\t\tfunc = (value, start, startIsRelative) => tween.resetTo(property, value, start, startIsRelative);\n\t\tfunc.tween = tween;\n\t\treturn func;\n\t},\n\tisTweening(targets) {\n\t\treturn _globalTimeline.getTweensOf(targets, true).length > 0;\n\t},\n\tdefaults(value) {\n\t\tvalue && value.ease && (value.ease = _parseEase(value.ease, _defaults.ease));\n\t\treturn _mergeDeep(_defaults, value || {});\n\t},\n\tconfig(value) {\n\t\treturn _mergeDeep(_config, value || {});\n\t},\n\tregisterEffect({name, effect, plugins, defaults, extendTimeline}) {\n\t\t(plugins || \"\").split(\",\").forEach(pluginName => pluginName && !_plugins[pluginName] && !_globals[pluginName] && _warn(name + \" effect requires \" + pluginName + \" plugin.\"));\n\t\t_effects[name] = (targets, vars, tl) => effect(toArray(targets), _setDefaults(vars || {}, defaults), tl);\n\t\tif (extendTimeline) {\n\t\t\tTimeline.prototype[name] = function(targets, vars, position) {\n\t\t\t\treturn this.add(_effects[name](targets, _isObject(vars) ? vars : (position = vars) && {}, this), position);\n\t\t\t};\n\t\t}\n\t},\n\tregisterEase(name, ease) {\n\t\t_easeMap[name] = _parseEase(ease);\n\t},\n\tparseEase(ease, defaultEase) {\n\t\treturn arguments.length ? _parseEase(ease, defaultEase) : _easeMap;\n\t},\n\tgetById(id) {\n\t\treturn _globalTimeline.getById(id);\n\t},\n\texportRoot(vars = {}, includeDelayedCalls) {\n\t\tlet tl = new Timeline(vars),\n\t\t\tchild, next;\n\t\ttl.smoothChildTiming = _isNotFalse(vars.smoothChildTiming);\n\t\t_globalTimeline.remove(tl);\n\t\ttl._dp = 0; //otherwise it'll get re-activated when adding children and be re-introduced into _globalTimeline's linked list (then added to itself).\n\t\ttl._time = tl._tTime = _globalTimeline._time;\n\t\tchild = _globalTimeline._first;\n\t\twhile (child) {\n\t\t\tnext = child._next;\n\t\t\tif (includeDelayedCalls || !(!child._dur && child instanceof Tween && child.vars.onComplete === child._targets[0])) {\n\t\t\t\t_addToTimeline(tl, child, child._start - child._delay);\n\t\t\t}\n\t\t\tchild = next;\n\t\t}\n\t\t_addToTimeline(_globalTimeline, tl, 0);\n\t\treturn tl;\n\t},\n\tcontext: (func, scope) => func ? new Context(func, scope) : _context,\n\tmatchMedia: scope => new MatchMedia(scope),\n\tmatchMediaRefresh: () => _media.forEach(c => {\n\t\tlet cond = c.conditions,\n\t\t\tfound, p;\n\t\tfor (p in cond) {\n\t\t\tif (cond[p]) {\n\t\t\t\tcond[p] = false;\n\t\t\t\tfound = 1;\n\t\t\t}\n\t\t}\n\t\tfound && c.revert();\n\t}) || _onMediaChange(),\n\taddEventListener(type, callback) {\n\t\tlet a = _listeners[type] || (_listeners[type] = []);\n\t\t~a.indexOf(callback) || a.push(callback);\n\t},\n\tremoveEventListener(type, callback) {\n\t\tlet a = _listeners[type],\n\t\t\ti = a && a.indexOf(callback);\n\t\ti >= 0 && a.splice(i, 1);\n\t},\n\tutils: { wrap, wrapYoyo, distribute, random, snap, normalize, getUnit, clamp, splitColor, toArray, selector, mapRange, pipe, unitize, interpolate, shuffle },\n\tinstall: _install,\n\teffects: _effects,\n\tticker: _ticker,\n\tupdateRoot: Timeline.updateRoot,\n\tplugins: _plugins,\n\tglobalTimeline: _globalTimeline,\n\tcore: {PropTween, globals: _addGlobal, Tween, Timeline, Animation, getCache: _getCache, _removeLinkedListItem, reverting: () => _reverting, context: toAdd => {if (toAdd && _context) { _context.data.push(toAdd); toAdd._ctx = _context} return _context; }, suppressOverwrites: value => _suppressOverwrites = value}\n};\n\n_forEachName(\"to,from,fromTo,delayedCall,set,killTweensOf\", name => _gsap[name] = Tween[name]);\n_ticker.add(Timeline.updateRoot);\n_quickTween = _gsap.to({}, {duration:0});\n\n\n\n\n// ---- EXTRA PLUGINS --------------------------------------------------------\n\n\nlet _getPluginPropTween = (plugin, prop) => {\n\t\tlet pt = plugin._pt;\n\t\twhile (pt && pt.p !== prop && pt.op !== prop && pt.fp !== prop) {\n\t\t\tpt = pt._next;\n\t\t}\n\t\treturn pt;\n\t},\n\t_addModifiers = (tween, modifiers) => {\n\t\t\tlet\ttargets = tween._targets,\n\t\t\t\tp, i, pt;\n\t\t\tfor (p in modifiers) {\n\t\t\t\ti = targets.length;\n\t\t\t\twhile (i--) {\n\t\t\t\t\tpt = tween._ptLookup[i][p];\n\t\t\t\t\tif (pt && (pt = pt.d)) {\n\t\t\t\t\t\tif (pt._pt) { // is a plugin\n\t\t\t\t\t\t\tpt = _getPluginPropTween(pt, p);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpt && pt.modifier && pt.modifier(modifiers[p], tween, targets[i], p);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t},\n\t_buildModifierPlugin = (name, modifier) => {\n\t\treturn {\n\t\t\tname: name,\n\t\t\trawVars: 1, //don't pre-process function-based values or \"random()\" strings.\n\t\t\tinit(target, vars, tween) {\n\t\t\t\ttween._onInit = tween => {\n\t\t\t\t\tlet temp, p;\n\t\t\t\t\tif (_isString(vars)) {\n\t\t\t\t\t\ttemp = {};\n\t\t\t\t\t\t_forEachName(vars, name => temp[name] = 1); //if the user passes in a comma-delimited list of property names to roundProps, like \"x,y\", we round to whole numbers.\n\t\t\t\t\t\tvars = temp;\n\t\t\t\t\t}\n\t\t\t\t\tif (modifier) {\n\t\t\t\t\t\ttemp = {};\n\t\t\t\t\t\tfor (p in vars) {\n\t\t\t\t\t\t\ttemp[p] = modifier(vars[p]);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvars = temp;\n\t\t\t\t\t}\n\t\t\t\t\t_addModifiers(tween, vars);\n\t\t\t\t};\n\t\t\t}\n\t\t};\n\t};\n\n//register core plugins\nexport const gsap = _gsap.registerPlugin({\n\t\tname:\"attr\",\n\t\tinit(target, vars, tween, index, targets) {\n\t\t\tlet p, pt, v;\n\t\t\tthis.tween = tween;\n\t\t\tfor (p in vars) {\n\t\t\t\tv = target.getAttribute(p) || \"\";\n\t\t\t\tpt = this.add(target, \"setAttribute\", (v || 0) + \"\", vars[p], index, targets, 0, 0, p);\n\t\t\t\tpt.op = p;\n\t\t\t\tpt.b = v; // record the beginning value so we can revert()\n\t\t\t\tthis._props.push(p);\n\t\t\t}\n\t\t},\n\t\trender(ratio, data) {\n\t\t\tlet pt = data._pt;\n\t\t\twhile (pt) {\n\t\t\t\t_reverting ? pt.set(pt.t, pt.p, pt.b, pt) : pt.r(ratio, pt.d); // if reverting, go back to the original (pt.b)\n\t\t\t\tpt = pt._next;\n\t\t\t}\n\t\t}\n\t}, {\n\t\tname:\"endArray\",\n\t\tinit(target, value) {\n\t\t\tlet i = value.length;\n\t\t\twhile (i--) {\n\t\t\t\tthis.add(target, i, target[i] || 0, value[i], 0, 0, 0, 0, 0, 1);\n\t\t\t}\n\t\t}\n\t},\n\t_buildModifierPlugin(\"roundProps\", _roundModifier),\n\t_buildModifierPlugin(\"modifiers\"),\n\t_buildModifierPlugin(\"snap\", snap)\n) || _gsap; //to prevent the core plugins from being dropped via aggressive tree shaking, we must include them in the variable declaration in this way.\n\nTween.version = Timeline.version = gsap.version = \"3.12.7\";\n_coreReady = 1;\n_windowExists() && _wake();\n\nexport const { Power0, Power1, Power2, Power3, Power4, Linear, Quad, Cubic, Quart, Quint, Strong, Elastic, Back, SteppedEase, Bounce, Sine, Expo, Circ } = _easeMap;\nexport { Tween as TweenMax, Tween as TweenLite, Timeline as TimelineMax, Timeline as TimelineLite, gsap as default, wrap, wrapYoyo, distribute, random, snap, normalize, getUnit, clamp, splitColor, toArray, selector, mapRange, pipe, unitize, interpolate, shuffle };\n//export some internal methods/orojects for use in CSSPlugin so that we can externalize that file and allow custom builds that exclude it.\nexport { _getProperty, _numExp, _numWithUnitExp, _isString, _isUndefined, _renderComplexString, _relExp, _setDefaults, _removeLinkedListItem, _forEachName, _sortPropTweensByPriority, _colorStringFilter, _replaceRandom, _checkPlugin, _plugins, _ticker, _config, _roundModifier, _round, _missingPlugin, _getSetter, _getCache, _colorExp, _parseRelative }","/*!\n * CSSPlugin 3.12.7\n * https://gsap.com\n *\n * Copyright 2008-2025, GreenSock. All rights reserved.\n * Subject to the terms at https://gsap.com/standard-license or for\n * Club GSAP members, the agreement issued with that membership.\n * @author: Jack Doyle, jack@greensock.com\n*/\n/* eslint-disable */\n\nimport {gsap, _getProperty, _numExp, _numWithUnitExp, getUnit, _isString, _isUndefined, _renderComplexString, _relExp, _forEachName, _sortPropTweensByPriority, _colorStringFilter, _checkPlugin, _replaceRandom, _plugins, GSCache, PropTween, _config, _ticker, _round, _missingPlugin, _getSetter, _getCache, _colorExp, _parseRelative,\n\t_setDefaults, _removeLinkedListItem //for the commented-out className feature.\n} from \"./gsap-core.js\";\n\nlet _win, _doc, _docElement, _pluginInitted, _tempDiv, _tempDivStyler, _recentSetterPlugin, _reverting,\n\t_windowExists = () => typeof(window) !== \"undefined\",\n\t_transformProps = {},\n\t_RAD2DEG = 180 / Math.PI,\n\t_DEG2RAD = Math.PI / 180,\n\t_atan2 = Math.atan2,\n\t_bigNum = 1e8,\n\t_capsExp = /([A-Z])/g,\n\t_horizontalExp = /(left|right|width|margin|padding|x)/i,\n\t_complexExp = /[\\s,\\(]\\S/,\n\t_propertyAliases = {autoAlpha:\"opacity,visibility\", scale:\"scaleX,scaleY\", alpha:\"opacity\"},\n\t_renderCSSProp = (ratio, data) => data.set(data.t, data.p, (Math.round((data.s + data.c * ratio) * 10000) / 10000) + data.u, data),\n\t_renderPropWithEnd = (ratio, data) => data.set(data.t, data.p, ratio === 1 ? data.e : (Math.round((data.s + data.c * ratio) * 10000) / 10000) + data.u, data),\n\t_renderCSSPropWithBeginning = (ratio, data) => data.set(data.t, data.p, ratio ? (Math.round((data.s + data.c * ratio) * 10000) / 10000) + data.u : data.b, data), //if units change, we need a way to render the original unit/value when the tween goes all the way back to the beginning (ratio:0)\n\t_renderRoundedCSSProp = (ratio, data) => {\n\t\tlet value = data.s + data.c * ratio;\n\t\tdata.set(data.t, data.p, ~~(value + (value < 0 ? -.5 : .5)) + data.u, data);\n\t},\n\t_renderNonTweeningValue = (ratio, data) => data.set(data.t, data.p, ratio ? data.e : data.b, data),\n\t_renderNonTweeningValueOnlyAtEnd = (ratio, data) => data.set(data.t, data.p, ratio !== 1 ? data.b : data.e, data),\n\t_setterCSSStyle = (target, property, value) => target.style[property] = value,\n\t_setterCSSProp = (target, property, value) => target.style.setProperty(property, value),\n\t_setterTransform = (target, property, value) => target._gsap[property] = value,\n\t_setterScale = (target, property, value) => target._gsap.scaleX = target._gsap.scaleY = value,\n\t_setterScaleWithRender = (target, property, value, data, ratio) => {\n\t\tlet cache = target._gsap;\n\t\tcache.scaleX = cache.scaleY = value;\n\t\tcache.renderTransform(ratio, cache);\n\t},\n\t_setterTransformWithRender = (target, property, value, data, ratio) => {\n\t\tlet cache = target._gsap;\n\t\tcache[property] = value;\n\t\tcache.renderTransform(ratio, cache);\n\t},\n\t_transformProp = \"transform\",\n\t_transformOriginProp = _transformProp + \"Origin\",\n\t_saveStyle = function(property, isNotCSS) {\n\t\tlet target = this.target,\n\t\t\tstyle = target.style,\n\t\t\tcache = target._gsap;\n\t\tif ((property in _transformProps) && style) {\n\t\t\tthis.tfm = this.tfm || {};\n\t\t\tif (property !== \"transform\") {\n\t\t\t\tproperty = _propertyAliases[property] || property;\n\t\t\t\t~property.indexOf(\",\") ? property.split(\",\").forEach(a => this.tfm[a] = _get(target, a)) : (this.tfm[property] = cache.x ? cache[property] : _get(target, property)); // note: scale would map to \"scaleX,scaleY\", thus we loop and apply them both.\n\t\t\t\tproperty === _transformOriginProp && (this.tfm.zOrigin = cache.zOrigin);\n\t\t\t} else {\n\t\t\t\treturn _propertyAliases.transform.split(\",\").forEach(p => _saveStyle.call(this, p, isNotCSS));\n\t\t\t}\n\t\t\tif (this.props.indexOf(_transformProp) >= 0) { return; }\n\t\t\tif (cache.svg) {\n\t\t\t\tthis.svgo = target.getAttribute(\"data-svg-origin\");\n\t\t\t\tthis.props.push(_transformOriginProp, isNotCSS, \"\");\n\t\t\t}\n\t\t\tproperty = _transformProp;\n\t\t}\n\t\t(style || isNotCSS) && this.props.push(property, isNotCSS, style[property]);\n\t},\n\t_removeIndependentTransforms = style => {\n\t\tif (style.translate) {\n\t\t\tstyle.removeProperty(\"translate\");\n\t\t\tstyle.removeProperty(\"scale\");\n\t\t\tstyle.removeProperty(\"rotate\");\n\t\t}\n\t},\n\t_revertStyle = function() {\n\t\tlet props = this.props,\n\t\t\ttarget = this.target,\n\t\t\tstyle = target.style,\n\t\t\tcache = target._gsap,\n\t\t\ti, p;\n\t\tfor (i = 0; i < props.length; i+=3) { // stored like this: property, isNotCSS, value\n\t\t\tif (!props[i+1]) {\n\t\t\t\tprops[i+2] ? (style[props[i]] = props[i+2]) : style.removeProperty(props[i].substr(0,2) === \"--\" ? props[i] : props[i].replace(_capsExp, \"-$1\").toLowerCase());\n\t\t\t} else if (props[i+1] === 2) { // non-CSS value (function-based)\n\t\t\t\ttarget[props[i]](props[i+2]);\n\t\t\t} else { // non-CSS value (not function-based)\n\t\t\t\ttarget[props[i]] = props[i+2];\n\t\t\t}\n\t\t}\n\t\tif (this.tfm) {\n\t\t\tfor (p in this.tfm) {\n\t\t\t\tcache[p] = this.tfm[p];\n\t\t\t}\n\t\t\tif (cache.svg) {\n\t\t\t\tcache.renderTransform();\n\t\t\t\ttarget.setAttribute(\"data-svg-origin\", this.svgo || \"\");\n\t\t\t}\n\t\t\ti = _reverting();\n\t\t\tif ((!i || !i.isStart) && !style[_transformProp]) {\n\t\t\t\t_removeIndependentTransforms(style);\n\t\t\t\tif (cache.zOrigin && style[_transformOriginProp]) {\n\t\t\t\t\tstyle[_transformOriginProp] += \" \" + cache.zOrigin + \"px\"; // since we're uncaching, we must put the zOrigin back into the transformOrigin so that we can pull it out accurately when we parse again. Otherwise, we'd lose the z portion of the origin since we extract it to protect from Safari bugs.\n\t\t\t\t\tcache.zOrigin = 0;\n\t\t\t\t\tcache.renderTransform();\n\t\t\t\t}\n\t\t\t\tcache.uncache = 1; // if it's a startAt that's being reverted in the _initTween() of the core, we don't need to uncache transforms. This is purely a performance optimization.\n\t\t\t}\n\t\t}\n\t},\n\t_getStyleSaver = (target, properties) => {\n\t\tlet saver = {\n\t\t\ttarget,\n\t\t\tprops: [],\n\t\t\trevert: _revertStyle,\n\t\t\tsave: _saveStyle\n\t\t};\n\t\ttarget._gsap || gsap.core.getCache(target); // just make sure there's a _gsap cache defined because we read from it in _saveStyle() and it's more efficient to just check it here once.\n\t\tproperties && target.style && target.nodeType && properties.split(\",\").forEach(p => saver.save(p)); // make sure it's a DOM node too.\n\t\treturn saver;\n\t},\n\t_supports3D,\n\t_createElement = (type, ns) => {\n\t\tlet e = _doc.createElementNS ? _doc.createElementNS((ns || \"http://www.w3.org/1999/xhtml\").replace(/^https/, \"http\"), type) : _doc.createElement(type); //some servers swap in https for http in the namespace which can break things, making \"style\" inaccessible.\n\t\treturn e && e.style ? e : _doc.createElement(type); //some environments won't allow access to the element's style when created with a namespace in which case we default to the standard createElement() to work around the issue. Also note that when GSAP is embedded directly inside an SVG file, createElement() won't allow access to the style object in Firefox (see https://gsap.com/forums/topic/20215-problem-using-tweenmax-in-standalone-self-containing-svg-file-err-cannot-set-property-csstext-of-undefined/).\n\t},\n\t_getComputedProperty = (target, property, skipPrefixFallback) => {\n\t\tlet cs = getComputedStyle(target);\n\t\treturn cs[property] || cs.getPropertyValue(property.replace(_capsExp, \"-$1\").toLowerCase()) || cs.getPropertyValue(property) || (!skipPrefixFallback && _getComputedProperty(target, _checkPropPrefix(property) || property, 1)) || \"\"; //css variables may not need caps swapped out for dashes and lowercase.\n\t},\n\t_prefixes = \"O,Moz,ms,Ms,Webkit\".split(\",\"),\n\t_checkPropPrefix = (property, element, preferPrefix) => {\n\t\tlet e = element || _tempDiv,\n\t\t\ts = e.style,\n\t\t\ti = 5;\n\t\tif (property in s && !preferPrefix) {\n\t\t\treturn property;\n\t\t}\n\t\tproperty = property.charAt(0).toUpperCase() + property.substr(1);\n\t\twhile (i-- && !((_prefixes[i]+property) in s)) { }\n\t\treturn (i < 0) ? null : ((i === 3) ? \"ms\" : (i >= 0) ? _prefixes[i] : \"\") + property;\n\t},\n\t_initCore = () => {\n\t\tif (_windowExists() && window.document) {\n\t\t\t_win = window;\n\t\t\t_doc = _win.document;\n\t\t\t_docElement = _doc.documentElement;\n\t\t\t_tempDiv = _createElement(\"div\") || {style:{}};\n\t\t\t_tempDivStyler = _createElement(\"div\");\n\t\t\t_transformProp = _checkPropPrefix(_transformProp);\n\t\t\t_transformOriginProp = _transformProp + \"Origin\";\n\t\t\t_tempDiv.style.cssText = \"border-width:0;line-height:0;position:absolute;padding:0\"; //make sure to override certain properties that may contaminate measurements, in case the user has overreaching style sheets.\n\t\t\t_supports3D = !!_checkPropPrefix(\"perspective\");\n\t\t\t_reverting = gsap.core.reverting;\n\t\t\t_pluginInitted = 1;\n\t\t}\n\t},\n\t_getReparentedCloneBBox = target => { //works around issues in some browsers (like Firefox) that don't correctly report getBBox() on SVG elements inside a element and/or . We try creating an SVG, adding it to the documentElement and toss the element in there so that it's definitely part of the rendering tree, then grab the bbox and if it works, we actually swap out the original getBBox() method for our own that does these extra steps whenever getBBox is needed. This helps ensure that performance is optimal (only do all these extra steps when absolutely necessary...most elements don't need it).\n\t\tlet owner = target.ownerSVGElement,\n\t\t\tsvg = _createElement(\"svg\", (owner && owner.getAttribute(\"xmlns\")) || \"http://www.w3.org/2000/svg\"),\n\t\t\tclone = target.cloneNode(true),\n\t\t\tbbox;\n\t\tclone.style.display = \"block\";\n\t\tsvg.appendChild(clone);\n\t\t_docElement.appendChild(svg);\n\t\ttry {\n\t\t\tbbox = clone.getBBox();\n\t\t} catch (e) { }\n\t\tsvg.removeChild(clone);\n\t\t_docElement.removeChild(svg);\n\t\treturn bbox;\n\t},\n\t_getAttributeFallbacks = (target, attributesArray) => {\n\t\tlet i = attributesArray.length;\n\t\twhile (i--) {\n\t\t\tif (target.hasAttribute(attributesArray[i])) {\n\t\t\t\treturn target.getAttribute(attributesArray[i]);\n\t\t\t}\n\t\t}\n\t},\n\t_getBBox = target => {\n\t\tlet bounds, cloned;\n\t\ttry {\n\t\t\tbounds = target.getBBox(); //Firefox throws errors if you try calling getBBox() on an SVG element that's not rendered (like in a or ). https://bugzilla.mozilla.org/show_bug.cgi?id=612118\n\t\t} catch (error) {\n\t\t\tbounds = _getReparentedCloneBBox(target);\n\t\t\tcloned = 1;\n\t\t}\n\t\t(bounds && (bounds.width || bounds.height)) || cloned || (bounds = _getReparentedCloneBBox(target));\n\t\t//some browsers (like Firefox) misreport the bounds if the element has zero width and height (it just assumes it's at x:0, y:0), thus we need to manually grab the position in that case.\n\t\treturn (bounds && !bounds.width && !bounds.x && !bounds.y) ? {x: +_getAttributeFallbacks(target, [\"x\",\"cx\",\"x1\"]) || 0, y:+_getAttributeFallbacks(target, [\"y\",\"cy\",\"y1\"]) || 0, width:0, height:0} : bounds;\n\t},\n\t_isSVG = e => !!(e.getCTM && (!e.parentNode || e.ownerSVGElement) && _getBBox(e)), //reports if the element is an SVG on which getBBox() actually works\n\t_removeProperty = (target, property) => {\n\t\tif (property) {\n\t\t\tlet style = target.style,\n\t\t\t\tfirst2Chars;\n\t\t\tif (property in _transformProps && property !== _transformOriginProp) {\n\t\t\t\tproperty = _transformProp;\n\t\t\t}\n\t\t\tif (style.removeProperty) {\n\t\t\t\tfirst2Chars = property.substr(0,2);\n\t\t\t\tif (first2Chars === \"ms\" || property.substr(0,6) === \"webkit\") { //Microsoft and some Webkit browsers don't conform to the standard of capitalizing the first prefix character, so we adjust so that when we prefix the caps with a dash, it's correct (otherwise it'd be \"ms-transform\" instead of \"-ms-transform\" for IE9, for example)\n\t\t\t\t\tproperty = \"-\" + property;\n\t\t\t\t}\n\t\t\t\tstyle.removeProperty(first2Chars === \"--\" ? property : property.replace(_capsExp, \"-$1\").toLowerCase());\n\t\t\t} else { //note: old versions of IE use \"removeAttribute()\" instead of \"removeProperty()\"\n\t\t\t\tstyle.removeAttribute(property);\n\t\t\t}\n\t\t}\n\t},\n\t_addNonTweeningPT = (plugin, target, property, beginning, end, onlySetAtEnd) => {\n\t\tlet pt = new PropTween(plugin._pt, target, property, 0, 1, onlySetAtEnd ? _renderNonTweeningValueOnlyAtEnd : _renderNonTweeningValue);\n\t\tplugin._pt = pt;\n\t\tpt.b = beginning;\n\t\tpt.e = end;\n\t\tplugin._props.push(property);\n\t\treturn pt;\n\t},\n\t_nonConvertibleUnits = {deg:1, rad:1, turn:1},\n\t_nonStandardLayouts = {grid:1, flex:1},\n\t//takes a single value like 20px and converts it to the unit specified, like \"%\", returning only the numeric amount.\n\t_convertToUnit = (target, property, value, unit) => {\n\t\tlet curValue = parseFloat(value) || 0,\n\t\t\tcurUnit = (value + \"\").trim().substr((curValue + \"\").length) || \"px\", // some browsers leave extra whitespace at the beginning of CSS variables, hence the need to trim()\n\t\t\tstyle = _tempDiv.style,\n\t\t\thorizontal = _horizontalExp.test(property),\n\t\t\tisRootSVG = target.tagName.toLowerCase() === \"svg\",\n\t\t\tmeasureProperty = (isRootSVG ? \"client\" : \"offset\") + (horizontal ? \"Width\" : \"Height\"),\n\t\t\tamount = 100,\n\t\t\ttoPixels = unit === \"px\",\n\t\t\ttoPercent = unit === \"%\",\n\t\t\tpx, parent, cache, isSVG;\n\t\tif (unit === curUnit || !curValue || _nonConvertibleUnits[unit] || _nonConvertibleUnits[curUnit]) {\n\t\t\treturn curValue;\n\t\t}\n\t\t(curUnit !== \"px\" && !toPixels) && (curValue = _convertToUnit(target, property, value, \"px\"));\n\t\tisSVG = target.getCTM && _isSVG(target);\n\t\tif ((toPercent || curUnit === \"%\") && (_transformProps[property] || ~property.indexOf(\"adius\"))) {\n\t\t\tpx = isSVG ? target.getBBox()[horizontal ? \"width\" : \"height\"] : target[measureProperty];\n\t\t\treturn _round(toPercent ? curValue / px * amount : curValue / 100 * px);\n\t\t}\n\t\tstyle[horizontal ? \"width\" : \"height\"] = amount + (toPixels ? curUnit : unit);\n\t\tparent = ((unit !== \"rem\" && ~property.indexOf(\"adius\")) || (unit === \"em\" && target.appendChild && !isRootSVG)) ? target : target.parentNode;\n\t\tif (isSVG) {\n\t\t\tparent = (target.ownerSVGElement || {}).parentNode;\n\t\t}\n\t\tif (!parent || parent === _doc || !parent.appendChild) {\n\t\t\tparent = _doc.body;\n\t\t}\n\t\tcache = parent._gsap;\n\t\tif (cache && toPercent && cache.width && horizontal && cache.time === _ticker.time && !cache.uncache) {\n\t\t\treturn _round(curValue / cache.width * amount);\n\t\t} else {\n\t\t\tif (toPercent && (property === \"height\" || property === \"width\")) { // if we're dealing with width/height that's inside a container with padding and/or it's a flexbox/grid container, we must apply it to the target itself rather than the _tempDiv in order to ensure complete accuracy, factoring in the parent's padding.\n\t\t\t\tlet v = target.style[property];\n\t\t\t\ttarget.style[property] = amount + unit;\n\t\t\t\tpx = target[measureProperty];\n\t\t\t\tv ? (target.style[property] = v) : _removeProperty(target, property);\n\t\t\t} else {\n\t\t\t\t(toPercent || curUnit === \"%\") && !_nonStandardLayouts[_getComputedProperty(parent, \"display\")] && (style.position = _getComputedProperty(target, \"position\"));\n\t\t\t\t(parent === target) && (style.position = \"static\"); // like for borderRadius, if it's a % we must have it relative to the target itself but that may not have position: relative or position: absolute in which case it'd go up the chain until it finds its offsetParent (bad). position: static protects against that.\n\t\t\t\tparent.appendChild(_tempDiv);\n\t\t\t\tpx = _tempDiv[measureProperty];\n\t\t\t\tparent.removeChild(_tempDiv);\n\t\t\t\tstyle.position = \"absolute\";\n\t\t\t}\n\t\t\tif (horizontal && toPercent) {\n\t\t\t\tcache = _getCache(parent);\n\t\t\t\tcache.time = _ticker.time;\n\t\t\t\tcache.width = parent[measureProperty];\n\t\t\t}\n\t\t}\n\t\treturn _round(toPixels ? px * curValue / amount : px && curValue ? amount / px * curValue : 0);\n\t},\n\t_get = (target, property, unit, uncache) => {\n\t\tlet value;\n\t\t_pluginInitted || _initCore();\n\t\tif ((property in _propertyAliases) && property !== \"transform\") {\n\t\t\tproperty = _propertyAliases[property];\n\t\t\tif (~property.indexOf(\",\")) {\n\t\t\t\tproperty = property.split(\",\")[0];\n\t\t\t}\n\t\t}\n\t\tif (_transformProps[property] && property !== \"transform\") {\n\t\t\tvalue = _parseTransform(target, uncache);\n\t\t\tvalue = (property !== \"transformOrigin\") ? value[property] : value.svg ? value.origin : _firstTwoOnly(_getComputedProperty(target, _transformOriginProp)) + \" \" + value.zOrigin + \"px\";\n\t\t} else {\n\t\t\tvalue = target.style[property];\n\t\t\tif (!value || value === \"auto\" || uncache || ~(value + \"\").indexOf(\"calc(\")) {\n\t\t\t\tvalue = (_specialProps[property] && _specialProps[property](target, property, unit)) || _getComputedProperty(target, property) || _getProperty(target, property) || (property === \"opacity\" ? 1 : 0); // note: some browsers, like Firefox, don't report borderRadius correctly! Instead, it only reports every corner like borderTopLeftRadius\n\t\t\t}\n\t\t}\n\t\treturn unit && !~(value + \"\").trim().indexOf(\" \") ? _convertToUnit(target, property, value, unit) + unit : value;\n\n\t},\n\t_tweenComplexCSSString = function(target, prop, start, end) { // note: we call _tweenComplexCSSString.call(pluginInstance...) to ensure that it's scoped properly. We may call it from within a plugin too, thus \"this\" would refer to the plugin.\n\t\tif (!start || start === \"none\") { // some browsers like Safari actually PREFER the prefixed property and mis-report the unprefixed value like clipPath (BUG). In other words, even though clipPath exists in the style (\"clipPath\" in target.style) and it's set in the CSS properly (along with -webkit-clip-path), Safari reports clipPath as \"none\" whereas WebkitClipPath reports accurately like \"ellipse(100% 0% at 50% 0%)\", so in this case we must SWITCH to using the prefixed property instead. See https://gsap.com/forums/topic/18310-clippath-doesnt-work-on-ios/\n\t\t\tlet p = _checkPropPrefix(prop, target, 1),\n\t\t\t\ts = p && _getComputedProperty(target, p, 1);\n\t\t\tif (s && s !== start) {\n\t\t\t\tprop = p;\n\t\t\t\tstart = s;\n\t\t\t} else if (prop === \"borderColor\") {\n\t\t\t\tstart = _getComputedProperty(target, \"borderTopColor\"); // Firefox bug: always reports \"borderColor\" as \"\", so we must fall back to borderTopColor. See https://gsap.com/forums/topic/24583-how-to-return-colors-that-i-had-after-reverse/\n\t\t\t}\n\t\t}\n\t\tlet pt = new PropTween(this._pt, target.style, prop, 0, 1, _renderComplexString),\n\t\t\tindex = 0,\n\t\t\tmatchIndex = 0,\n\t\t\ta, result,\tstartValues, startNum, color, startValue, endValue, endNum, chunk, endUnit, startUnit, endValues;\n\t\tpt.b = start;\n\t\tpt.e = end;\n\t\tstart += \"\"; // ensure values are strings\n\t\tend += \"\";\n\t\tif (end === \"auto\") {\n\t\t\tstartValue = target.style[prop];\n\t\t\ttarget.style[prop] = end;\n\t\t\tend = _getComputedProperty(target, prop) || end;\n\t\t\tstartValue ? (target.style[prop] = startValue) : _removeProperty(target, prop);\n\t\t}\n\t\ta = [start, end];\n\t\t_colorStringFilter(a); // pass an array with the starting and ending values and let the filter do whatever it needs to the values. If colors are found, it returns true and then we must match where the color shows up order-wise because for things like boxShadow, sometimes the browser provides the computed values with the color FIRST, but the user provides it with the color LAST, so flip them if necessary. Same for drop-shadow().\n\t\tstart = a[0];\n\t\tend = a[1];\n\t\tstartValues = start.match(_numWithUnitExp) || [];\n\t\tendValues = end.match(_numWithUnitExp) || [];\n\t\tif (endValues.length) {\n\t\t\twhile ((result = _numWithUnitExp.exec(end))) {\n\t\t\t\tendValue = result[0];\n\t\t\t\tchunk = end.substring(index, result.index);\n\t\t\t\tif (color) {\n\t\t\t\t\tcolor = (color + 1) % 5;\n\t\t\t\t} else if (chunk.substr(-5) === \"rgba(\" || chunk.substr(-5) === \"hsla(\") {\n\t\t\t\t\tcolor = 1;\n\t\t\t\t}\n\t\t\t\tif (endValue !== (startValue = startValues[matchIndex++] || \"\")) {\n\t\t\t\t\tstartNum = parseFloat(startValue) || 0;\n\t\t\t\t\tstartUnit = startValue.substr((startNum + \"\").length);\n\t\t\t\t\t(endValue.charAt(1) === \"=\") && (endValue = _parseRelative(startNum, endValue) + startUnit);\n\t\t\t\t\tendNum = parseFloat(endValue);\n\t\t\t\t\tendUnit = endValue.substr((endNum + \"\").length);\n\t\t\t\t\tindex = _numWithUnitExp.lastIndex - endUnit.length;\n\t\t\t\t\tif (!endUnit) { //if something like \"perspective:300\" is passed in and we must add a unit to the end\n\t\t\t\t\t\tendUnit = endUnit || _config.units[prop] || startUnit;\n\t\t\t\t\t\tif (index === end.length) {\n\t\t\t\t\t\t\tend += endUnit;\n\t\t\t\t\t\t\tpt.e += endUnit;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (startUnit !== endUnit) {\n\t\t\t\t\t\tstartNum = _convertToUnit(target, prop, startValue, endUnit) || 0;\n\t\t\t\t\t}\n\t\t\t\t\t// these nested PropTweens are handled in a special way - we'll never actually call a render or setter method on them. We'll just loop through them in the parent complex string PropTween's render method.\n\t\t\t\t\tpt._pt = {\n\t\t\t\t\t\t_next: pt._pt,\n\t\t\t\t\t\tp: (chunk || (matchIndex === 1)) ? chunk : \",\", //note: SVG spec allows omission of comma/space when a negative sign is wedged between two numbers, like 2.5-5.3 instead of 2.5,-5.3 but when tweening, the negative value may switch to positive, so we insert the comma just in case.\n\t\t\t\t\t\ts: startNum,\n\t\t\t\t\t\tc: endNum - startNum,\n\t\t\t\t\t\tm: (color && color < 4) || prop === \"zIndex\" ? Math.round : 0\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t\tpt.c = (index < end.length) ? end.substring(index, end.length) : \"\"; //we use the \"c\" of the PropTween to store the final part of the string (after the last number)\n\t\t} else {\n\t\t\tpt.r = prop === \"display\" && end === \"none\" ? _renderNonTweeningValueOnlyAtEnd : _renderNonTweeningValue;\n\t\t}\n\t\t_relExp.test(end) && (pt.e = 0); //if the end string contains relative values or dynamic random(...) values, delete the end it so that on the final render we don't actually set it to the string with += or -= characters (forces it to use the calculated value).\n\t\tthis._pt = pt; //start the linked list with this new PropTween. Remember, we call _tweenComplexCSSString.call(pluginInstance...) to ensure that it's scoped properly. We may call it from within another plugin too, thus \"this\" would refer to the plugin.\n\t\treturn pt;\n\t},\n\t_keywordToPercent = {top:\"0%\", bottom:\"100%\", left:\"0%\", right:\"100%\", center:\"50%\"},\n\t_convertKeywordsToPercentages = value => {\n\t\tlet split = value.split(\" \"),\n\t\t\tx = split[0],\n\t\t\ty = split[1] || \"50%\";\n\t\tif (x === \"top\" || x === \"bottom\" || y === \"left\" || y === \"right\") { //the user provided them in the wrong order, so flip them\n\t\t\tvalue = x;\n\t\t\tx = y;\n\t\t\ty = value;\n\t\t}\n\t\tsplit[0] = _keywordToPercent[x] || x;\n\t\tsplit[1] = _keywordToPercent[y] || y;\n\t\treturn split.join(\" \");\n\t},\n\t_renderClearProps = (ratio, data) => {\n\t\tif (data.tween && data.tween._time === data.tween._dur) {\n\t\t\tlet target = data.t,\n\t\t\t\tstyle = target.style,\n\t\t\t\tprops = data.u,\n\t\t\t\tcache = target._gsap,\n\t\t\t\tprop, clearTransforms, i;\n\t\t\tif (props === \"all\" || props === true) {\n\t\t\t\tstyle.cssText = \"\";\n\t\t\t\tclearTransforms = 1;\n\t\t\t} else {\n\t\t\t\tprops = props.split(\",\");\n\t\t\t\ti = props.length;\n\t\t\t\twhile (--i > -1) {\n\t\t\t\t\tprop = props[i];\n\t\t\t\t\tif (_transformProps[prop]) {\n\t\t\t\t\t\tclearTransforms = 1;\n\t\t\t\t\t\tprop = (prop === \"transformOrigin\") ? _transformOriginProp : _transformProp;\n\t\t\t\t\t}\n\t\t\t\t\t_removeProperty(target, prop);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (clearTransforms) {\n\t\t\t\t_removeProperty(target, _transformProp);\n\t\t\t\tif (cache) {\n\t\t\t\t\tcache.svg && target.removeAttribute(\"transform\");\n\t\t\t\t\tstyle.scale = style.rotate = style.translate = \"none\";\n\t\t\t\t\t_parseTransform(target, 1); // force all the cached values back to \"normal\"/identity, otherwise if there's another tween that's already set to render transforms on this element, it could display the wrong values.\n\t\t\t\t\tcache.uncache = 1;\n\t\t\t\t\t_removeIndependentTransforms(style);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\t// note: specialProps should return 1 if (and only if) they have a non-zero priority. It indicates we need to sort the linked list.\n\t_specialProps = {\n\t\tclearProps(plugin, target, property, endValue, tween) {\n\t\t\tif (tween.data !== \"isFromStart\") {\n\t\t\t\tlet pt = plugin._pt = new PropTween(plugin._pt, target, property, 0, 0, _renderClearProps);\n\t\t\t\tpt.u = endValue;\n\t\t\t\tpt.pr = -10;\n\t\t\t\tpt.tween = tween;\n\t\t\t\tplugin._props.push(property);\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t}\n\t\t/* className feature (about 0.4kb gzipped).\n\t\t, className(plugin, target, property, endValue, tween) {\n\t\t\tlet _renderClassName = (ratio, data) => {\n\t\t\t\t\tdata.css.render(ratio, data.css);\n\t\t\t\t\tif (!ratio || ratio === 1) {\n\t\t\t\t\t\tlet inline = data.rmv,\n\t\t\t\t\t\t\ttarget = data.t,\n\t\t\t\t\t\t\tp;\n\t\t\t\t\t\ttarget.setAttribute(\"class\", ratio ? data.e : data.b);\n\t\t\t\t\t\tfor (p in inline) {\n\t\t\t\t\t\t\t_removeProperty(target, p);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t_getAllStyles = (target) => {\n\t\t\t\t\tlet styles = {},\n\t\t\t\t\t\tcomputed = getComputedStyle(target),\n\t\t\t\t\t\tp;\n\t\t\t\t\tfor (p in computed) {\n\t\t\t\t\t\tif (isNaN(p) && p !== \"cssText\" && p !== \"length\") {\n\t\t\t\t\t\t\tstyles[p] = computed[p];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t_setDefaults(styles, _parseTransform(target, 1));\n\t\t\t\t\treturn styles;\n\t\t\t\t},\n\t\t\t\tstartClassList = target.getAttribute(\"class\"),\n\t\t\t\tstyle = target.style,\n\t\t\t\tcssText = style.cssText,\n\t\t\t\tcache = target._gsap,\n\t\t\t\tclassPT = cache.classPT,\n\t\t\t\tinlineToRemoveAtEnd = {},\n\t\t\t\tdata = {t:target, plugin:plugin, rmv:inlineToRemoveAtEnd, b:startClassList, e:(endValue.charAt(1) !== \"=\") ? endValue : startClassList.replace(new RegExp(\"(?:\\\\s|^)\" + endValue.substr(2) + \"(?![\\\\w-])\"), \"\") + ((endValue.charAt(0) === \"+\") ? \" \" + endValue.substr(2) : \"\")},\n\t\t\t\tchangingVars = {},\n\t\t\t\tstartVars = _getAllStyles(target),\n\t\t\t\ttransformRelated = /(transform|perspective)/i,\n\t\t\t\tendVars, p;\n\t\t\tif (classPT) {\n\t\t\t\tclassPT.r(1, classPT.d);\n\t\t\t\t_removeLinkedListItem(classPT.d.plugin, classPT, \"_pt\");\n\t\t\t}\n\t\t\ttarget.setAttribute(\"class\", data.e);\n\t\t\tendVars = _getAllStyles(target, true);\n\t\t\ttarget.setAttribute(\"class\", startClassList);\n\t\t\tfor (p in endVars) {\n\t\t\t\tif (endVars[p] !== startVars[p] && !transformRelated.test(p)) {\n\t\t\t\t\tchangingVars[p] = endVars[p];\n\t\t\t\t\tif (!style[p] && style[p] !== \"0\") {\n\t\t\t\t\t\tinlineToRemoveAtEnd[p] = 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tcache.classPT = plugin._pt = new PropTween(plugin._pt, target, \"className\", 0, 0, _renderClassName, data, 0, -11);\n\t\t\tif (style.cssText !== cssText) { //only apply if things change. Otherwise, in cases like a background-image that's pulled dynamically, it could cause a refresh. See https://gsap.com/forums/topic/20368-possible-gsap-bug-switching-classnames-in-chrome/.\n\t\t\t\tstyle.cssText = cssText; //we recorded cssText before we swapped classes and ran _getAllStyles() because in cases when a className tween is overwritten, we remove all the related tweening properties from that class change (otherwise class-specific stuff can't override properties we've directly set on the target's style object due to specificity).\n\t\t\t}\n\t\t\t_parseTransform(target, true); //to clear the caching of transforms\n\t\t\tdata.css = new gsap.plugins.css();\n\t\t\tdata.css.init(target, changingVars, tween);\n\t\t\tplugin._props.push(...data.css._props);\n\t\t\treturn 1;\n\t\t}\n\t\t*/\n\t},\n\n\n\n\n\n\t/*\n\t * --------------------------------------------------------------------------------------\n\t * TRANSFORMS\n\t * --------------------------------------------------------------------------------------\n\t */\n\t_identity2DMatrix = [1,0,0,1,0,0],\n\t_rotationalProperties = {},\n\t_isNullTransform = value => (value === \"matrix(1, 0, 0, 1, 0, 0)\" || value === \"none\" || !value),\n\t_getComputedTransformMatrixAsArray = target => {\n\t\tlet matrixString = _getComputedProperty(target, _transformProp);\n\t\treturn _isNullTransform(matrixString) ? _identity2DMatrix : matrixString.substr(7).match(_numExp).map(_round);\n\t},\n\t_getMatrix = (target, force2D) => {\n\t\tlet cache = target._gsap || _getCache(target),\n\t\t\tstyle = target.style,\n\t\t\tmatrix = _getComputedTransformMatrixAsArray(target),\n\t\t\tparent, nextSibling, temp, addedToDOM;\n\t\tif (cache.svg && target.getAttribute(\"transform\")) {\n\t\t\ttemp = target.transform.baseVal.consolidate().matrix; //ensures that even complex values like \"translate(50,60) rotate(135,0,0)\" are parsed because it mashes it into a matrix.\n\t\t\tmatrix = [temp.a, temp.b, temp.c, temp.d, temp.e, temp.f];\n\t\t\treturn (matrix.join(\",\") === \"1,0,0,1,0,0\") ? _identity2DMatrix : matrix;\n\t\t} else if (matrix === _identity2DMatrix && !target.offsetParent && target !== _docElement && !cache.svg) { //note: if offsetParent is null, that means the element isn't in the normal document flow, like if it has display:none or one of its ancestors has display:none). Firefox returns null for getComputedStyle() if the element is in an iframe that has display:none. https://bugzilla.mozilla.org/show_bug.cgi?id=548397\n\t\t\t//browsers don't report transforms accurately unless the element is in the DOM and has a display value that's not \"none\". Firefox and Microsoft browsers have a partial bug where they'll report transforms even if display:none BUT not any percentage-based values like translate(-50%, 8px) will be reported as if it's translate(0, 8px).\n\t\t\ttemp = style.display;\n\t\t\tstyle.display = \"block\";\n\t\t\tparent = target.parentNode;\n\t\t\tif (!parent || (!target.offsetParent && !target.getBoundingClientRect().width)) { // note: in 3.3.0 we switched target.offsetParent to _doc.body.contains(target) to avoid [sometimes unnecessary] MutationObserver calls but that wasn't adequate because there are edge cases where nested position: fixed elements need to get reparented to accurately sense transforms. See https://github.com/greensock/GSAP/issues/388 and https://github.com/greensock/GSAP/issues/375. Note: position: fixed elements report a null offsetParent but they could also be invisible because they're in an ancestor with display: none, so we check getBoundingClientRect(). We only want to alter the DOM if we absolutely have to because it can cause iframe content to reload, like a Vimeo video.\n\t\t\t\taddedToDOM = 1; //flag\n\t\t\t\tnextSibling = target.nextElementSibling;\n\t\t\t\t_docElement.appendChild(target); //we must add it to the DOM in order to get values properly\n\t\t\t}\n\t\t\tmatrix = _getComputedTransformMatrixAsArray(target);\n\t\t\ttemp ? (style.display = temp) : _removeProperty(target, \"display\");\n\t\t\tif (addedToDOM) {\n\t\t\t\tnextSibling ? parent.insertBefore(target, nextSibling) : parent ? parent.appendChild(target) : _docElement.removeChild(target);\n\t\t\t}\n\t\t}\n\t\treturn (force2D && matrix.length > 6) ? [matrix[0], matrix[1], matrix[4], matrix[5], matrix[12], matrix[13]] : matrix;\n\t},\n\t_applySVGOrigin = (target, origin, originIsAbsolute, smooth, matrixArray, pluginToAddPropTweensTo) => {\n\t\tlet cache = target._gsap,\n\t\t\tmatrix = matrixArray || _getMatrix(target, true),\n\t\t\txOriginOld = cache.xOrigin || 0,\n\t\t\tyOriginOld = cache.yOrigin || 0,\n\t\t\txOffsetOld = cache.xOffset || 0,\n\t\t\tyOffsetOld = cache.yOffset || 0,\n\t\t\t[a, b, c, d, tx, ty] = matrix,\n\t\t\toriginSplit = origin.split(\" \"),\n\t\t\txOrigin = parseFloat(originSplit[0]) || 0,\n\t\t\tyOrigin = parseFloat(originSplit[1]) || 0,\n\t\t\tbounds, determinant, x, y;\n\t\tif (!originIsAbsolute) {\n\t\t\tbounds = _getBBox(target);\n\t\t\txOrigin = bounds.x + (~originSplit[0].indexOf(\"%\") ? xOrigin / 100 * bounds.width : xOrigin);\n\t\t\tyOrigin = bounds.y + (~((originSplit[1] || originSplit[0]).indexOf(\"%\")) ? yOrigin / 100 * bounds.height : yOrigin);\n\t\t\t// if (!(\"xOrigin\" in cache) && (xOrigin || yOrigin)) { // added in 3.12.3, reverted in 3.12.4; requires more exploration\n\t\t\t// \txOrigin -= bounds.x;\n\t\t\t// \tyOrigin -= bounds.y;\n\t\t\t// }\n\t\t} else if (matrix !== _identity2DMatrix && (determinant = (a * d - b * c))) { //if it's zero (like if scaleX and scaleY are zero), skip it to avoid errors with dividing by zero.\n\t\t\tx = xOrigin * (d / determinant) + yOrigin * (-c / determinant) + ((c * ty - d * tx) / determinant);\n\t\t\ty = xOrigin * (-b / determinant) + yOrigin * (a / determinant) - ((a * ty - b * tx) / determinant);\n\t\t\txOrigin = x;\n\t\t\tyOrigin = y;\n\t\t\t// theory: we only had to do this for smoothing and it assumes that the previous one was not originIsAbsolute.\n\t\t}\n\t\tif (smooth || (smooth !== false && cache.smooth)) {\n\t\t\ttx = xOrigin - xOriginOld;\n\t\t\tty = yOrigin - yOriginOld;\n\t\t\tcache.xOffset = xOffsetOld + (tx * a + ty * c) - tx;\n\t\t\tcache.yOffset = yOffsetOld + (tx * b + ty * d) - ty;\n\t\t} else {\n\t\t\tcache.xOffset = cache.yOffset = 0;\n\t\t}\n\t\tcache.xOrigin = xOrigin;\n\t\tcache.yOrigin = yOrigin;\n\t\tcache.smooth = !!smooth;\n\t\tcache.origin = origin;\n\t\tcache.originIsAbsolute = !!originIsAbsolute;\n\t\ttarget.style[_transformOriginProp] = \"0px 0px\"; //otherwise, if someone sets an origin via CSS, it will likely interfere with the SVG transform attribute ones (because remember, we're baking the origin into the matrix() value).\n\t\tif (pluginToAddPropTweensTo) {\n\t\t\t_addNonTweeningPT(pluginToAddPropTweensTo, cache, \"xOrigin\", xOriginOld, xOrigin);\n\t\t\t_addNonTweeningPT(pluginToAddPropTweensTo, cache, \"yOrigin\", yOriginOld, yOrigin);\n\t\t\t_addNonTweeningPT(pluginToAddPropTweensTo, cache, \"xOffset\", xOffsetOld, cache.xOffset);\n\t\t\t_addNonTweeningPT(pluginToAddPropTweensTo, cache, \"yOffset\", yOffsetOld, cache.yOffset);\n\t\t}\n\t\ttarget.setAttribute(\"data-svg-origin\", xOrigin + \" \" + yOrigin);\n\t},\n\t_parseTransform = (target, uncache) => {\n\t\tlet cache = target._gsap || new GSCache(target);\n\t\tif (\"x\" in cache && !uncache && !cache.uncache) {\n\t\t\treturn cache;\n\t\t}\n\t\tlet style = target.style,\n\t\t\tinvertedScaleX = cache.scaleX < 0,\n\t\t\tpx = \"px\",\n\t\t\tdeg = \"deg\",\n\t\t\tcs = getComputedStyle(target),\n\t\t\torigin = _getComputedProperty(target, _transformOriginProp) || \"0\",\n\t\t\tx, y, z, scaleX, scaleY, rotation, rotationX, rotationY, skewX, skewY, perspective, xOrigin, yOrigin,\n\t\t\tmatrix, angle, cos, sin, a, b, c, d, a12, a22, t1, t2, t3, a13, a23, a33, a42, a43, a32;\n\t\tx = y = z = rotation = rotationX = rotationY = skewX = skewY = perspective = 0;\n\t\tscaleX = scaleY = 1;\n\t\tcache.svg = !!(target.getCTM && _isSVG(target));\n\n\t\tif (cs.translate) { // accommodate independent transforms by combining them into normal ones.\n\t\t\tif (cs.translate !== \"none\" || cs.scale !== \"none\" || cs.rotate !== \"none\") {\n\t\t\t\tstyle[_transformProp] = (cs.translate !== \"none\" ? \"translate3d(\" + (cs.translate + \" 0 0\").split(\" \").slice(0, 3).join(\", \") + \") \" : \"\") + (cs.rotate !== \"none\" ? \"rotate(\" + cs.rotate + \") \" : \"\") + (cs.scale !== \"none\" ? \"scale(\" + cs.scale.split(\" \").join(\",\") + \") \" : \"\") + (cs[_transformProp] !== \"none\" ? cs[_transformProp] : \"\");\n\t\t\t}\n\t\t\tstyle.scale = style.rotate = style.translate = \"none\";\n\t\t}\n\n\t\tmatrix = _getMatrix(target, cache.svg);\n\t\tif (cache.svg) {\n\t\t\tif (cache.uncache) { // if cache.uncache is true (and maybe if origin is 0,0), we need to set element.style.transformOrigin = (cache.xOrigin - bbox.x) + \"px \" + (cache.yOrigin - bbox.y) + \"px\". Previously we let the data-svg-origin stay instead, but when introducing revert(), it complicated things.\n\t\t\t\tt2 = target.getBBox();\n\t\t\t\torigin = (cache.xOrigin - t2.x) + \"px \" + (cache.yOrigin - t2.y) + \"px\";\n\t\t\t\tt1 = \"\";\n\t\t\t} else {\n\t\t\t\tt1 = !uncache && target.getAttribute(\"data-svg-origin\"); // Remember, to work around browser inconsistencies we always force SVG elements' transformOrigin to 0,0 and offset the translation accordingly.\n\t\t\t}\n\t\t\t_applySVGOrigin(target, t1 || origin, !!t1 || cache.originIsAbsolute, cache.smooth !== false, matrix);\n\t\t}\n\t\txOrigin = cache.xOrigin || 0;\n\t\tyOrigin = cache.yOrigin || 0;\n\t\tif (matrix !== _identity2DMatrix) {\n\t\t\ta = matrix[0]; //a11\n\t\t\tb = matrix[1]; //a21\n\t\t\tc = matrix[2]; //a31\n\t\t\td = matrix[3]; //a41\n\t\t\tx = a12 = matrix[4];\n\t\t\ty = a22 = matrix[5];\n\n\t\t\t//2D matrix\n\t\t\tif (matrix.length === 6) {\n\t\t\t\tscaleX = Math.sqrt(a * a + b * b);\n\t\t\t\tscaleY = Math.sqrt(d * d + c * c);\n\t\t\t\trotation = (a || b) ? _atan2(b, a) * _RAD2DEG : 0; //note: if scaleX is 0, we cannot accurately measure rotation. Same for skewX with a scaleY of 0. Therefore, we default to the previously recorded value (or zero if that doesn't exist).\n\t\t\t\tskewX = (c || d) ? _atan2(c, d) * _RAD2DEG + rotation : 0;\n\t\t\t\tskewX && (scaleY *= Math.abs(Math.cos(skewX * _DEG2RAD)));\n\t\t\t\tif (cache.svg) {\n\t\t\t\t\tx -= xOrigin - (xOrigin * a + yOrigin * c);\n\t\t\t\t\ty -= yOrigin - (xOrigin * b + yOrigin * d);\n\t\t\t\t}\n\n\t\t\t//3D matrix\n\t\t\t} else {\n\t\t\t\ta32 = matrix[6];\n\t\t\t\ta42 = matrix[7];\n\t\t\t\ta13 = matrix[8];\n\t\t\t\ta23 = matrix[9];\n\t\t\t\ta33 = matrix[10];\n\t\t\t\ta43 = matrix[11];\n\t\t\t\tx = matrix[12];\n\t\t\t\ty = matrix[13];\n\t\t\t\tz = matrix[14];\n\n\t\t\t\tangle = _atan2(a32, a33);\n\t\t\t\trotationX = angle * _RAD2DEG;\n\t\t\t\t//rotationX\n\t\t\t\tif (angle) {\n\t\t\t\t\tcos = Math.cos(-angle);\n\t\t\t\t\tsin = Math.sin(-angle);\n\t\t\t\t\tt1 = a12*cos+a13*sin;\n\t\t\t\t\tt2 = a22*cos+a23*sin;\n\t\t\t\t\tt3 = a32*cos+a33*sin;\n\t\t\t\t\ta13 = a12*-sin+a13*cos;\n\t\t\t\t\ta23 = a22*-sin+a23*cos;\n\t\t\t\t\ta33 = a32*-sin+a33*cos;\n\t\t\t\t\ta43 = a42*-sin+a43*cos;\n\t\t\t\t\ta12 = t1;\n\t\t\t\t\ta22 = t2;\n\t\t\t\t\ta32 = t3;\n\t\t\t\t}\n\t\t\t\t//rotationY\n\t\t\t\tangle = _atan2(-c, a33);\n\t\t\t\trotationY = angle * _RAD2DEG;\n\t\t\t\tif (angle) {\n\t\t\t\t\tcos = Math.cos(-angle);\n\t\t\t\t\tsin = Math.sin(-angle);\n\t\t\t\t\tt1 = a*cos-a13*sin;\n\t\t\t\t\tt2 = b*cos-a23*sin;\n\t\t\t\t\tt3 = c*cos-a33*sin;\n\t\t\t\t\ta43 = d*sin+a43*cos;\n\t\t\t\t\ta = t1;\n\t\t\t\t\tb = t2;\n\t\t\t\t\tc = t3;\n\t\t\t\t}\n\t\t\t\t//rotationZ\n\t\t\t\tangle = _atan2(b, a);\n\t\t\t\trotation = angle * _RAD2DEG;\n\t\t\t\tif (angle) {\n\t\t\t\t\tcos = Math.cos(angle);\n\t\t\t\t\tsin = Math.sin(angle);\n\t\t\t\t\tt1 = a*cos+b*sin;\n\t\t\t\t\tt2 = a12*cos+a22*sin;\n\t\t\t\t\tb = b*cos-a*sin;\n\t\t\t\t\ta22 = a22*cos-a12*sin;\n\t\t\t\t\ta = t1;\n\t\t\t\t\ta12 = t2;\n\t\t\t\t}\n\n\t\t\t\tif (rotationX && Math.abs(rotationX) + Math.abs(rotation) > 359.9) { //when rotationY is set, it will often be parsed as 180 degrees different than it should be, and rotationX and rotation both being 180 (it looks the same), so we adjust for that here.\n\t\t\t\t\trotationX = rotation = 0;\n\t\t\t\t\trotationY = 180 - rotationY;\n\t\t\t\t}\n\t\t\t\tscaleX = _round(Math.sqrt(a * a + b * b + c * c));\n\t\t\t\tscaleY = _round(Math.sqrt(a22 * a22 + a32 * a32));\n\t\t\t\tangle = _atan2(a12, a22);\n\t\t\t\tskewX = (Math.abs(angle) > 0.0002) ? angle * _RAD2DEG : 0;\n\t\t\t\tperspective = a43 ? 1 / ((a43 < 0) ? -a43 : a43) : 0;\n\t\t\t}\n\n\t\t\tif (cache.svg) { //sense if there are CSS transforms applied on an SVG element in which case we must overwrite them when rendering. The transform attribute is more reliable cross-browser, but we can't just remove the CSS ones because they may be applied in a CSS rule somewhere (not just inline).\n\t\t\t\tt1 = target.getAttribute(\"transform\");\n\t\t\t\tcache.forceCSS = target.setAttribute(\"transform\", \"\") || (!_isNullTransform(_getComputedProperty(target, _transformProp)));\n\t\t\t\tt1 && target.setAttribute(\"transform\", t1);\n\t\t\t}\n\t\t}\n\n\t\tif (Math.abs(skewX) > 90 && Math.abs(skewX) < 270) {\n\t\t\tif (invertedScaleX) {\n\t\t\t\tscaleX *= -1;\n\t\t\t\tskewX += (rotation <= 0) ? 180 : -180;\n\t\t\t\trotation += (rotation <= 0) ? 180 : -180;\n\t\t\t} else {\n\t\t\t\tscaleY *= -1;\n\t\t\t\tskewX += (skewX <= 0) ? 180 : -180;\n\t\t\t}\n\t\t}\n\t\tuncache = uncache || cache.uncache;\n\t\tcache.x = x - ((cache.xPercent = x && ((!uncache && cache.xPercent) || (Math.round(target.offsetWidth / 2) === Math.round(-x) ? -50 : 0))) ? target.offsetWidth * cache.xPercent / 100 : 0) + px;\n\t\tcache.y = y - ((cache.yPercent = y && ((!uncache && cache.yPercent) || (Math.round(target.offsetHeight / 2) === Math.round(-y) ? -50 : 0))) ? target.offsetHeight * cache.yPercent / 100 : 0) + px;\n\t\tcache.z = z + px;\n\t\tcache.scaleX = _round(scaleX);\n\t\tcache.scaleY = _round(scaleY);\n\t\tcache.rotation = _round(rotation) + deg;\n\t\tcache.rotationX = _round(rotationX) + deg;\n\t\tcache.rotationY = _round(rotationY) + deg;\n\t\tcache.skewX = skewX + deg;\n\t\tcache.skewY = skewY + deg;\n\t\tcache.transformPerspective = perspective + px;\n\t\tif ((cache.zOrigin = parseFloat(origin.split(\" \")[2]) || (!uncache && cache.zOrigin) || 0)) {\n\t\t\tstyle[_transformOriginProp] = _firstTwoOnly(origin);\n\t\t}\n\t\tcache.xOffset = cache.yOffset = 0;\n\t\tcache.force3D = _config.force3D;\n\t\tcache.renderTransform = cache.svg ? _renderSVGTransforms : _supports3D ? _renderCSSTransforms : _renderNon3DTransforms;\n\t\tcache.uncache = 0;\n\t\treturn cache;\n\t},\n\t_firstTwoOnly = value => (value = value.split(\" \"))[0] + \" \" + value[1], //for handling transformOrigin values, stripping out the 3rd dimension\n\t_addPxTranslate = (target, start, value) => {\n\t\tlet unit = getUnit(start);\n\t\treturn _round(parseFloat(start) + parseFloat(_convertToUnit(target, \"x\", value + \"px\", unit))) + unit;\n\t},\n\t_renderNon3DTransforms = (ratio, cache) => {\n\t\tcache.z = \"0px\";\n\t\tcache.rotationY = cache.rotationX = \"0deg\";\n\t\tcache.force3D = 0;\n\t\t_renderCSSTransforms(ratio, cache);\n\t},\n\t_zeroDeg = \"0deg\",\n\t_zeroPx = \"0px\",\n\t_endParenthesis = \") \",\n\t_renderCSSTransforms = function(ratio, cache) {\n\t\tlet {xPercent, yPercent, x, y, z, rotation, rotationY, rotationX, skewX, skewY, scaleX, scaleY, transformPerspective, force3D, target, zOrigin} = cache || this,\n\t\t\ttransforms = \"\",\n\t\t\tuse3D = (force3D === \"auto\" && ratio && ratio !== 1) || force3D === true;\n\n\t\t// Safari has a bug that causes it not to render 3D transform-origin values properly, so we force the z origin to 0, record it in the cache, and then do the math here to offset the translate values accordingly (basically do the 3D transform-origin part manually)\n\t\tif (zOrigin && (rotationX !== _zeroDeg || rotationY !== _zeroDeg)) {\n\t\t\tlet angle = parseFloat(rotationY) * _DEG2RAD,\n\t\t\t\ta13 = Math.sin(angle),\n\t\t\t\ta33 = Math.cos(angle),\n\t\t\t\tcos;\n\t\t\tangle = parseFloat(rotationX) * _DEG2RAD;\n\t\t\tcos = Math.cos(angle);\n\t\t\tx = _addPxTranslate(target, x, a13 * cos * -zOrigin);\n\t\t\ty = _addPxTranslate(target, y, -Math.sin(angle) * -zOrigin);\n\t\t\tz = _addPxTranslate(target, z, a33 * cos * -zOrigin + zOrigin);\n\t\t}\n\n\t\tif (transformPerspective !== _zeroPx) {\n\t\t\ttransforms += \"perspective(\" + transformPerspective + _endParenthesis;\n\t\t}\n\t\tif (xPercent || yPercent) {\n\t\t\ttransforms += \"translate(\" + xPercent + \"%, \" + yPercent + \"%) \";\n\t\t}\n\t\tif (use3D || x !== _zeroPx || y !== _zeroPx || z !== _zeroPx) {\n\t\t\ttransforms += (z !== _zeroPx || use3D) ? \"translate3d(\" + x + \", \" + y + \", \" + z + \") \" : \"translate(\" + x + \", \" + y + _endParenthesis;\n\t\t}\n\t\tif (rotation !== _zeroDeg) {\n\t\t\ttransforms += \"rotate(\" + rotation + _endParenthesis;\n\t\t}\n\t\tif (rotationY !== _zeroDeg) {\n\t\t\ttransforms += \"rotateY(\" + rotationY + _endParenthesis;\n\t\t}\n\t\tif (rotationX !== _zeroDeg) {\n\t\t\ttransforms += \"rotateX(\" + rotationX + _endParenthesis;\n\t\t}\n\t\tif (skewX !== _zeroDeg || skewY !== _zeroDeg) {\n\t\t\ttransforms += \"skew(\" + skewX + \", \" + skewY + _endParenthesis;\n\t\t}\n\t\tif (scaleX !== 1 || scaleY !== 1) {\n\t\t\ttransforms += \"scale(\" + scaleX + \", \" + scaleY + _endParenthesis;\n\t\t}\n\t\ttarget.style[_transformProp] = transforms || \"translate(0, 0)\";\n\t},\n\t_renderSVGTransforms = function(ratio, cache) {\n\t\tlet {xPercent, yPercent, x, y, rotation, skewX, skewY, scaleX, scaleY, target, xOrigin, yOrigin, xOffset, yOffset, forceCSS} = cache || this,\n\t\t\ttx = parseFloat(x),\n\t\t\tty = parseFloat(y),\n\t\t\ta11, a21, a12, a22, temp;\n\t\trotation = parseFloat(rotation);\n\t\tskewX = parseFloat(skewX);\n\t\tskewY = parseFloat(skewY);\n\t\tif (skewY) { //for performance reasons, we combine all skewing into the skewX and rotation values. Remember, a skewY of 10 degrees looks the same as a rotation of 10 degrees plus a skewX of 10 degrees.\n\t\t\tskewY = parseFloat(skewY);\n\t\t\tskewX += skewY;\n\t\t\trotation += skewY;\n\t\t}\n\t\tif (rotation || skewX) {\n\t\t\trotation *= _DEG2RAD;\n\t\t\tskewX *= _DEG2RAD;\n\t\t\ta11 = Math.cos(rotation) * scaleX;\n\t\t\ta21 = Math.sin(rotation) * scaleX;\n\t\t\ta12 = Math.sin(rotation - skewX) * -scaleY;\n\t\t\ta22 = Math.cos(rotation - skewX) * scaleY;\n\t\t\tif (skewX) {\n\t\t\t\tskewY *= _DEG2RAD;\n\t\t\t\ttemp = Math.tan(skewX - skewY);\n\t\t\t\ttemp = Math.sqrt(1 + temp * temp);\n\t\t\t\ta12 *= temp;\n\t\t\t\ta22 *= temp;\n\t\t\t\tif (skewY) {\n\t\t\t\t\ttemp = Math.tan(skewY);\n\t\t\t\t\ttemp = Math.sqrt(1 + temp * temp);\n\t\t\t\t\ta11 *= temp;\n\t\t\t\t\ta21 *= temp;\n\t\t\t\t}\n\t\t\t}\n\t\t\ta11 = _round(a11);\n\t\t\ta21 = _round(a21);\n\t\t\ta12 = _round(a12);\n\t\t\ta22 = _round(a22);\n\t\t} else {\n\t\t\ta11 = scaleX;\n\t\t\ta22 = scaleY;\n\t\t\ta21 = a12 = 0;\n\t\t}\n\t\tif ((tx && !~(x + \"\").indexOf(\"px\")) || (ty && !~(y + \"\").indexOf(\"px\"))) {\n\t\t\ttx = _convertToUnit(target, \"x\", x, \"px\");\n\t\t\tty = _convertToUnit(target, \"y\", y, \"px\");\n\t\t}\n\t\tif (xOrigin || yOrigin || xOffset || yOffset) {\n\t\t\ttx = _round(tx + xOrigin - (xOrigin * a11 + yOrigin * a12) + xOffset);\n\t\t\tty = _round(ty + yOrigin - (xOrigin * a21 + yOrigin * a22) + yOffset);\n\t\t}\n\t\tif (xPercent || yPercent) {\n\t\t\t//The SVG spec doesn't support percentage-based translation in the \"transform\" attribute, so we merge it into the translation to simulate it.\n\t\t\ttemp = target.getBBox();\n\t\t\ttx = _round(tx + xPercent / 100 * temp.width);\n\t\t\tty = _round(ty + yPercent / 100 * temp.height);\n\t\t}\n\t\ttemp = \"matrix(\" + a11 + \",\" + a21 + \",\" + a12 + \",\" + a22 + \",\" + tx + \",\" + ty + \")\";\n\t\ttarget.setAttribute(\"transform\", temp);\n\t\tforceCSS && (target.style[_transformProp] = temp); //some browsers prioritize CSS transforms over the transform attribute. When we sense that the user has CSS transforms applied, we must overwrite them this way (otherwise some browser simply won't render the transform attribute changes!)\n\t},\n\t_addRotationalPropTween = function(plugin, target, property, startNum, endValue) {\n\t\tlet cap = 360,\n\t\t\tisString = _isString(endValue),\n\t\t\tendNum = parseFloat(endValue) * ((isString && ~endValue.indexOf(\"rad\")) ? _RAD2DEG : 1),\n\t\t\tchange = endNum - startNum,\n\t\t\tfinalValue = (startNum + change) + \"deg\",\n\t\t\tdirection, pt;\n\t\tif (isString) {\n\t\t\tdirection = endValue.split(\"_\")[1];\n\t\t\tif (direction === \"short\") {\n\t\t\t\tchange %= cap;\n\t\t\t\tif (change !== change % (cap / 2)) {\n\t\t\t\t\tchange += (change < 0) ? cap : -cap;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (direction === \"cw\" && change < 0) {\n\t\t\t\tchange = ((change + cap * _bigNum) % cap) - ~~(change / cap) * cap;\n\t\t\t} else if (direction === \"ccw\" && change > 0) {\n\t\t\t\tchange = ((change - cap * _bigNum) % cap) - ~~(change / cap) * cap;\n\t\t\t}\n\t\t}\n\t\tplugin._pt = pt = new PropTween(plugin._pt, target, property, startNum, change, _renderPropWithEnd);\n\t\tpt.e = finalValue;\n\t\tpt.u = \"deg\";\n\t\tplugin._props.push(property);\n\t\treturn pt;\n\t},\n\t_assign = (target, source) => { // Internet Explorer doesn't have Object.assign(), so we recreate it here.\n\t\tfor (let p in source) {\n\t\t\ttarget[p] = source[p];\n\t\t}\n\t\treturn target;\n\t},\n\t_addRawTransformPTs = (plugin, transforms, target) => { //for handling cases where someone passes in a whole transform string, like transform: \"scale(2, 3) rotate(20deg) translateY(30em)\"\n\t\tlet startCache = _assign({}, target._gsap),\n\t\t\texclude = \"perspective,force3D,transformOrigin,svgOrigin\",\n\t\t\tstyle = target.style,\n\t\t\tendCache, p, startValue, endValue, startNum, endNum, startUnit, endUnit;\n\t\tif (startCache.svg) {\n\t\t\tstartValue = target.getAttribute(\"transform\");\n\t\t\ttarget.setAttribute(\"transform\", \"\");\n\t\t\tstyle[_transformProp] = transforms;\n\t\t\tendCache = _parseTransform(target, 1);\n\t\t\t_removeProperty(target, _transformProp);\n\t\t\ttarget.setAttribute(\"transform\", startValue);\n\t\t} else {\n\t\t\tstartValue = getComputedStyle(target)[_transformProp];\n\t\t\tstyle[_transformProp] = transforms;\n\t\t\tendCache = _parseTransform(target, 1);\n\t\t\tstyle[_transformProp] = startValue;\n\t\t}\n\t\tfor (p in _transformProps) {\n\t\t\tstartValue = startCache[p];\n\t\t\tendValue = endCache[p];\n\t\t\tif (startValue !== endValue && exclude.indexOf(p) < 0) { //tweening to no perspective gives very unintuitive results - just keep the same perspective in that case.\n\t\t\t\tstartUnit = getUnit(startValue);\n\t\t\t\tendUnit = getUnit(endValue);\n\t\t\t\tstartNum = (startUnit !== endUnit) ? _convertToUnit(target, p, startValue, endUnit) : parseFloat(startValue);\n\t\t\t\tendNum = parseFloat(endValue);\n\t\t\t\tplugin._pt = new PropTween(plugin._pt, endCache, p, startNum, endNum - startNum, _renderCSSProp);\n\t\t\t\tplugin._pt.u = endUnit || 0;\n\t\t\t\tplugin._props.push(p);\n\t\t\t}\n\t\t}\n\t\t_assign(endCache, startCache);\n\t};\n\n// handle splitting apart padding, margin, borderWidth, and borderRadius into their 4 components. Firefox, for example, won't report borderRadius correctly - it will only do borderTopLeftRadius and the other corners. We also want to handle paddingTop, marginLeft, borderRightWidth, etc.\n_forEachName(\"padding,margin,Width,Radius\", (name, index) => {\n\tlet t = \"Top\",\n\t\tr = \"Right\",\n\t\tb = \"Bottom\",\n\t\tl = \"Left\",\n\t\tprops = (index < 3 ? [t,r,b,l] : [t+l, t+r, b+r, b+l]).map(side => index < 2 ? name + side : \"border\" + side + name);\n\t_specialProps[(index > 1 ? \"border\" + name : name)] = function(plugin, target, property, endValue, tween) {\n\t\tlet a, vars;\n\t\tif (arguments.length < 4) { // getter, passed target, property, and unit (from _get())\n\t\t\ta = props.map(prop => _get(plugin, prop, property));\n\t\t\tvars = a.join(\" \");\n\t\t\treturn vars.split(a[0]).length === 5 ? a[0] : vars;\n\t\t}\n\t\ta = (endValue + \"\").split(\" \");\n\t\tvars = {};\n\t\tprops.forEach((prop, i) => vars[prop] = a[i] = a[i] || a[(((i - 1) / 2) | 0)]);\n\t\tplugin.init(target, vars, tween);\n\t}\n});\n\n\nexport const CSSPlugin = {\n\tname: \"css\",\n\tregister: _initCore,\n\ttargetTest(target) {\n\t\treturn target.style && target.nodeType;\n\t},\n\tinit(target, vars, tween, index, targets) {\n\t\tlet props = this._props,\n\t\t\tstyle = target.style,\n\t\t\tstartAt = tween.vars.startAt,\n\t\t\tstartValue, endValue, endNum, startNum, type, specialProp, p, startUnit, endUnit, relative, isTransformRelated, transformPropTween, cache, smooth, hasPriority, inlineProps;\n\t\t_pluginInitted || _initCore();\n\t\t// we may call init() multiple times on the same plugin instance, like when adding special properties, so make sure we don't overwrite the revert data or inlineProps\n\t\tthis.styles = this.styles || _getStyleSaver(target);\n\t\tinlineProps = this.styles.props;\n\t\tthis.tween = tween;\n\t\tfor (p in vars) {\n\t\t\tif (p === \"autoRound\") {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tendValue = vars[p];\n\t\t\tif (_plugins[p] && _checkPlugin(p, vars, tween, index, target, targets)) { // plugins\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\ttype = typeof(endValue);\n\t\t\tspecialProp = _specialProps[p];\n\t\t\tif (type === \"function\") {\n\t\t\t\tendValue = endValue.call(tween, index, target, targets);\n\t\t\t\ttype = typeof(endValue);\n\t\t\t}\n\t\t\tif (type === \"string\" && ~endValue.indexOf(\"random(\")) {\n\t\t\t\tendValue = _replaceRandom(endValue);\n\t\t\t}\n\t\t\tif (specialProp) {\n\t\t\t\tspecialProp(this, target, p, endValue, tween) && (hasPriority = 1);\n\t\t\t} else if (p.substr(0,2) === \"--\") { //CSS variable\n\t\t\t\tstartValue = (getComputedStyle(target).getPropertyValue(p) + \"\").trim();\n\t\t\t\tendValue += \"\";\n\t\t\t\t_colorExp.lastIndex = 0;\n\t\t\t\tif (!_colorExp.test(startValue)) { // colors don't have units\n\t\t\t\t\tstartUnit = getUnit(startValue);\n\t\t\t\t\tendUnit = getUnit(endValue);\n\t\t\t\t}\n\t\t\t\tendUnit ? startUnit !== endUnit && (startValue = _convertToUnit(target, p, startValue, endUnit) + endUnit) : startUnit && (endValue += startUnit);\n\t\t\t\tthis.add(style, \"setProperty\", startValue, endValue, index, targets, 0, 0, p);\n\t\t\t\tprops.push(p);\n\t\t\t\tinlineProps.push(p, 0, style[p]);\n\t\t\t} else if (type !== \"undefined\") {\n\t\t\t\tif (startAt && p in startAt) { // in case someone hard-codes a complex value as the start, like top: \"calc(2vh / 2)\". Without this, it'd use the computed value (always in px)\n\t\t\t\t\tstartValue = typeof(startAt[p]) === \"function\" ? startAt[p].call(tween, index, target, targets) : startAt[p];\n\t\t\t\t\t_isString(startValue) && ~startValue.indexOf(\"random(\") && (startValue = _replaceRandom(startValue));\n\t\t\t\t\tgetUnit(startValue + \"\") || startValue === \"auto\" || (startValue += _config.units[p] || getUnit(_get(target, p)) || \"\"); // for cases when someone passes in a unitless value like {x: 100}; if we try setting translate(100, 0px) it won't work.\n\t\t\t\t\t(startValue + \"\").charAt(1) === \"=\" && (startValue = _get(target, p)); // can't work with relative values\n\t\t\t\t} else {\n\t\t\t\t\tstartValue = _get(target, p);\n\t\t\t\t}\n\t\t\t\tstartNum = parseFloat(startValue);\n\t\t\t\trelative = (type === \"string\" && endValue.charAt(1) === \"=\") && endValue.substr(0, 2);\n\t\t\t\trelative && (endValue = endValue.substr(2));\n\t\t\t\tendNum = parseFloat(endValue);\n\t\t\t\tif (p in _propertyAliases) {\n\t\t\t\t\tif (p === \"autoAlpha\") { //special case where we control the visibility along with opacity. We still allow the opacity value to pass through and get tweened.\n\t\t\t\t\t\tif (startNum === 1 && _get(target, \"visibility\") === \"hidden\" && endNum) { //if visibility is initially set to \"hidden\", we should interpret that as intent to make opacity 0 (a convenience)\n\t\t\t\t\t\t\tstartNum = 0;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tinlineProps.push(\"visibility\", 0, style.visibility);\n\t\t\t\t\t\t_addNonTweeningPT(this, style, \"visibility\", startNum ? \"inherit\" : \"hidden\", endNum ? \"inherit\" : \"hidden\", !endNum);\n\t\t\t\t\t}\n\t\t\t\t\tif (p !== \"scale\" && p !== \"transform\") {\n\t\t\t\t\t\tp = _propertyAliases[p];\n\t\t\t\t\t\t~p.indexOf(\",\") && (p = p.split(\",\")[0]);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tisTransformRelated = (p in _transformProps);\n\n\t\t\t\t//--- TRANSFORM-RELATED ---\n\t\t\t\tif (isTransformRelated) {\n\t\t\t\t\tthis.styles.save(p);\n\t\t\t\t\tif (!transformPropTween) {\n\t\t\t\t\t\tcache = target._gsap;\n\t\t\t\t\t\t(cache.renderTransform && !vars.parseTransform) || _parseTransform(target, vars.parseTransform); // if, for example, gsap.set(... {transform:\"translateX(50vw)\"}), the _get() call doesn't parse the transform, thus cache.renderTransform won't be set yet so force the parsing of the transform here.\n\t\t\t\t\t\tsmooth = (vars.smoothOrigin !== false && cache.smooth);\n\t\t\t\t\t\ttransformPropTween = this._pt = new PropTween(this._pt, style, _transformProp, 0, 1, cache.renderTransform, cache, 0, -1); //the first time through, create the rendering PropTween so that it runs LAST (in the linked list, we keep adding to the beginning)\n\t\t\t\t\t\ttransformPropTween.dep = 1; //flag it as dependent so that if things get killed/overwritten and this is the only PropTween left, we can safely kill the whole tween.\n\t\t\t\t\t}\n\t\t\t\t\tif (p === \"scale\") {\n\t\t\t\t\t\tthis._pt = new PropTween(this._pt, cache, \"scaleY\", cache.scaleY, ((relative ? _parseRelative(cache.scaleY, relative + endNum) : endNum) - cache.scaleY) || 0, _renderCSSProp);\n\t\t\t\t\t\tthis._pt.u = 0;\n\t\t\t\t\t\tprops.push(\"scaleY\", p);\n\t\t\t\t\t\tp += \"X\";\n\t\t\t\t\t} else if (p === \"transformOrigin\") {\n\t\t\t\t\t\tinlineProps.push(_transformOriginProp, 0, style[_transformOriginProp]);\n\t\t\t\t\t\tendValue = _convertKeywordsToPercentages(endValue); //in case something like \"left top\" or \"bottom right\" is passed in. Convert to percentages.\n\t\t\t\t\t\tif (cache.svg) {\n\t\t\t\t\t\t\t_applySVGOrigin(target, endValue, 0, smooth, 0, this);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tendUnit = parseFloat(endValue.split(\" \")[2]) || 0; //handle the zOrigin separately!\n\t\t\t\t\t\t\tendUnit !== cache.zOrigin && _addNonTweeningPT(this, cache, \"zOrigin\", cache.zOrigin, endUnit);\n\t\t\t\t\t\t\t_addNonTweeningPT(this, style, p, _firstTwoOnly(startValue), _firstTwoOnly(endValue));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} else if (p === \"svgOrigin\") {\n\t\t\t\t\t\t_applySVGOrigin(target, endValue, 1, smooth, 0, this);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} else if (p in _rotationalProperties) {\n\t\t\t\t\t\t_addRotationalPropTween(this, cache, p, startNum, relative ? _parseRelative(startNum, relative + endValue) : endValue);\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\t} else if (p === \"smoothOrigin\") {\n\t\t\t\t\t\t_addNonTweeningPT(this, cache, \"smooth\", cache.smooth, endValue);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} else if (p === \"force3D\") {\n\t\t\t\t\t\tcache[p] = endValue;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} else if (p === \"transform\") {\n\t\t\t\t\t\t_addRawTransformPTs(this, endValue, target);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t} else if (!(p in style)) {\n\t\t\t\t\tp = _checkPropPrefix(p) || p;\n\t\t\t\t}\n\n\t\t\t\tif (isTransformRelated || ((endNum || endNum === 0) && (startNum || startNum === 0) && !_complexExp.test(endValue) && (p in style))) {\n\t\t\t\t\tstartUnit = (startValue + \"\").substr((startNum + \"\").length);\n\t\t\t\t\tendNum || (endNum = 0); // protect against NaN\n\t\t\t\t\tendUnit = getUnit(endValue) || ((p in _config.units) ? _config.units[p] : startUnit);\n\t\t\t\t\tstartUnit !== endUnit && (startNum = _convertToUnit(target, p, startValue, endUnit));\n\t\t\t\t\tthis._pt = new PropTween(this._pt, isTransformRelated ? cache : style, p, startNum, (relative ? _parseRelative(startNum, relative + endNum) : endNum) - startNum, (!isTransformRelated && (endUnit === \"px\" || p === \"zIndex\") && vars.autoRound !== false) ? _renderRoundedCSSProp : _renderCSSProp);\n\t\t\t\t\tthis._pt.u = endUnit || 0;\n\t\t\t\t\tif (startUnit !== endUnit && endUnit !== \"%\") { //when the tween goes all the way back to the beginning, we need to revert it to the OLD/ORIGINAL value (with those units). We record that as a \"b\" (beginning) property and point to a render method that handles that. (performance optimization)\n\t\t\t\t\t\tthis._pt.b = startValue;\n\t\t\t\t\t\tthis._pt.r = _renderCSSPropWithBeginning;\n\t\t\t\t\t}\n\t\t\t\t} else if (!(p in style)) {\n\t\t\t\t\tif (p in target) { //maybe it's not a style - it could be a property added directly to an element in which case we'll try to animate that.\n\t\t\t\t\t\tthis.add(target, p, startValue || target[p], relative ? relative + endValue : endValue, index, targets);\n\t\t\t\t\t} else if (p !== \"parseTransform\") {\n\t\t\t\t\t\t_missingPlugin(p, endValue);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t_tweenComplexCSSString.call(this, target, p, startValue, relative ? relative + endValue : endValue);\n\t\t\t\t}\n\t\t\t\tisTransformRelated || (p in style ? inlineProps.push(p, 0, style[p]) : typeof(target[p]) === \"function\" ? inlineProps.push(p, 2, target[p]()) : inlineProps.push(p, 1, startValue || target[p]));\n\t\t\t\tprops.push(p);\n\t\t\t}\n\t\t}\n\t\thasPriority && _sortPropTweensByPriority(this);\n\n\t},\n\trender(ratio, data) {\n\t\tif (data.tween._time || !_reverting()) {\n\t\t\tlet pt = data._pt;\n\t\t\twhile (pt) {\n\t\t\t\tpt.r(ratio, pt.d);\n\t\t\t\tpt = pt._next;\n\t\t\t}\n\t\t} else {\n\t\t\tdata.styles.revert();\n\t\t}\n\t},\n\tget: _get,\n\taliases: _propertyAliases,\n\tgetSetter(target, property, plugin) { //returns a setter function that accepts target, property, value and applies it accordingly. Remember, properties like \"x\" aren't as simple as target.style.property = value because they've got to be applied to a proxy object and then merged into a transform string in a renderer.\n\t\tlet p = _propertyAliases[property];\n\t\t(p && p.indexOf(\",\") < 0) && (property = p);\n\t\treturn (property in _transformProps && property !== _transformOriginProp && (target._gsap.x || _get(target, \"x\"))) ? (plugin && _recentSetterPlugin === plugin ? (property === \"scale\" ? _setterScale : _setterTransform) : (_recentSetterPlugin = plugin || {}) && (property === \"scale\" ? _setterScaleWithRender : _setterTransformWithRender)) : target.style && !_isUndefined(target.style[property]) ? _setterCSSStyle : ~property.indexOf(\"-\") ? _setterCSSProp : _getSetter(target, property);\n\t},\n\tcore: { _removeProperty, _getMatrix }\n\n};\n\ngsap.utils.checkPrefix = _checkPropPrefix;\ngsap.core.getStyleSaver = _getStyleSaver;\n(function(positionAndScale, rotation, others, aliases) {\n\tlet all = _forEachName(positionAndScale + \",\" + rotation + \",\" + others, name => {_transformProps[name] = 1});\n\t_forEachName(rotation, name => {_config.units[name] = \"deg\"; _rotationalProperties[name] = 1});\n\t_propertyAliases[all[13]] = positionAndScale + \",\" + rotation;\n\t_forEachName(aliases, name => {\n\t\tlet split = name.split(\":\");\n\t\t_propertyAliases[split[1]] = all[split[0]];\n\t});\n})(\"x,y,z,scale,scaleX,scaleY,xPercent,yPercent\", \"rotation,rotationX,rotationY,skewX,skewY\", \"transform,transformOrigin,svgOrigin,force3D,smoothOrigin,transformPerspective\", \"0:translateX,1:translateY,2:translateZ,8:rotate,8:rotationZ,8:rotateZ,9:rotateX,10:rotateY\");\n_forEachName(\"x,y,z,top,right,bottom,left,width,height,fontSize,padding,margin,perspective\", name => {_config.units[name] = \"px\"});\n\ngsap.registerPlugin(CSSPlugin);\n\nexport { CSSPlugin as default, _getBBox, _createElement, _checkPropPrefix as checkPrefix };","import { gsap, Power0, Power1, Power2, Power3, Power4, Linear, Quad, Cubic, Quart, Quint, Strong, Elastic, Back, SteppedEase, Bounce, Sine, Expo, Circ, TweenLite, TimelineLite, TimelineMax } from \"./gsap-core.js\";\nimport { CSSPlugin } from \"./CSSPlugin.js\";\n\nconst gsapWithCSS = gsap.registerPlugin(CSSPlugin) || gsap, // to protect from tree shaking\n\tTweenMaxWithCSS = gsapWithCSS.core.Tween;\n\nexport {\n\tgsapWithCSS as gsap,\n\tgsapWithCSS as default,\n\tCSSPlugin,\n\tTweenMaxWithCSS as TweenMax,\n\tTweenLite,\n\tTimelineMax,\n\tTimelineLite,\n\tPower0,\n\tPower1,\n\tPower2,\n\tPower3,\n\tPower4,\n\tLinear,\n\tQuad,\n\tCubic,\n\tQuart,\n\tQuint,\n\tStrong,\n\tElastic,\n\tBack,\n\tSteppedEase,\n\tBounce,\n\tSine,\n\tExpo,\n\tCirc\n};"],"names":["_isString","value","_isFunction","_isNumber","_isUndefined","_isObject","_isNotFalse","_windowExists","window","_isFuncOrString","_install","scope","_installScope","_merge","_globals","gsap","_missingPlugin","property","console","warn","_warn","message","suppress","_addGlobal","name","obj","_emptyFunc","_harness","targets","harnessPlugin","i","target","_gsap","harness","_harnessPlugins","length","targetTest","GSCache","splice","_getCache","toArray","_getProperty","v","getAttribute","_forEachName","names","func","split","forEach","_round","Math","round","_roundPrecise","_parseRelative","start","operator","charAt","end","parseFloat","substr","_arrayContainsAny","toSearch","toFind","l","indexOf","_lazyRender","tween","_lazyTweens","a","slice","_lazyLookup","_lazy","render","_lazySafeRender","animation","time","suppressEvents","force","_reverting","_initted","_startAt","_numericIfPossible","n","match","_delimitedValueExp","trim","_passThrough","p","_setDefaults","defaults","_mergeDeep","base","toMerge","_copyExcluding","excluding","copy","_inheritDefaults","vars","parent","_globalTimeline","keyframes","_setKeyframeDefaults","excludeDuration","_isArray","inherit","_dp","_addLinkedListItem","child","firstProp","lastProp","sortBy","t","prev","_prev","_next","_removeLinkedListItem","next","_removeFromParent","onlyIfParentHasAutoRemove","autoRemoveChildren","remove","_act","_uncache","_end","_dur","_start","_dirty","_rewindStartAt","totalTime","revert","_revertConfigNoKill","immediateRender","autoRevert","_elapsedCycleDuration","_repeat","_animationCycle","_tTime","duration","_rDelay","_parentToChildTotalTime","parentTime","_ts","totalDuration","_tDur","_setEnd","abs","_rts","_tinyNum","_alignPlayhead","smoothChildTiming","_time","_postAddChecks","timeline","add","rawTime","_clamp","_zTime","_addToTimeline","position","skipChecks","_parsePosition","_delay","timeScale","_sort","_isFromOrFromStart","_recent","_scrollTrigger","trigger","ScrollTrigger","create","_attemptInitTween","tTime","_initTween","_pt","lazy","_lastRenderedFrame","_ticker","frame","push","_setDuration","skipUncache","leavePlayhead","repeat","dur","totalProgress","_onUpdateTotalDuration","Timeline","_createTweenType","type","params","irVars","isLegacy","varsIndex","runBackwards","startAt","Tween","_conditionalReturn","getUnit","_unitExp","exec","_isArrayLike","nonEmpty","nodeType","_win","selector","el","current","nativeElement","querySelectorAll","_doc","createElement","shuffle","sort","random","distribute","each","ease","_parseEase","from","cache","isDecimal","ratios","isNaN","axis","ratioX","ratioY","center","edges","originX","originY","x","y","d","j","max","min","wrapAt","distances","grid","_bigNum","getBoundingClientRect","left","_sqrt","amount","b","u","_invertEase","_roundModifier","pow","raw","snap","snapTo","radius","is2D","isArray","values","increment","dx","dy","closest","roundingIncrement","returnFunction","floor","_wrapArray","wrapper","index","_replaceRandom","nums","s","_strictNumExp","_getLabelInDirection","fromTime","backward","distance","label","labels","_interrupt","scrollTrigger","kill","progress","_callback","_createPlugin","config","headless","isFunc","Plugin","init","_props","instanceDefaults","_renderPropTweens","_addPropTween","_killPropTweensOf","modifier","_addPluginModifier","rawVars","statics","get","getSetter","_getSetter","aliases","register","_wake","_plugins","prototype","prop","_reservedProps","toUpperCase","PropTween","_registerPluginQueue","_hue","h","m1","m2","_255","splitColor","toHSL","forceAlpha","r","g","wasHSL","_colorLookup","black","parseInt","_numExp","transparent","map","Number","_colorOrderData","c","_colorExp","_numWithUnitExp","_formatColors","orderMatchData","shell","result","colors","color","join","replace","shift","_colorStringFilter","combined","lastIndex","test","_hslExp","_configEaseFromString","_easeMap","apply","_parseObjectInString","val","parsedVal","key","lastIndexOf","_quotesExp","_valueInParentheses","open","close","nested","substring","_CE","_customEaseExp","_propagateYoyoEase","isYoyo","_first","yoyoEase","_yoyo","_ease","_yEase","_insertEase","easeIn","easeOut","easeInOut","lowercaseName","toLowerCase","_easeInOutFromOut","_configElastic","amplitude","period","p1","_sin","p3","p2","_2PI","asin","_configBack","overshoot","_suppressOverwrites","_context","_coreInitted","_coreReady","_quickTween","_tickerActive","_id","_req","_raf","_self","_delta","_i","_getTime","_lagThreshold","_adjustedLag","_startTime","_lastUpdate","_gap","_nextTime","_listeners","n1","_config","autoSleep","force3D","nullTargetWarn","units","lineHeight","_defaults","overwrite","delay","PI","_HALF_PI","_gsID","sqrt","_cos","cos","sin","_isTypedArray","ArrayBuffer","isView","Array","_complexStringNumExp","_relExp","_startAtRevertConfig","isStart","_revertConfig","_effects","_nextGCFrame","_callbackNames","cycleDuration","whole","data","_zeroPosition","endTime","percentAnimation","offset","isPercent","recent","clippedDuration","_slice","leaveStrings","_flatten","ar","accumulator","call","mapRange","inMin","inMax","outMin","outMax","inRange","outRange","executeLazyFirst","callback","prevContext","context","_ctx","callbackScope","aqua","lime","silver","maroon","teal","blue","navy","white","olive","yellow","orange","gray","purple","green","red","pink","cyan","RegExp","Date","now","tick","_tick","deltaRatio","fps","wake","document","gsapVersions","version","GreenSockGlobals","requestAnimationFrame","sleep","f","setTimeout","cancelAnimationFrame","clearTimeout","lagSmoothing","threshold","adjustedLag","Infinity","once","prioritize","defaultEase","overlap","dispatch","elapsed","manual","power","Linear","easeNone","none","SteppedEase","steps","immediateStart","id","this","set","Animation","startTime","arguments","_ptLookup","_pTime","iteration","_ps","_recacheAncestors","paused","includeRepeats","wrapRepeats","prevIsReverting","globalTime","_sat","repeatDelay","yoyo","seek","restart","includeDelay","play","reversed","reverse","pause","atTime","resume","invalidate","isActive","eventCallback","_onUpdate","then","onFulfilled","self","Promise","resolve","_resolve","_then","_prom","ratio","sortChildren","_this","to","fromTo","fromVars","toVars","delayedCall","staggerTo","stagger","onCompleteAll","onCompleteAllParams","onComplete","onCompleteParams","staggerFrom","staggerFromTo","prevPaused","pauseTween","prevStart","prevIteration","prevTime","tDur","crossingStart","_lock","rewinding","doesWrap","repeatRefresh","onRepeat","_hasPause","_forcing","_findNextPauseTween","_last","onUpdate","adjustedTime","_this2","addLabel","getChildren","tweens","timelines","ignoreBeforeTime","getById","animations","removeLabel","killTweensOf","addPause","removePause","props","onlyActive","getTweensOf","_overwritingTween","children","parsedTargets","isGlobalTime","_targets","tweenTo","initted","tl","onStart","onStartParams","tweenFromTo","fromPosition","toPosition","nextLabel","afterTime","previousLabel","beforeTime","currentLabel","shiftChildren","adjustLabels","soft","clear","includeLabels","updateRoot","_checkPlugin","plugin","pt","ptLookup","_processVars","_parseFuncOrString","style","priority","_parseKeyframe","allProps","easeEach","e","_forceAllPropTweens","stringFilter","funcParam","optional","currentValue","parsedStart","setter","_setterFuncWithParam","_setterFunc","_setterPlain","_addComplexStringPropTween","startNums","endNum","chunk","startNum","hasRandom","_renderComplexString","matchIndex","m","fp","_renderBoolean","_renderPlain","cleanVars","hasPriority","gsData","harnessVars","overwritten","prevStartAt","fullTargets","autoOverwrite","_overwrite","_from","_ptCache","_op","_sortPropTweensByPriority","_onInit","_staggerTweenProps","_staggerPropsToSkip","skipInherit","curTarget","staggerFunc","staggerVarsToMerge","_this3","kf","_hasNoPausedAncestors","isNegative","_renderZeroDurationTween","prevRatio","_parentPlayheadIsBeforeStart","resetTo","startIsRelative","skipRecursion","_updatePropTweens","rootPT","lookup","ptCache","overwrittenProps","curLookup","curOverwriteProps","killingTargets","propTweenLookup","firstPT","_arraysMatch","a1","a2","_addAliasesToVars","propertyAliases","onReverseComplete","onReverseCompleteParams","_setterAttribute","setAttribute","_setterWithModifier","mSet","mt","hasNonDependentRemaining","op","dep","pt2","first","last","pr","change","renderer","TweenMax","TweenLite","TimelineLite","TimelineMax","_dispatch","_emptyArray","_onMediaChange","matches","_lastMediaTime","_media","anyMatch","toggled","queries","conditions","matchMedia","onMatch","_contextID","Context","prevSelector","_r","isReverted","ignore","getTweens","_this4","o","MatchMedia","mq","active","cond","contexts","addListener","addEventListener","registerPlugin","args","getProperty","unit","uncache","getter","format","quickSetter","setters","quickTo","isTweening","registerEffect","effect","plugins","extendTimeline","pluginName","registerEase","parseEase","exportRoot","includeDelayedCalls","matchMediaRefresh","found","removeEventListener","utils","wrap","range","wrapYoyo","total","normalize","clamp","pipe","functions","reduce","unitize","interpolate","mutate","interpolators","il","isString","master","install","effects","ticker","globalTimeline","core","globals","getCache","reverting","toAdd","suppressOverwrites","_getPluginPropTween","_buildModifierPlugin","temp","_addModifiers","modifiers","_renderCSSProp","_renderPropWithEnd","_renderCSSPropWithBeginning","_renderRoundedCSSProp","_renderNonTweeningValue","_renderNonTweeningValueOnlyAtEnd","_setterCSSStyle","_setterCSSProp","setProperty","_setterTransform","_setterScale","scaleX","scaleY","_setterScaleWithRender","renderTransform","_setterTransformWithRender","_saveStyle","isNotCSS","_transformProps","tfm","_propertyAliases","transform","_get","_transformOriginProp","zOrigin","_transformProp","svg","svgo","_removeIndependentTransforms","translate","removeProperty","_revertStyle","_capsExp","_getStyleSaver","properties","saver","save","_createElement","ns","createElementNS","_getComputedProperty","skipPrefixFallback","cs","getComputedStyle","getPropertyValue","_checkPropPrefix","_initCore","_docElement","documentElement","_tempDiv","cssText","_supports3D","_pluginInitted","_getReparentedCloneBBox","bbox","owner","ownerSVGElement","clone","cloneNode","display","appendChild","getBBox","removeChild","_getAttributeFallbacks","attributesArray","hasAttribute","_getBBox","bounds","cloned","error","width","height","_isSVG","getCTM","parentNode","_removeProperty","first2Chars","removeAttribute","_addNonTweeningPT","beginning","onlySetAtEnd","_convertToUnit","px","isSVG","curValue","curUnit","horizontal","_horizontalExp","isRootSVG","tagName","measureProperty","toPixels","toPercent","_nonConvertibleUnits","body","_nonStandardLayouts","_tweenComplexCSSString","startValues","startValue","endValue","endUnit","startUnit","_convertKeywordsToPercentages","_keywordToPercent","_renderClearProps","clearTransforms","scale","rotate","_parseTransform","_isNullTransform","_getComputedTransformMatrixAsArray","matrixString","_identity2DMatrix","_getMatrix","force2D","nextSibling","addedToDOM","matrix","baseVal","consolidate","offsetParent","nextElementSibling","insertBefore","_applySVGOrigin","origin","originIsAbsolute","smooth","matrixArray","pluginToAddPropTweensTo","determinant","xOriginOld","xOrigin","yOriginOld","yOrigin","xOffsetOld","xOffset","yOffsetOld","yOffset","tx","ty","originSplit","_addPxTranslate","_addRotationalPropTween","direction","cap","_RAD2DEG","finalValue","_assign","source","_addRawTransformPTs","transforms","endCache","startCache","_recentSetterPlugin","Power0","Power1","Power2","Power3","Power4","Quad","Cubic","Quart","Quint","Strong","Elastic","Back","Bounce","Sine","Expo","Circ","_DEG2RAD","_atan2","atan2","_complexExp","autoAlpha","alpha","_prefixes","element","preferPrefix","deg","rad","turn","flex","_firstTwoOnly","_specialProps","top","bottom","right","clearProps","_rotationalProperties","z","rotation","rotationX","rotationY","skewX","skewY","perspective","angle","a12","a22","t1","t2","t3","a13","a23","a33","a42","a43","a32","invertedScaleX","forceCSS","xPercent","offsetWidth","yPercent","offsetHeight","transformPerspective","_renderSVGTransforms","_renderCSSTransforms","_renderNon3DTransforms","_zeroDeg","_zeroPx","_endParenthesis","use3D","a11","a21","tan","side","positionAndScale","all","CSSPlugin","specialProp","relative","isTransformRelated","transformPropTween","inlineProps","styles","visibility","parseTransform","smoothOrigin","autoRound","checkPrefix","getStyleSaver","gsapWithCSS","TweenMaxWithCSS"],"mappings":";;;;;;;;;ycAgCa,SAAZA,EAAYC,SAA2B,iBAAXA,EACd,SAAdC,EAAcD,SAA2B,mBAAXA,EAClB,SAAZE,EAAYF,SAA2B,iBAAXA,EACb,SAAfG,EAAeH,eAA2B,IAAXA,EACnB,SAAZI,EAAYJ,SAA2B,iBAAXA,EACd,SAAdK,EAAcL,UAAmB,IAAVA,EACP,SAAhBM,UAAyC,oBAAZC,OACX,SAAlBC,EAAkBR,UAASC,EAAYD,IAAUD,EAAUC,GAchD,SAAXS,EAAWC,UAAUC,EAAgBC,GAAOF,EAAOG,MAAcC,GAChD,SAAjBC,EAAkBC,EAAUhB,UAAUiB,QAAQC,KAAK,mBAAoBF,EAAU,SAAUhB,EAAO,yCAC1F,SAARmB,EAASC,EAASC,UAAcA,GAAYJ,QAAQC,KAAKE,GAC5C,SAAbE,EAAcC,EAAMC,UAASD,IAASV,GAASU,GAAQC,IAASb,IAAkBA,EAAcY,GAAQC,IAAUX,GACrG,SAAbY,WAAmB,EAaR,SAAXC,GAAWC,OAETC,EAAeC,EADZC,EAASH,EAAQ,MAErBvB,EAAU0B,IAAW7B,EAAY6B,KAAYH,EAAU,CAACA,MAClDC,GAAiBE,EAAOC,OAAS,IAAIC,SAAU,KACpDH,EAAII,GAAgBC,OACbL,MAAQI,GAAgBJ,GAAGM,WAAWL,KAC7CF,EAAgBK,GAAgBJ,OAEjCA,EAAIF,EAAQO,OACLL,KACLF,EAAQE,KAAOF,EAAQE,GAAGE,QAAUJ,EAAQE,GAAGE,MAAQ,IAAIK,GAAQT,EAAQE,GAAID,MAAqBD,EAAQU,OAAOR,EAAG,UAEjHF,EAEI,SAAZW,GAAYR,UAAUA,EAAOC,OAASL,GAASa,GAAQT,IAAS,GAAGC,MACpD,SAAfS,GAAgBV,EAAQd,EAAUyB,UAAOA,EAAIX,EAAOd,KAAcf,EAAYwC,GAAKX,EAAOd,KAAeb,EAAasC,IAAMX,EAAOY,cAAgBZ,EAAOY,aAAa1B,IAAcyB,EACtK,SAAfE,GAAgBC,EAAOC,UAAWD,EAAQA,EAAME,MAAM,MAAMC,QAAQF,IAAUD,EACrE,SAATI,GAAShD,UAASiD,KAAKC,MAAc,IAARlD,GAAkB,KAAU,EACzC,SAAhBmD,GAAgBnD,UAASiD,KAAKC,MAAc,IAARlD,GAAoB,KAAY,EACnD,SAAjBoD,GAAkBC,EAAOrD,OACpBsD,EAAWtD,EAAMuD,OAAO,GAC3BC,EAAMC,WAAWzD,EAAM0D,OAAO,WAC/BL,EAAQI,WAAWJ,GACC,MAAbC,EAAmBD,EAAQG,EAAmB,MAAbF,EAAmBD,EAAQG,EAAmB,MAAbF,EAAmBD,EAAQG,EAAMH,EAAQG,EAE/F,SAApBG,GAAqBC,EAAUC,WAC1BC,EAAID,EAAO3B,OACdL,EAAI,EACE+B,EAASG,QAAQF,EAAOhC,IAAM,KAAOA,EAAIiC,WACxCjC,EAAIiC,EAEC,SAAdE,SAGEnC,EAAGoC,EAFAH,EAAII,GAAYhC,OACnBiC,EAAID,GAAYE,MAAM,OAEvBC,GAAc,GAETxC,EADLqC,GAAYhC,OAAS,EACTL,EAAIiC,EAAGjC,KAClBoC,EAAQE,EAAEtC,KACDoC,EAAMK,QAAUL,EAAMM,OAAON,EAAMK,MAAM,GAAIL,EAAMK,MAAM,IAAI,GAAMA,MAAQ,GAGpE,SAAlBE,GAAmBC,EAAWC,EAAMC,EAAgBC,GACnDV,GAAYhC,SAAW2C,GAAcb,KACrCS,EAAUF,OAAOG,EAAMC,EAAgBC,GAAUC,GAAcH,EAAO,IAAMD,EAAUK,UAAYL,EAAUM,WAC5Gb,GAAYhC,SAAW2C,GAAcb,KAEjB,SAArBgB,GAAqBhF,OAChBiF,EAAIxB,WAAWzD,UACXiF,GAAW,IAANA,KAAajF,EAAQ,IAAIkF,MAAMC,IAAoBjD,OAAS,EAAI+C,EAAIlF,EAAUC,GAASA,EAAMoF,OAASpF,EAErG,SAAfqF,GAAeC,UAAKA,EACL,SAAfC,GAAgB/D,EAAKgE,OACf,IAAIF,KAAKE,EACZF,KAAK9D,IAASA,EAAI8D,GAAKE,EAASF,WAE3B9D,EAaK,SAAbiE,GAAcC,EAAMC,OACd,IAAIL,KAAKK,EACP,cAANL,GAA2B,gBAANA,GAA6B,cAANA,IAAsBI,EAAKJ,GAAKlF,EAAUuF,EAAQL,IAAMG,GAAWC,EAAKJ,KAAOI,EAAKJ,GAAK,IAAKK,EAAQL,IAAMK,EAAQL,WAE1JI,EAES,SAAjBE,GAAkBpE,EAAKqE,OAErBP,EADGQ,EAAO,OAENR,KAAK9D,EACR8D,KAAKO,IAAeC,EAAKR,GAAK9D,EAAI8D,WAE7BQ,EAEW,SAAnBC,GAAmBC,OACdC,EAASD,EAAKC,QAAUC,EAC3BrD,EAAOmD,EAAKG,UA3BS,SAAvBC,qBAAuBC,UAAmB,SAAC7E,EAAKgE,OAC1C,IAAIF,KAAKE,EACZF,KAAK9D,GAAe,aAAN8D,GAAoBe,GAA0B,SAANf,IAAiB9D,EAAI8D,GAAKE,EAASF,KAyBlEc,CAAqBE,EAASN,EAAKG,YAAcZ,MACtElF,EAAY2F,EAAKO,cACbN,GACNpD,EAAKmD,EAAMC,EAAOD,KAAKR,UACvBS,EAASA,EAAOA,QAAUA,EAAOO,WAG5BR,EAQa,SAArBS,GAAsBR,EAAQS,EAAOC,EAAsBC,EAAoBC,YAA1CF,IAAAA,EAAY,mBAAUC,IAAAA,EAAW,aAEpEE,EADGC,EAAOd,EAAOW,MAEdC,MACHC,EAAIJ,EAAMG,GACHE,GAAQA,EAAKF,GAAUC,GAC7BC,EAAOA,EAAKC,aAGVD,GACHL,EAAMO,MAAQF,EAAKE,MACnBF,EAAKE,MAAQP,IAEbA,EAAMO,MAAQhB,EAAOU,GACrBV,EAAOU,GAAaD,GAEjBA,EAAMO,MACTP,EAAMO,MAAMD,MAAQN,EAEpBT,EAAOW,GAAYF,EAEpBA,EAAMM,MAAQD,EACdL,EAAMT,OAASS,EAAMF,IAAMP,EACpBS,EAEgB,SAAxBQ,GAAyBjB,EAAQS,EAAOC,EAAsBC,YAAtBD,IAAAA,EAAY,mBAAUC,IAAAA,EAAW,aACpEG,EAAOL,EAAMM,MAChBG,EAAOT,EAAMO,MACVF,EACHA,EAAKE,MAAQE,EACHlB,EAAOU,KAAeD,IAChCT,EAAOU,GAAaQ,GAEjBA,EACHA,EAAKH,MAAQD,EACHd,EAAOW,KAAcF,IAC/BT,EAAOW,GAAYG,GAEpBL,EAAMO,MAAQP,EAAMM,MAAQN,EAAMT,OAAS,KAExB,SAApBmB,GAAqBV,EAAOW,GAC3BX,EAAMT,UAAYoB,GAA6BX,EAAMT,OAAOqB,qBAAuBZ,EAAMT,OAAOsB,QAAUb,EAAMT,OAAOsB,OAAOb,GAC9HA,EAAMc,KAAO,EAEH,SAAXC,GAAYhD,EAAWiC,MAClBjC,KAAeiC,GAASA,EAAMgB,KAAOjD,EAAUkD,MAAQjB,EAAMkB,OAAS,WACrEzD,EAAIM,EACDN,GACNA,EAAE0D,OAAS,EACX1D,EAAIA,EAAE8B,cAGDxB,EAWS,SAAjBqD,GAAkB7D,EAAO8D,EAAWpD,EAAgBC,UAAUX,EAAMc,WAAaF,EAAaZ,EAAMc,SAASiD,OAAOC,IAAwBhE,EAAM+B,KAAKkC,kBAAoBjE,EAAM+B,KAAKmC,YAAelE,EAAMc,SAASR,OAAOwD,GAAW,EAAMnD,IAEpN,SAAxBwD,GAAwB3D,UAAaA,EAAU4D,QAAUC,GAAgB7D,EAAU8D,OAAS9D,EAAYA,EAAU+D,WAAa/D,EAAUgE,SAAYhE,EAAY,EAMvI,SAA1BiE,GAA2BC,EAAYjC,UAAWiC,EAAajC,EAAMkB,QAAUlB,EAAMkC,KAAoB,GAAblC,EAAMkC,IAAW,EAAKlC,EAAMmB,OAASnB,EAAMmC,gBAAkBnC,EAAMoC,OACrJ,SAAVC,GAAUtE,UAAcA,EAAUiD,KAAOvE,GAAcsB,EAAUmD,QAAWnD,EAAUqE,MAAQ7F,KAAK+F,IAAIvE,EAAUmE,KAAOnE,EAAUwE,MAAQC,IAAc,IACvI,SAAjBC,GAAkB1E,EAAWsD,OACxB9B,EAASxB,EAAU+B,WACnBP,GAAUA,EAAOmD,mBAAqB3E,EAAUmE,MACnDnE,EAAUmD,OAASzE,GAAc8C,EAAOoD,OAAyB,EAAhB5E,EAAUmE,IAAUb,EAAYtD,EAAUmE,MAAQnE,EAAUoD,OAASpD,EAAUoE,gBAAkBpE,EAAUqE,OAASf,IAActD,EAAUmE,MAC7LG,GAAQtE,GACRwB,EAAO4B,QAAUJ,GAASxB,EAAQxB,IAE5BA,EAYS,SAAjB6E,GAAkBC,EAAU7C,OACvBI,MACAJ,EAAM2C,QAAW3C,EAAMiB,MAAQjB,EAAM5B,UAAc4B,EAAMkB,OAAS2B,EAASF,QAAU3C,EAAMiB,OAASjB,EAAM8C,QAC7G1C,EAAI4B,GAAwBa,EAASE,UAAW/C,KAC3CA,EAAMiB,MAAQ+B,GAAO,EAAGhD,EAAMmC,gBAAiB/B,GAAKJ,EAAM6B,OAASW,IACvExC,EAAMnC,OAAOuC,GAAG,IAIdW,GAAS8B,EAAU7C,GAAOF,KAAO+C,EAASzE,UAAYyE,EAASF,OAASE,EAAS5B,MAAQ4B,EAASX,IAAK,IAEtGW,EAAS5B,KAAO4B,EAASf,eAC5B1B,EAAIyC,EACGzC,EAAEN,KACQ,GAAfM,EAAE2C,WAAmB3C,EAAEiB,UAAUjB,EAAEyB,QACpCzB,EAAIA,EAAEN,IAGR+C,EAASI,QAAUT,GAGJ,SAAjBU,GAAkBL,EAAU7C,EAAOmD,EAAUC,UAC5CpD,EAAMT,QAAUmB,GAAkBV,GAClCA,EAAMkB,OAASzE,IAAejD,EAAU2J,GAAYA,EAAWA,GAAYN,IAAarD,EAAkB6D,GAAeR,EAAUM,EAAUnD,GAAS6C,EAASF,OAAS3C,EAAMsD,QAC9KtD,EAAMgB,KAAOvE,GAAcuD,EAAMkB,QAAWlB,EAAMmC,gBAAkB5F,KAAK+F,IAAItC,EAAMuD,cAAiB,IACpGxD,GAAmB8C,EAAU7C,EAAO,SAAU,QAAS6C,EAASW,MAAQ,SAAW,GACnFC,GAAmBzD,KAAW6C,EAASa,QAAU1D,GACjDoD,GAAcR,GAAeC,EAAU7C,GACvC6C,EAASX,IAAM,GAAKO,GAAeI,EAAUA,EAAShB,QAC/CgB,EAES,SAAjBc,GAAkB5F,EAAW6F,UAAazJ,GAAS0J,eAAiBxJ,EAAe,gBAAiBuJ,KAAazJ,GAAS0J,cAAcC,OAAOF,EAAS7F,GACpI,SAApBgG,GAAqBxG,EAAOS,EAAME,EAAOD,EAAgB+F,UACxDC,GAAW1G,EAAOS,EAAMgG,GACnBzG,EAAMa,UAGNF,GAASX,EAAM2G,MAAQ/F,IAAgBZ,EAAM0D,OAA4B,IAApB1D,EAAM+B,KAAK6E,OAAqB5G,EAAM0D,MAAQ1D,EAAM+B,KAAK6E,OAAUC,IAAuBC,GAAQC,OAC3J9G,GAAY+G,KAAKhH,GACjBA,EAAMK,MAAQ,CAACoG,EAAO/F,GACf,UALA,EA2EM,SAAfuG,GAAgBzG,EAAW+D,EAAU2C,EAAaC,OAC7CC,EAAS5G,EAAU4D,QACtBiD,EAAMnI,GAAcqF,IAAa,EACjC+C,EAAgB9G,EAAU8D,OAAS9D,EAAUqE,aAC9CyC,IAAkBH,IAAkB3G,EAAU4E,OAASiC,EAAM7G,EAAUkD,MACvElD,EAAUkD,KAAO2D,EACjB7G,EAAUqE,MAASuC,EAAeA,EAAS,EAAI,KAAOlI,GAAcmI,GAAOD,EAAS,GAAM5G,EAAUgE,QAAU4C,GAAlFC,EACZ,EAAhBC,IAAsBH,GAAiBjC,GAAe1E,EAAYA,EAAU8D,OAAS9D,EAAUqE,MAAQyC,GACvG9G,EAAUwB,QAAU8C,GAAQtE,GAC5B0G,GAAe1D,GAAShD,EAAUwB,OAAQxB,GACnCA,EAEiB,SAAzB+G,GAAyB/G,UAAcA,aAAqBgH,GAAYhE,GAAShD,GAAayG,GAAazG,EAAWA,EAAUkD,MA2B7G,SAAnB+D,GAAoBC,EAAMC,EAAQrC,OAIhCsC,EAAQ5F,EAHL6F,EAAW5L,EAAU0L,EAAO,IAC/BG,GAAaD,EAAW,EAAI,IAAMH,EAAO,EAAI,EAAI,GACjD3F,EAAO4F,EAAOG,MAEfD,IAAa9F,EAAKwC,SAAWoD,EAAO,IACpC5F,EAAKC,OAASsD,EACVoC,EAAM,KACTE,EAAS7F,EACTC,EAASsD,EACFtD,KAAY,oBAAqB4F,IACvCA,EAAS5F,EAAOD,KAAKR,UAAY,GACjCS,EAAS5F,EAAY4F,EAAOD,KAAKO,UAAYN,EAAOA,OAErDD,EAAKkC,gBAAkB7H,EAAYwL,EAAO3D,iBAC1CyD,EAAO,EAAK3F,EAAKgG,aAAe,EAAMhG,EAAKiG,QAAUL,EAAOG,EAAY,UAElE,IAAIG,GAAMN,EAAO,GAAI5F,EAAM4F,EAAmB,EAAZG,IAErB,SAArBI,GAAsBnM,EAAO6C,UAAS7C,GAAmB,IAAVA,EAAc6C,EAAK7C,GAAS6C,EAEjE,SAAVuJ,GAAWpM,EAAOyC,UAAO1C,EAAUC,KAAYyC,EAAI4J,GAASC,KAAKtM,IAAeyC,EAAE,GAAP,GAG5D,SAAf8J,GAAgBvM,EAAOwM,UAAaxM,GAAUI,EAAUJ,IAAU,WAAYA,KAAYwM,IAAaxM,EAAMkC,QAAalC,EAAMkC,OAAS,KAAMlC,GAASI,EAAUJ,EAAM,OAAUA,EAAMyM,UAAYzM,IAAU0M,EAInM,SAAXC,GAAW3M,UACVA,EAAQuC,GAAQvC,GAAO,IAAMmB,EAAM,kBAAoB,GAChD,SAAAsB,OACFmK,EAAK5M,EAAM6M,SAAW7M,EAAM8M,eAAiB9M,SAC1CuC,GAAQE,EAAGmK,EAAGG,iBAAmBH,EAAKA,IAAO5M,EAAQmB,EAAM,kBAAoB6L,EAAKC,cAAc,OAASjN,IAG1G,SAAVkN,GAAU/I,UAAKA,EAAEgJ,KAAK,iBAAM,GAAKlK,KAAKmK,WAEzB,SAAbC,GAAa5K,MACRxC,EAAYwC,UACRA,MAEJuD,EAAO5F,EAAUqC,GAAKA,EAAI,CAAC6K,KAAK7K,GACnC8K,EAAOC,GAAWxH,EAAKuH,MACvBE,EAAOzH,EAAKyH,MAAQ,EACpB/H,EAAOjC,WAAWuC,EAAKN,OAAS,EAChCgI,EAAQ,GACRC,EAAoB,EAAPF,GAAYA,EAAO,EAChCG,EAASC,MAAMJ,IAASE,EACxBG,EAAO9H,EAAK8H,KACZC,EAASN,EACTO,EAASP,SACN1N,EAAU0N,GACbM,EAASC,EAAS,CAACC,OAAO,GAAIC,MAAM,GAAI1K,IAAI,GAAGiK,IAAS,GAC7CE,GAAaC,IACxBG,EAASN,EAAK,GACdO,EAASP,EAAK,IAER,SAAC5L,EAAGC,EAAQqC,OAGjBgK,EAASC,EAASC,EAAGC,EAAGC,EAAGC,EAAGC,EAAKC,EAAKC,EAFrC7K,GAAKK,GAAK6B,GAAM9D,OACnB0M,EAAYlB,EAAM5J,OAEd8K,EAAW,MACfD,EAAwB,SAAd3I,EAAK6I,KAAmB,GAAK7I,EAAK6I,MAAQ,CAAC,EAAGC,IAAU,IACrD,KACZL,GAAOK,EACAL,GAAOA,EAAMtK,EAAEwK,KAAUI,wBAAwBC,OAASL,EAAS7K,IAC1E6K,EAAS7K,GAAK6K,QAEfC,EAAYlB,EAAM5J,GAAK,GACvBqK,EAAUP,EAAU3K,KAAKyL,IAAIC,EAAQ7K,GAAKiK,EAAU,GAAKN,EAAOkB,EAChEP,EAAUO,IAAWG,EAAU,EAAIlB,EAAS9J,EAAIkK,EAASW,EAAS,GAAMlB,EAAOkB,EAAU,EAEzFD,EAAMI,EACDN,EAFLC,EAAM,EAEMD,EAAI1K,EAAG0K,IAClBH,EAAKG,EAAIG,EAAUR,EACnBG,EAAIF,GAAYI,EAAIG,EAAU,GAC9BC,EAAUJ,GAAKD,EAAKT,EAA8B7K,KAAK+F,IAAc,MAAT8E,EAAgBQ,EAAID,GAArDY,EAAMZ,EAAIA,EAAIC,EAAIA,GACxCG,EAAJF,IAAaE,EAAMF,GACnBA,EAAIG,IAASA,EAAMH,GAEX,WAATd,GAAsBP,GAAQ0B,GAC/BA,EAAUH,IAAMA,EAAMC,EACtBE,EAAUF,IAAMA,EAChBE,EAAUnM,EAAIqB,GAAKL,WAAWuC,EAAKkJ,SAAYzL,WAAWuC,EAAKsH,OAAkBxJ,EAAT6K,EAAa7K,EAAI,EAAKgK,EAA+C,MAATA,EAAehK,EAAI6K,EAASA,EAA3D1L,KAAKwL,IAAIE,EAAQ7K,EAAI6K,KAAkD,IAAe,UAATlB,GAAoB,EAAI,GAC1MmB,EAAUO,EAAKrL,EAAI,EAAK4B,EAAO5B,EAAI4B,EACnCkJ,EAAUQ,EAAIhD,GAAQpG,EAAKkJ,QAAUlJ,EAAKsH,OAAS,EACnDC,EAAQA,GAAQzJ,EAAI,EAAKuL,GAAY9B,GAAQA,SAE9CzJ,GAAM8K,EAAU/M,GAAK+M,EAAUF,KAAOE,EAAUH,KAAQ,EACjDtL,GAAcyL,EAAUO,GAAK5B,EAAOA,EAAKzJ,GAAKA,GAAK8K,EAAUnM,GAAKmM,EAAUQ,GAGpE,SAAjBE,GAAiB7M,OACZ6C,EAAIrC,KAAKsM,IAAI,KAAM9M,EAAI,IAAIK,MAAM,KAAK,IAAM,IAAIZ,eAC7C,SAAAsN,OACFvK,EAAI9B,GAAcF,KAAKC,MAAMO,WAAW+L,GAAO/M,GAAKA,EAAI6C,UACpDL,EAAIA,EAAI,GAAKK,GAAKpF,EAAUsP,GAAO,EAAIpD,GAAQoD,KAGlD,SAAPC,GAAQC,EAAQ1P,OAEd2P,EAAQC,EADLC,EAAUvJ,EAASoJ,UAElBG,GAAWzP,EAAUsP,KACzBC,EAASE,EAAUH,EAAOC,QAAUb,EAChCY,EAAOI,QACVJ,EAASnN,GAAQmN,EAAOI,SACnBF,GAAQ1P,EAAUwP,EAAO,OAC7BC,GAAUA,IAGXD,EAASJ,GAAeI,EAAOK,YAG1B5D,GAAmBnM,EAAQ6P,EAAmC5P,EAAYyP,GAAU,SAAAF,UAAQI,EAAOF,EAAOF,GAAavM,KAAK+F,IAAI4G,EAAOJ,IAAQG,EAASC,EAAOJ,GAAS,SAAAA,WAM7KQ,EAAIC,EALD5B,EAAI5K,WAAWmM,EAAOJ,EAAInB,EAAImB,GACjClB,EAAI7K,WAAWmM,EAAOJ,EAAIlB,EAAI,GAC9BI,EAAMI,EACNoB,EAAU,EACVrO,EAAI6N,EAAOxN,OAELL,MAILmO,EAHGJ,GACHI,EAAKN,EAAO7N,GAAGwM,EAAIA,GAET2B,GADVC,EAAKP,EAAO7N,GAAGyM,EAAIA,GACC2B,EAEfhN,KAAK+F,IAAI0G,EAAO7N,GAAKwM,IAElBK,IACRA,EAAMsB,EACNE,EAAUrO,UAGZqO,GAAYP,GAAUjB,GAAOiB,EAAUD,EAAOQ,GAAWV,EACjDI,GAAQM,IAAYV,GAAOtP,EAAUsP,GAAQU,EAAUA,EAAU9D,GAAQoD,IArBtCF,GAAeI,IAwBnD,SAATtC,GAAUsB,EAAKD,EAAK0B,EAAmBC,UAAmBjE,GAAmB7F,EAASoI,IAAQD,GAA4B,IAAtB0B,KAAgCA,EAAoB,IAAMC,EAAgB,kBAAM9J,EAASoI,GAAOA,KAAOzL,KAAKmK,SAAWsB,EAAIxM,UAAYiO,EAAoBA,GAAqB,QAAUC,EAAiBD,EAAoB,WAAI,IAAQA,EAAoB,IAAIjO,OAAS,GAAK,IAAOe,KAAKoN,MAAMpN,KAAKC,OAAOwL,EAAMyB,EAAoB,EAAIlN,KAAKmK,UAAYqB,EAAMC,EAA0B,IAApByB,IAA4BA,GAAqBA,EAAoBC,GAAkBA,IAIxhB,SAAbE,GAAcnM,EAAGoM,EAASvQ,UAAUmM,GAAmBnM,EAAO,SAAAwQ,UAASrM,IAAIoM,EAAQC,MAalE,SAAjBC,GAAiBzQ,WAGf6B,EAAG6O,EAAMlN,EAAKqM,EAFX9I,EAAO,EACV4J,EAAI,KAEI9O,EAAI7B,EAAM+D,QAAQ,UAAWgD,KACrCvD,EAAMxD,EAAM+D,QAAQ,IAAKlC,GACzBgO,EAAkC,MAAxB7P,EAAMuD,OAAO1B,EAAI,GAC3B6O,EAAO1Q,EAAM0D,OAAO7B,EAAI,EAAG2B,EAAM3B,EAAI,GAAGqD,MAAM2K,EAAU1K,GAAqByL,IAC7ED,GAAK3Q,EAAM0D,OAAOqD,EAAMlF,EAAIkF,GAAQqG,GAAOyC,EAAUa,GAAQA,EAAK,GAAIb,EAAU,GAAKa,EAAK,IAAKA,EAAK,IAAM,MAC1G3J,EAAOvD,EAAM,SAEPmN,EAAI3Q,EAAM0D,OAAOqD,EAAM/G,EAAMkC,OAAS6E,GA4CvB,SAAvB8J,GAAwBtH,EAAUuH,EAAUC,OAG1CzL,EAAG0L,EAAUC,EAFVC,EAAS3H,EAAS2H,OACrBxC,EAAMI,MAEFxJ,KAAK4L,GACTF,EAAWE,EAAO5L,GAAKwL,GACP,KAASC,GAAYC,GAAYtC,GAAOsC,EAAW/N,KAAK+F,IAAIgI,MAC3EC,EAAQ3L,EACRoJ,EAAMsC,UAGDC,EAmBK,SAAbE,GAAa1M,UACZ2C,GAAkB3C,GAClBA,EAAU2M,eAAiB3M,EAAU2M,cAAcC,OAAOxM,GAC1DJ,EAAU6M,WAAa,GAAKC,GAAU9M,EAAW,eAC1CA,EAIQ,SAAhB+M,GAAgBC,MACVA,KACLA,GAAWA,EAAOlQ,MAAQkQ,WAAmBA,EACzCnR,KAAmBmR,EAAOC,SAAU,KACnCnQ,EAAOkQ,EAAOlQ,KACjBoQ,EAAS1R,EAAYwR,GACrBG,EAAUrQ,IAASoQ,GAAUF,EAAOI,KAAQ,gBACtCC,OAAS,IACXL,EACJM,EAAmB,CAACF,KAAMpQ,EAAY8C,OAAQyN,GAAmBxI,IAAKyI,GAAeZ,KAAMa,GAAmBC,SAAUC,GAAoBC,QAAS,GACrJC,EAAU,CAACnQ,WAAY,EAAGoQ,IAAK,EAAGC,UAAWC,GAAYC,QAAS,GAAIC,SAAU,MACjFC,KACInB,IAAWG,EAAQ,IAClBiB,GAAStR,UAGbgE,GAAaqM,EAAQrM,GAAaK,GAAe6L,EAAQM,GAAmBO,IAC5E1R,GAAOgR,EAAOkB,UAAWlS,GAAOmR,EAAkBnM,GAAe6L,EAAQa,KACzEO,GAAUjB,EAAOmB,KAAOxR,GAASqQ,EAC7BH,EAAOtP,aACVF,GAAgBgJ,KAAK2G,GACrBoB,GAAezR,GAAQ,GAExBA,GAAiB,QAATA,EAAiB,MAAQA,EAAKgC,OAAO,GAAG0P,cAAgB1R,EAAKmC,OAAO,IAAM,SAEnFpC,EAAWC,EAAMqQ,GACjBH,EAAOkB,UAAYlB,EAAOkB,SAAS7R,GAAM8Q,EAAQsB,SAEjDC,GAAqBlI,KAAKwG,GAkDrB,SAAP2B,GAAQC,EAAGC,EAAIC,UAEC,GADfF,GAAKA,EAAI,EAAI,EAAQ,EAAJA,GAAS,EAAI,GACX,EAAKC,GAAMC,EAAKD,GAAMD,EAAI,EAAIA,EAAI,GAAKE,EAAU,EAAJF,EAAQ,EAAKC,GAAMC,EAAKD,IAAO,EAAI,EAAID,GAAK,EAAIC,GAAME,GAAQ,GAAM,EAExH,SAAbC,GAAchR,EAAGiR,EAAOC,OAEtBC,EAAGC,EAAG1E,EAAGkE,EAAG1C,EAAG7M,EAAG2K,EAAKC,EAAKH,EAAGuF,EAD5B3P,EAAK1B,EAAyBvC,EAAUuC,GAAK,CAACA,GAAK,GAAKA,GAAK,EAAK+Q,GAAM/Q,EAAI+Q,IAAQ,EAA3EO,GAAaC,UAErB7P,EAAG,IACc,MAAjB1B,EAAEiB,QAAQ,KACbjB,EAAIA,EAAEiB,OAAO,EAAGjB,EAAEP,OAAS,IAExB6R,GAAatR,GAChB0B,EAAI4P,GAAatR,QACX,GAAoB,MAAhBA,EAAEc,OAAO,GAAY,IAC3Bd,EAAEP,OAAS,IAIdO,EAAI,KAHJmR,EAAInR,EAAEc,OAAO,IAGCqQ,GAFdC,EAAIpR,EAAEc,OAAO,IAESsQ,GADtB1E,EAAI1M,EAAEc,OAAO,IACiB4L,GAAkB,IAAb1M,EAAEP,OAAeO,EAAEc,OAAO,GAAKd,EAAEc,OAAO,GAAK,KAEhE,IAAbd,EAAEP,aAEE,EADPiC,EAAI8P,SAASxR,EAAEiB,OAAO,EAAG,GAAI,MAChB,GAAKS,GAAK,EAAKqP,GAAMrP,EAAIqP,GAAMS,SAASxR,EAAEiB,OAAO,GAAI,IAAM,KAGzES,EAAI,EADJ1B,EAAIwR,SAASxR,EAAEiB,OAAO,GAAI,MAChB,GAAKjB,GAAK,EAAK+Q,GAAM/Q,EAAI+Q,SAC7B,GAAuB,QAAnB/Q,EAAEiB,OAAO,EAAG,MACtBS,EAAI2P,EAASrR,EAAEyC,MAAM0L,IAChB8C,GAUE,IAAKjR,EAAEsB,QAAQ,YACrBI,EAAI1B,EAAEyC,MAAMgP,IACZP,GAAcxP,EAAEjC,OAAS,IAAMiC,EAAE,GAAK,GAC/BA,OAZPkP,GAAMlP,EAAE,GAAK,IAAO,IACpBwM,EAAKxM,EAAE,GAAK,IAGZyP,EAAQ,GAFR9P,EAAKK,EAAE,GAAK,MACZ0P,EAAK/P,GAAK,GAAMA,GAAK6M,EAAI,GAAK7M,EAAI6M,EAAI7M,EAAI6M,GAE/B,EAAXxM,EAAEjC,SAAeiC,EAAE,IAAM,GACzBA,EAAE,GAAKiP,GAAKC,EAAI,EAAI,EAAGO,EAAGC,GAC1B1P,EAAE,GAAKiP,GAAKC,EAAGO,EAAGC,GAClB1P,EAAE,GAAKiP,GAAKC,EAAI,EAAI,EAAGO,EAAGC,QAO3B1P,EAAI1B,EAAEyC,MAAM0L,KAAkBmD,GAAaI,YAE5ChQ,EAAIA,EAAEiQ,IAAIC,eAEPX,IAAUI,IACbF,EAAIzP,EAAE,GAAKqP,GACXK,EAAI1P,EAAE,GAAKqP,GACXrE,EAAIhL,EAAE,GAAKqP,GAGX1P,IAFA2K,EAAMxL,KAAKwL,IAAImF,EAAGC,EAAG1E,KACrBT,EAAMzL,KAAKyL,IAAIkF,EAAGC,EAAG1E,KACH,EACdV,IAAQC,EACX2E,EAAI1C,EAAI,GAERpC,EAAIE,EAAMC,EACViC,EAAQ,GAAJ7M,EAAUyK,GAAK,EAAIE,EAAMC,GAAOH,GAAKE,EAAMC,GAC/C2E,EAAI5E,IAAQmF,GAAKC,EAAI1E,GAAKZ,GAAKsF,EAAI1E,EAAI,EAAI,GAAKV,IAAQoF,GAAK1E,EAAIyE,GAAKrF,EAAI,GAAKqF,EAAIC,GAAKtF,EAAI,EAC5F8E,GAAK,IAENlP,EAAE,MAAQkP,EAAI,IACdlP,EAAE,MAAY,IAAJwM,EAAU,IACpBxM,EAAE,MAAY,IAAJL,EAAU,KAErB6P,GAAcxP,EAAEjC,OAAS,IAAMiC,EAAE,GAAK,GAC/BA,EAEU,SAAlBmQ,GAAkB7R,OACbqN,EAAS,GACZyE,EAAI,GACJ1S,GAAK,SACNY,EAAEK,MAAM0R,IAAWzR,QAAQ,SAAAN,OACtB0B,EAAI1B,EAAEyC,MAAMuP,KAAoB,GACpC3E,EAAO7E,WAAP6E,EAAe3L,GACfoQ,EAAEtJ,KAAKpJ,GAAKsC,EAAEjC,OAAS,KAExB4N,EAAOyE,EAAIA,EACJzE,EAEQ,SAAhB4E,GAAiB/D,EAAG+C,EAAOiB,OAKzBJ,EAAGK,EAAOrG,EAAGzK,EAJV+Q,EAAS,GACZC,GAAUnE,EAAIkE,GAAQ3P,MAAMsP,IAC5B7I,EAAO+H,EAAQ,QAAU,QACzB7R,EAAI,MAEAiT,SACGnE,KAERmE,EAASA,EAAOV,IAAI,SAAAW,UAAUA,EAAQtB,GAAWsB,EAAOrB,EAAO,KAAO/H,GAAQ+H,EAAQqB,EAAM,GAAK,IAAMA,EAAM,GAAK,KAAOA,EAAM,GAAK,KAAOA,EAAM,GAAKA,EAAMC,KAAK,MAAQ,MACrKL,IACHpG,EAAI+F,GAAgB3D,IACpB4D,EAAII,EAAeJ,GACbS,KAAKH,KAAYtG,EAAEgG,EAAES,KAAKH,QAE/B/Q,GADA8Q,EAAQjE,EAAEsE,QAAQT,GAAW,KAAK1R,MAAM2R,KAC9BvS,OAAS,EACZL,EAAIiC,EAAGjC,IACbgT,GAAUD,EAAM/S,KAAO0S,EAAExQ,QAAQlC,GAAKiT,EAAOI,SAAWvJ,EAAO,YAAc4C,EAAErM,OAASqM,EAAIuG,EAAO5S,OAAS4S,EAASH,GAAgBO,aAInIN,MAEJ9Q,GADA8Q,EAAQjE,EAAE7N,MAAM0R,KACNtS,OAAS,EACZL,EAAIiC,EAAGjC,IACbgT,GAAUD,EAAM/S,GAAKiT,EAAOjT,UAGvBgT,EAASD,EAAM9Q,GAWF,SAArBqR,GAAqBhR,OAEnBuP,EADG0B,EAAWjR,EAAE6Q,KAAK,QAEtBR,GAAUa,UAAY,EAClBb,GAAUc,KAAKF,UAClB1B,EAAQ6B,GAAQD,KAAKF,GACrBjR,EAAE,GAAKuQ,GAAcvQ,EAAE,GAAIuP,GAC3BvP,EAAE,GAAKuQ,GAAcvQ,EAAE,GAAIuP,EAAOY,GAAgBnQ,EAAE,MAC7C,EA2Je,SAAxBqR,GAAwBjU,OACnBuB,GAASvB,EAAO,IAAIuB,MAAM,KAC7ByK,EAAOkI,GAAS3S,EAAM,WACfyK,GAAuB,EAAfzK,EAAMZ,QAAcqL,EAAKkE,OAAUlE,EAAKkE,OAAOiE,MAAM,MAAOnU,EAAKwC,QAAQ,KAAO,CAzB1E,SAAvB4R,qBAAuB3V,WAMrBwQ,EAAOoF,EAAKC,EALTrU,EAAM,GACTsB,EAAQ9C,EAAM0D,OAAO,EAAG1D,EAAMkC,OAAO,GAAGY,MAAM,KAC9CgT,EAAMhT,EAAM,GACZjB,EAAI,EACJiC,EAAIhB,EAAMZ,OAEJL,EAAIiC,EAAGjC,IACb+T,EAAM9S,EAAMjB,GACZ2O,EAAQ3O,IAAMiC,EAAE,EAAI8R,EAAIG,YAAY,KAAOH,EAAI1T,OAC/C2T,EAAYD,EAAIlS,OAAO,EAAG8M,GAC1BhP,EAAIsU,GAAOjI,MAAMgI,GAAaA,EAAUZ,QAAQe,GAAY,IAAI5Q,QAAUyQ,EAC1EC,EAAMF,EAAIlS,OAAO8M,EAAM,GAAGpL,cAEpB5D,EAW0FmU,CAAqB7S,EAAM,KATvG,SAAtBmT,oBAAsBjW,OACjBkW,EAAOlW,EAAM+D,QAAQ,KAAO,EAC/BoS,EAAQnW,EAAM+D,QAAQ,KACtBqS,EAASpW,EAAM+D,QAAQ,IAAKmS,UACtBlW,EAAMqW,UAAUH,GAAOE,GAAUA,EAASD,EAAQnW,EAAM+D,QAAQ,IAAKoS,EAAQ,GAAKA,GAK0CF,CAAoB1U,GAAMuB,MAAM,KAAKsR,IAAIpP,KAAwByQ,GAASa,KAAOC,GAAejB,KAAK/T,GAASkU,GAASa,IAAI,GAAI/U,GAAQgM,EAItP,SAArBiJ,GAAsBjN,EAAUkN,WACFlJ,EAAzB7G,EAAQ6C,EAASmN,OACdhQ,GACFA,aAAiB+E,GACpB+K,GAAmB9P,EAAO+P,IAChB/P,EAAMV,KAAK2Q,UAAcjQ,EAAMkQ,OAAUlQ,EAAM2B,SAAY3B,EAAMkQ,QAAUH,IACjF/P,EAAM6C,SACTiN,GAAmB9P,EAAM6C,SAAUkN,IAEnClJ,EAAO7G,EAAMmQ,MACbnQ,EAAMmQ,MAAQnQ,EAAMoQ,OACpBpQ,EAAMoQ,OAASvJ,EACf7G,EAAMkQ,MAAQH,IAGhB/P,EAAQA,EAAMO,MAIF,SAAd8P,GAAenU,EAAOoU,EAAQC,EAAkCC,YAAlCD,IAAAA,EAAU,iBAAA3R,UAAK,EAAI0R,EAAO,EAAI1R,cAAI4R,IAAAA,EAAa,mBAAA5R,UAAKA,EAAI,GAAK0R,EAAW,EAAJ1R,GAAS,EAAI,EAAI0R,EAAiB,GAAT,EAAI1R,IAAU,QAEvI6R,EADG5J,EAAO,CAACyJ,OAAAA,EAAQC,QAAAA,EAASC,UAAAA,UAE7BvU,GAAaC,EAAO,SAAArB,OAGd,IAAI+D,KAFTmQ,GAASlU,GAAQV,GAASU,GAAQgM,EAClCkI,GAAU0B,EAAgB5V,EAAK6V,eAAkBH,EACnC1J,EACbkI,GAAS0B,GAAuB,WAAN7R,EAAiB,MAAc,YAANA,EAAkB,OAAS,WAAamQ,GAASlU,EAAO,IAAM+D,GAAKiI,EAAKjI,KAGtHiI,EAEY,SAApB8J,GAAoBJ,UAAY,SAAA3R,UAAKA,EAAI,IAAM,EAAI2R,EAAQ,EAAS,EAAJ3R,IAAW,EAAI,GAAK2R,EAAmB,GAAV3R,EAAI,KAAW,GAC3F,SAAjBgS,GAAkB3L,EAAM4L,EAAWC,GAIvB,SAAVP,GAAU3R,UAAW,IAANA,EAAU,EAAImS,WAAM,GAAO,GAAKnS,GAAMoS,GAAMpS,EAAIqS,GAAMC,GAAM,MAHxEH,EAAmB,GAAbF,EAAkBA,EAAY,EACvCK,GAAMJ,IAAW7L,EAAO,GAAK,OAAS4L,EAAY,EAAIA,EAAY,GAClEI,EAAKC,EAAKC,GAAQ5U,KAAK6U,KAAK,EAAIL,IAAO,GAEvClK,EAAiB,QAAT5B,EAAkBsL,GAAoB,OAATtL,EAAiB,SAAArG,UAAK,EAAI2R,GAAQ,EAAI3R,IAAK+R,GAAkBJ,WACnGW,EAAKC,EAAOD,EACZrK,EAAKkE,OAAS,SAAC8F,EAAWC,UAAWF,GAAe3L,EAAM4L,EAAWC,IAC9DjK,EAEM,SAAdwK,GAAepM,EAAMqM,GACN,SAAVf,GAAU3R,UAAKA,IAAQA,EAAKA,IAAM0S,EAAY,GAAK1S,EAAI0S,GAAa,EAAK,WADzDA,IAAAA,EAAY,aAE/BzK,EAAgB,QAAT5B,EAAiBsL,GAAmB,OAATtL,EAAgB,SAAArG,UAAK,EAAI2R,GAAQ,EAAI3R,IAAK+R,GAAkBJ,WAC/F1J,EAAKkE,OAAS,SAAAuG,UAAaD,GAAYpM,EAAMqM,IACtCzK,EAviCT,IAWC0K,EACApT,EAAYqT,EA0BZhS,EAAiBwG,EAAMyL,EAAcnL,EAErCrM,EACAyX,EAYAtN,EAilBAuN,EAyOAC,EAUEC,EAAKC,EAAMC,EAAMC,EAAOC,EAAQC,EAR7BC,EACHC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAqMDnU,EACGoU,EA9jCDC,EAAU,CACZC,UAAW,IACXC,QAAS,OACTC,eAAgB,EAChBC,MAAO,CAACC,WAAW,KAEpBC,EAAY,CACXpR,SAAU,GACVqR,WAAW,EACXC,MAAO,GAIRhL,EAAU,IACV5F,EAAW,EAAI4F,EACf+I,EAAiB,EAAV5U,KAAK8W,GACZC,EAAWnC,EAAO,EAClBoC,EAAQ,EACRhL,EAAQhM,KAAKiX,KACbC,EAAOlX,KAAKmX,IACZ1C,EAAOzU,KAAKoX,IASZC,EAAwC,mBAAhBC,aAA8BA,YAAYC,QAAW,aAC7ElU,EAAWmU,MAAM5K,QACjBe,GAAgB,oBAChBsD,GAAU,mCACVO,GAAkB,8BAClBiG,GAAuB,mCACvBC,GAAU,gBACVxV,GAAqB,kBACrBkH,GAAW,wCAEXxL,GAAW,GAQX+Z,GAAuB,CAACjW,gBAAgB,EAAMkW,SAAS,EAAMxJ,MAAM,GACnEpJ,GAAsB,CAACtD,gBAAgB,EAAM0M,MAAM,GACnDyJ,GAAgB,CAACnW,gBAAgB,GACjCqO,GAAiB,GACjB9O,GAAc,GACdG,GAAc,GAEdwO,GAAW,GACXkI,GAAW,GACXC,GAAe,GACf/Y,GAAkB,GAClBgZ,GAAiB,GAiEjBra,GAAS,SAATA,OAAU8E,EAAMC,OACV,IAAIL,KAAKK,EACbD,EAAKJ,GAAKK,EAAQL,UAEZI,GAoGR4C,GAAkB,SAAlBA,gBAAmBoC,EAAOwQ,OACrBC,EAAQlY,KAAKoN,MAAM3F,EAAQvH,GAAcuH,EAAQwQ,WAC9CxQ,GAAUyQ,IAAUzQ,EAASyQ,EAAQ,EAAIA,GAmEjDhR,GAAqB,SAArBA,0BAAuBiR,IAAAA,WAAmB,gBAATA,GAAmC,YAATA,GA+E3DC,GAAgB,CAACzT,OAAO,EAAG0T,QAAQ7Z,EAAYoH,cAAcpH,GAC7DsI,GAAiB,SAAjBA,eAAkBtF,EAAWoF,EAAU0R,OAIrC1Z,EAAG2Z,EAAQC,EAHRvK,EAASzM,EAAUyM,OACtBwK,EAASjX,EAAU2F,SAAWiR,GAC9BM,EAAkBlX,EAAU+D,YAAcsG,EAAU4M,EAAOJ,SAAQ,GAAS7W,EAAUkD,YAEnF5H,EAAU8J,KAAcgE,MAAMhE,IAAcA,KAAYqH,IAC3DsK,EAAS3R,EAAStG,OAAO,GACzBkY,EAAoC,MAAxB5R,EAASnG,QAAQ,GAC7B7B,EAAIgI,EAAS9F,QAAQ,KACN,MAAXyX,GAA6B,MAAXA,GAChB,GAAL3Z,IAAWgI,EAAWA,EAASoL,QAAQ,IAAK,MACzB,MAAXuG,EAAiBE,EAAO9T,OAAS8T,EAAOJ,QAA0B,GAAlBI,EAAOrT,WAAkB5E,WAAWoG,EAASnG,OAAO,KAAO,IAAM+X,GAAa5Z,EAAI,EAAI6Z,EAASH,GAAkB1S,gBAAkB,IAAM,IAE9LhH,EAAI,GACNgI,KAAYqH,IAAYA,EAAOrH,GAAY8R,GACrCzK,EAAOrH,KAEf2R,EAAS/X,WAAWoG,EAAStG,OAAO1B,EAAE,GAAKgI,EAASnG,OAAO7B,EAAE,IACzD4Z,GAAaF,IAChBC,EAASA,EAAS,KAAOlV,EAASiV,GAAoBA,EAAiB,GAAKA,GAAkB1S,iBAEnF,EAAJhH,EAASkI,eAAetF,EAAWoF,EAASnG,OAAO,EAAG7B,EAAE,GAAI0Z,GAAoBC,EAASG,EAAkBH,IAEhG,MAAZ3R,EAAoB8R,GAAmB9R,GAsBhDH,GAAS,SAATA,OAAUgF,EAAKD,EAAKzO,UAAUA,EAAQ0O,EAAMA,EAAcD,EAARzO,EAAcyO,EAAMzO,GAGtE4b,GAAS,GAAGxX,MAIZ7B,GAAU,SAAVA,QAAWvC,EAAOU,EAAOmb,UAAiB3D,IAAaxX,GAASwX,EAASvL,SAAWuL,EAASvL,SAAS3M,IAASD,EAAUC,IAAW6b,IAAiB1D,GAAiBvF,KAAqEtM,EAAStG,GAFzO,SAAX8b,SAAYC,EAAIF,EAAcG,mBAAAA,IAAAA,EAAc,IAAOD,EAAGhZ,QAAQ,SAAA/C,UAAUD,EAAUC,KAAW6b,GAAiBtP,GAAavM,EAAO,GAAKgc,EAAY/Q,WAAZ+Q,EAAoBzZ,GAAQvC,IAAUgc,EAAY/Q,KAAKjL,MAAWgc,EAEoDF,CAAS9b,EAAO6b,GAAgBtP,GAAavM,GAAS4b,GAAOK,KAAKjc,EAAO,GAAKA,EAAQ,CAACA,GAAS,GAA5K4b,GAAOK,MAAMvb,GAASsM,GAAMD,iBAAiB/M,GAAQ,IA4ItOkc,GAAW,SAAXA,SAAYC,EAAOC,EAAOC,EAAQC,EAAQtc,OACrCuc,EAAUH,EAAQD,EACrBK,EAAWF,EAASD,SACdlQ,GAAmBnM,EAAO,SAAAA,UAASqc,IAAarc,EAAQmc,GAASI,EAAWC,GAAa,MAoDjGjL,GAAY,SAAZA,UAAa9M,EAAWkH,EAAM8Q,OAK5B7Q,EAAQlL,EAAOmU,EAJZpS,EAAIgC,EAAUuB,KACjB0W,EAAWja,EAAEkJ,GACbgR,EAAczE,EACd0E,EAAUnY,EAAUoY,QAEhBH,SAGL9Q,EAASnJ,EAAEkJ,EAAO,UAClBjL,EAAQ+B,EAAEqa,eAAiBrY,EAC3BgY,GAAoBvY,GAAYhC,QAAU8B,KAC1C4Y,IAAY1E,EAAW0E,GACvB/H,EAASjJ,EAAS8Q,EAAShH,MAAMhV,EAAOkL,GAAU8Q,EAAST,KAAKvb,GAChEwX,EAAWyE,EACJ9H,GASR1B,GAAuB,GAsDvBK,GAAO,IACPO,GAAe,CACdgJ,KAAK,CAAC,EAAEvJ,GAAKA,IACbwJ,KAAK,CAAC,EAAExJ,GAAK,GACbyJ,OAAO,CAAC,IAAI,IAAI,KAChBjJ,MAAM,CAAC,EAAE,EAAE,GACXkJ,OAAO,CAAC,IAAI,EAAE,GACdC,KAAK,CAAC,EAAE,IAAI,KACZC,KAAK,CAAC,EAAE,EAAE5J,IACV6J,KAAK,CAAC,EAAE,EAAE,KACVC,MAAM,CAAC9J,GAAKA,GAAKA,IACjB+J,MAAM,CAAC,IAAI,IAAI,GACfC,OAAO,CAAChK,GAAKA,GAAK,GAClBiK,OAAO,CAACjK,GAAK,IAAI,GACjBkK,KAAK,CAAC,IAAI,IAAI,KACdC,OAAO,CAAC,IAAI,EAAE,KACdC,MAAM,CAAC,EAAE,IAAI,GACbC,IAAI,CAACrK,GAAK,EAAE,GACZsK,KAAK,CAACtK,GAAK,IAAI,KACfuK,KAAK,CAAC,EAAEvK,GAAKA,IACbW,YAAY,CAACX,GAAKA,GAAKA,GAAK,IAqH7BgB,GAAa,eAEXlP,EADGqL,EAAI,6EAEHrL,KAAKyO,GACTpD,GAAK,IAAMrL,EAAI,aAET,IAAI0Y,OAAOrN,EAAI,IAAK,MANf,GAQb4E,GAAU,YAkCVxK,IACK8N,EAAWoF,KAAKC,IACnBpF,EAAgB,IAChBC,EAAe,GACfC,EAAaH,IACbI,EAAcD,EAEdG,EADAD,EAAO,IAAO,IA0BfR,EAAQ,CACPhU,KAAK,EACLsG,MAAM,EACNmT,qBACCC,IAAM,IAEPC,+BAAWC,UACH3F,GAAU,KAAQ2F,GAAO,MAEjCC,qBACKnG,KACED,GAAgB7X,MACpBoM,EAAOyL,EAAe5X,OACtByM,EAAON,EAAK8R,UAAY,GACxB3d,GAASC,KAAOA,IACf4L,EAAK+R,eAAiB/R,EAAK+R,aAAe,KAAKxT,KAAKnK,GAAK4d,SAC1Dje,EAASE,GAAiB+L,EAAKiS,mBAAsBjS,EAAK5L,MAAQ4L,GAAS,IAC3EyG,GAAqBpQ,QAAQyO,KAE9BiH,EAAyC,oBAA3BmG,uBAA0CA,sBACxDrG,GAAOG,EAAMmG,QACbrG,EAAOC,GAAS,SAAAqG,UAAKC,WAAWD,EAAI3F,EAAyB,IAAbT,EAAMhU,KAAc,EAAK,IACzE4T,EAAgB,EAChB8F,GAAM,KAGRS,wBACEpG,EAAOuG,qBAAuBC,cAAc1G,GAC7CD,EAAgB,EAChBE,EAAO/W,GAERyd,mCAAaC,EAAWC,GACvBtG,EAAgBqG,GAAaE,EAAAA,EAC7BtG,EAAe9V,KAAKyL,IAAI0Q,GAAe,GAAItG,IAE5CwF,iBAAIA,GACHpF,EAAO,KAAQoF,GAAO,KACtBnF,EAAyB,IAAbT,EAAMhU,KAAcwU,GAEjC1P,iBAAIkT,EAAU4C,EAAMC,OACf1c,EAAOyc,EAAO,SAACxY,EAAGyH,EAAGuQ,EAAGrc,GAAOia,EAAS5V,EAAGyH,EAAGuQ,EAAGrc,GAAIiW,EAAMnR,OAAO1E,IAAU6Z,SAChFhE,EAAMnR,OAAOmV,GACbtD,EAAWmG,EAAa,UAAY,QAAQ1c,GAC5C+P,KACO/P,GAER0E,uBAAOmV,EAAU7a,KACdA,EAAIuX,EAAWrV,QAAQ2Y,KAActD,EAAW/W,OAAOR,EAAG,IAAYA,GAAN+W,GAAWA,KAE9EQ,WAzEAA,EAAa,KA6EfxG,GAAQ,SAARA,eAAe0F,GAAiBvN,GAAQwT,QAoBxC9I,GAAW,GACXc,GAAiB,sBACjBP,GAAa,QA4Bb3G,GAAc,SAAdA,YAAc9B,UAAQ,SAAAjI,UAAK,EAAIiI,EAAK,EAAIjI,KAoBxCkI,GAAa,SAAbA,WAAcD,EAAMiS,UAAiBjS,IAAsBtN,EAAYsN,GAAQA,EAAOkI,GAASlI,IAASiI,GAAsBjI,KAAlFiS,GAjJlC,SAARpB,GAAQ3b,OAGNgd,EAASC,EAAUhb,EAAMsG,EAFtB2U,EAAU9G,IAAaI,EAC1B2G,GAAe,IAANnd,MAECqW,EAAV6G,GAA2BA,EAAU,KAAO3G,GAAc2G,EAAU5G,IAIvD,GADd0G,GADA/a,GADAuU,GAAe0G,GACM3G,GACJG,IACEyG,KAClB5U,IAAU0N,EAAM1N,MAChB2N,EAASjU,EAAoB,IAAbgU,EAAMhU,KACtBgU,EAAMhU,KAAOA,GAAc,IAC3ByU,GAAasG,GAAsBvG,GAAXuG,EAAkB,EAAIvG,EAAOuG,GACrDC,EAAW,GAEZE,IAAWrH,EAAMC,EAAK4F,KAClBsB,MACE9G,EAAK,EAAGA,EAAKQ,EAAWlX,OAAQ0W,IACpCQ,EAAWR,GAAIlU,EAAMiU,EAAQ3N,EAAOvI,GAqL9B,SAAVwU,GAAU3R,UAAMA,EAAI+T,EAAMpU,EAAIK,EAAIA,EAAKA,EAFlC,kBAE4CL,WAAKK,EAAI,IAEjD,KAF6D,GAAI,IAAOA,EAD5E,kBACsFL,GAAKK,GAAK,KAE5F,MAFwGA,EAAI,MAAQL,WAAKK,EAAI,MAE7H,KAF2I,GAAI,QAV1J3C,GAAa,uCAAwC,SAACpB,EAAMM,OACvDge,EAAQhe,EAAI,EAAIA,EAAI,EAAIA,EAC5BkV,GAAYxV,EAAO,UAAYse,EAAQ,GAAIhe,EAAI,SAAAyD,mBAAKA,EAAKua,IAAQ,SAAAva,UAAKA,GAAG,SAAAA,UAAK,WAAK,EAAIA,EAAMua,IAAO,SAAAva,UAAKA,EAAI,GAAKrC,SAAK,EAAJqC,EAAUua,GAAQ,EAAI,EAAI5c,SAAW,GAAT,EAAIqC,GAAWua,GAAQ,MAEvKpK,GAASqK,OAAOC,SAAWtK,GAASuK,KAAOvK,GAASqK,OAAO9I,OAC3DD,GAAY,UAAWO,GAAe,MAAOA,GAAe,OAAQA,MAClErS,EAMC,OALEoU,EAAK,EAKC,KADVtC,GAAY,SAAU,SAAAzR,UAAK,EAAI2R,GAAQ,EAAI3R,IAAI2R,IAEhDF,GAAY,OAAQ,SAAAzR,UAAKrC,SAAC,EAAM,IAAMqC,EAAI,IAAOA,EAAIA,EAAIA,EAAIA,EAAIA,EAAIA,EAAIA,GAAK,EAAEA,KAChFyR,GAAY,OAAQ,SAAAzR,WAAO2J,EAAM,EAAK3J,EAAIA,GAAM,KAChDyR,GAAY,OAAQ,SAAAzR,UAAW,IAANA,EAAU,EAA0B,EAArB6U,EAAK7U,EAAI0U,KACjDjD,GAAY,OAAQgB,GAAY,MAAOA,GAAY,OAAQA,MAC3DtC,GAASwK,YAAcxK,GAASyK,MAAQrf,GAASof,YAAc,CAC9DxO,uBAAOyO,EAAWC,YAAXD,IAAAA,EAAQ,OACVzI,EAAK,EAAIyI,EACZtI,EAAKsI,GAASC,EAAiB,EAAI,GACnCxI,EAAKwI,EAAiB,EAAI,SAEpB,SAAA7a,WAAQsS,EAAKlO,GAAO,EADpB,UAC4BpE,GAAM,GAAKqS,GAAMF,KAGtDmC,EAAUrM,KAAOkI,GAAS,YAG1B9S,GAAa,qEAAsE,SAAApB,UAAQ0Z,IAAkB1Z,EAAO,IAAMA,EAAO,mBAoBpHa,GAEZ,iBAAYN,EAAQE,QACdoe,GAAKnG,KACVnY,EAAOC,MAAQse,MACVve,OAASA,OACTE,QAAUA,OACVuQ,IAAMvQ,EAAUA,EAAQuQ,IAAM/P,QAC9B8d,IAAMte,EAAUA,EAAQwQ,UAAYC,IAyB9B8N,6BAmBZzG,MAAA,eAAM9Z,UACDA,GAAmB,IAAVA,QACPiG,QAAUoa,KAAKpa,OAAOmD,mBAAsBiX,KAAKG,UAAUH,KAAKzY,OAAS5H,EAAQqgB,KAAKrW,aACtFA,OAAShK,EACPqgB,MAEDA,KAAKrW,WAGbxB,SAAA,kBAASxI,UACDygB,UAAUve,OAASme,KAAKxX,cAA6B,EAAfwX,KAAKhY,QAAcrI,GAASA,EAAQqgB,KAAK5X,SAAW4X,KAAKhY,QAAUrI,GAASqgB,KAAKxX,iBAAmBwX,KAAK1Y,SAGvJkB,cAAA,uBAAc7I,UACRygB,UAAUve,aAGV2F,OAAS,EACPqD,GAAamV,KAAMA,KAAKhY,QAAU,EAAIrI,GAASA,EAASqgB,KAAKhY,QAAUgY,KAAK5X,UAAa4X,KAAKhY,QAAU,KAHvGgY,KAAKvX,UAMdf,UAAA,mBAAUA,EAAWpD,MACpBiO,MACK6N,UAAUve,cACPme,KAAK9X,WAETtC,EAASoa,KAAK7Z,OACdP,GAAUA,EAAOmD,mBAAqBiX,KAAKzX,IAAK,KACnDO,GAAekX,KAAMtY,IACpB9B,EAAOO,KAAOP,EAAOA,QAAUqD,GAAerD,EAAQoa,MAEhDpa,GAAUA,EAAOA,QACnBA,EAAOA,OAAOoD,QAAUpD,EAAO2B,QAAwB,GAAd3B,EAAO2C,IAAW3C,EAAOsC,OAAStC,EAAO2C,KAAO3C,EAAO4C,gBAAkB5C,EAAOsC,SAAWtC,EAAO2C,MAC9I3C,EAAO8B,UAAU9B,EAAOsC,QAAQ,GAEjCtC,EAASA,EAAOA,QAEZoa,KAAKpa,QAAUoa,KAAK7Z,IAAIc,qBAAmC,EAAX+Y,KAAKzX,KAAWb,EAAYsY,KAAKvX,OAAWuX,KAAKzX,IAAM,GAAiB,EAAZb,IAAoBsY,KAAKvX,QAAUf,IACnJ6B,GAAeyW,KAAK7Z,IAAK6Z,KAAMA,KAAKzY,OAASyY,KAAKrW,eAG1CqW,KAAK9X,SAAWR,IAAesY,KAAK1Y,OAAShD,GAAoB0b,KAAKvb,UAAY7B,KAAK+F,IAAIqX,KAAK1W,UAAYT,IAAenB,IAAcsY,KAAKvb,WAAaub,KAAK7W,KAAO6W,KAAKK,mBAC1K9X,MAAQyX,KAAKM,OAAS5Y,GAG1BvD,GAAgB6b,KAAMtY,EAAWpD,IAIlC0b,SAGR3b,KAAA,cAAK1E,EAAO2E,UACJ8b,UAAUve,OAASme,KAAKtY,UAAW9E,KAAKyL,IAAI2R,KAAKxX,gBAAiB7I,EAAQoI,GAAsBiY,QAAUA,KAAK1Y,KAAO0Y,KAAK5X,WAAczI,EAAQqgB,KAAK1Y,KAAO,GAAIhD,GAAkB0b,KAAKhX,UAGhMkC,cAAA,uBAAcvL,EAAO2E,UACb8b,UAAUve,OAASme,KAAKtY,UAAWsY,KAAKxX,gBAAkB7I,EAAO2E,GAAkB0b,KAAKxX,gBAAkB5F,KAAKyL,IAAI,EAAG2R,KAAK9X,OAAS8X,KAAKvX,OAA2B,GAAlBuX,KAAK5W,WAAkB4W,KAAKvb,SAAW,EAAI,MAGrMwM,SAAA,kBAAStR,EAAO2E,UACR8b,UAAUve,OAASme,KAAKtY,UAAWsY,KAAK7X,aAAc6X,KAAKzJ,OAA8B,EAAnByJ,KAAKO,YAA+B5gB,EAAZ,EAAIA,GAAiBoI,GAAsBiY,MAAO1b,GAAmB0b,KAAK7X,WAAavF,KAAKyL,IAAI,EAAG2R,KAAKhX,MAAQgX,KAAK1Y,MAAyB,EAAjB0Y,KAAK5W,UAAgB,EAAI,MAG5PmX,UAAA,mBAAU5gB,EAAO2E,OACZuW,EAAgBmF,KAAK7X,WAAa6X,KAAK5X,eACpCgY,UAAUve,OAASme,KAAKtY,UAAUsY,KAAKhX,OAASrJ,EAAQ,GAAKkb,EAAevW,GAAkB0b,KAAKhY,QAAUC,GAAgB+X,KAAK9X,OAAQ2S,GAAiB,EAAI,MAcvKjR,UAAA,mBAAUjK,EAAO2E,OACX8b,UAAUve,cACPme,KAAKpX,QAAUC,EAAW,EAAImX,KAAKpX,QAEvCoX,KAAKpX,OAASjJ,SACVqgB,SAEJ3V,EAAQ2V,KAAKpa,QAAUoa,KAAKzX,IAAMF,GAAwB2X,KAAKpa,OAAOoD,MAAOgX,MAAQA,KAAK9X,mBAMzFU,MAAQjJ,GAAS,OACjB4I,IAAOyX,KAAKQ,KAAO7gB,KAAWkJ,EAAY,EAAImX,KAAKpX,UACnDlB,UAAU2B,IAAQzG,KAAK+F,IAAIqX,KAAKrW,QAASqW,KAAKvX,MAAO4B,IAA2B,IAAnB/F,GAClEoE,GAAQsX,MAtiCW,SAApBS,kBAAoBrc,WACfwB,EAASxB,EAAUwB,OAChBA,GAAUA,EAAOA,QACvBA,EAAO4B,OAAS,EAChB5B,EAAO4C,gBACP5C,EAASA,EAAOA,cAEVxB,EAgiCAqc,CAAkBT,UAG1BU,OAAA,gBAAO/gB,UACDygB,UAAUve,QAKXme,KAAKQ,MAAQ7gB,UACX6gB,IAAM7gB,SAEL2gB,OAASN,KAAK9X,QAAUtF,KAAKwL,KAAK4R,KAAKrW,OAAQqW,KAAK5W,gBACpDb,IAAMyX,KAAK7Y,KAAO,IAEvBoL,UACKhK,IAAMyX,KAAKpX,UAEXlB,UAAUsY,KAAKpa,SAAWoa,KAAKpa,OAAOmD,kBAAoBiX,KAAK5W,UAAY4W,KAAK9X,QAAU8X,KAAKM,OAA6B,IAApBN,KAAK/O,YAAqBrO,KAAK+F,IAAIqX,KAAK1W,UAAYT,IAAamX,KAAK9X,QAAUW,MAGxLmX,MAhBCA,KAAKQ,QAmBdL,UAAA,mBAAUxgB,MACLygB,UAAUve,OAAQ,MAChB0F,OAAS5H,MACViG,EAASoa,KAAKpa,QAAUoa,KAAK7Z,WACjCP,IAAWA,EAAOiE,OAAUmW,KAAKpa,QAAW2D,GAAe3D,EAAQoa,KAAMrgB,EAAQqgB,KAAKrW,QAC/EqW,YAEDA,KAAKzY,WAGb0T,QAAA,iBAAQ0F,UACAX,KAAKzY,QAAUvH,EAAY2gB,GAAkBX,KAAKxX,gBAAkBwX,KAAK7X,YAAcvF,KAAK+F,IAAIqX,KAAKzX,KAAO,OAGpHa,QAAA,iBAAQwX,OACHhb,EAASoa,KAAKpa,QAAUoa,KAAK7Z,WACzBP,EAAwBgb,KAAiBZ,KAAKzX,KAAQyX,KAAKhY,SAAWgY,KAAKhX,OAASgX,KAAK9U,gBAAkB,GAAO8U,KAAK9X,QAAU8X,KAAK1Y,KAAO0Y,KAAK5X,SAAY4X,KAAKzX,IAAoBF,GAAwBzC,EAAOwD,QAAQwX,GAAcZ,MAAnEA,KAAK9X,OAArK8X,KAAK9X,WAGvBP,OAAA,gBAAOyJ,YAAAA,IAAAA,EAAQqJ,QACVoG,EAAkBrc,SACtBA,EAAa4M,GACT4O,KAAKvb,UAAYub,KAAKtb,iBACpBwE,UAAY8W,KAAK9W,SAASvB,OAAOyJ,QACjC1J,WAAW,IAAM0J,EAAO9M,iBAEhB,gBAATyW,OAAqC,IAAhB3J,EAAOJ,MAAkBgP,KAAKhP,OACxDxM,EAAaqc,EACNb,SAGRc,WAAA,oBAAW1X,WACNhF,EAAY4b,KACf3b,EAAO+b,UAAUve,OAASuH,EAAUhF,EAAUgF,UACxChF,GACNC,EAAOD,EAAUmD,OAASlD,GAAQzB,KAAK+F,IAAIvE,EAAUmE,MAAQ,GAC7DnE,EAAYA,EAAU+B,WAEf6Z,KAAKpa,QAAUoa,KAAKe,KAAOf,KAAKe,KAAKD,WAAW1X,GAAW/E,MAGpE2G,OAAA,gBAAOrL,UACFygB,UAAUve,aACRmG,QAAUrI,IAAUqf,EAAAA,GAAY,EAAIrf,EAClCwL,GAAuB6U,QAEN,IAAlBA,KAAKhY,QAAiBgX,EAAAA,EAAWgB,KAAKhY,YAG9CgZ,YAAA,qBAAYrhB,MACPygB,UAAUve,OAAQ,KACjBwC,EAAO2b,KAAKhX,kBACXZ,QAAUzI,EACfwL,GAAuB6U,MAChB3b,EAAO2b,KAAK3b,KAAKA,GAAQ2b,YAE1BA,KAAK5X,YAGb6Y,KAAA,cAAKthB,UACAygB,UAAUve,aACR0U,MAAQ5W,EACNqgB,MAEDA,KAAKzJ,UAGb2K,KAAA,cAAK1X,EAAUlF,UACP0b,KAAKtY,UAAUgC,GAAesW,KAAMxW,GAAWxJ,EAAYsE,QAGnE6c,QAAA,iBAAQC,EAAc9c,eAChB+c,OAAO3Z,UAAU0Z,GAAgBpB,KAAKrW,OAAS,EAAG3J,EAAYsE,SAC9DgD,OAAS0Y,KAAK1W,QAAUT,GACtBmX,SAGRqB,KAAA,cAAKjU,EAAM9I,UACF,MAAR8I,GAAgB4S,KAAKkB,KAAK9T,EAAM9I,GACzB0b,KAAKsB,UAAS,GAAOZ,QAAO,OAGpCa,QAAA,iBAAQnU,EAAM9I,UACL,MAAR8I,GAAgB4S,KAAKkB,KAAK9T,GAAQ4S,KAAKxX,gBAAiBlE,GACjD0b,KAAKsB,UAAS,GAAMZ,QAAO,OAGnCc,MAAA,eAAMC,EAAQnd,UACH,MAAVmd,GAAkBzB,KAAKkB,KAAKO,EAAQnd,GAC7B0b,KAAKU,QAAO,OAGpBgB,OAAA,yBACQ1B,KAAKU,QAAO,OAGpBY,SAAA,kBAAS3hB,UACJygB,UAAUve,UACXlC,IAAUqgB,KAAKsB,YAActB,KAAKpW,WAAWoW,KAAKpX,OAASjJ,GAASkJ,EAAW,IAC1EmX,MAEDA,KAAKpX,KAAO,MAGpB+Y,WAAA,kCACMld,SAAWub,KAAK7Y,KAAO,OACvBmC,QAAUT,EACRmX,SAGR4B,SAAA,wBAGExY,EAFGxD,EAASoa,KAAKpa,QAAUoa,KAAK7Z,IAChCnD,EAAQgd,KAAKzY,eAEH3B,KAAWoa,KAAKzX,KAAOyX,KAAKvb,UAAYmB,EAAOgc,aAAexY,EAAUxD,EAAOwD,SAAQ,KAAUpG,GAASoG,EAAU4W,KAAK/E,SAAQ,GAAQpS,QAGrJgZ,cAAA,uBAAcvW,EAAM+Q,EAAU9Q,OACzB5F,EAAOqa,KAAKra,YACO,EAAnBya,UAAUve,QACRwa,GAGJ1W,EAAK2F,GAAQ+Q,EACb9Q,IAAW5F,EAAK2F,EAAO,UAAYC,GAC1B,aAATD,IAAwB0U,KAAK8B,UAAYzF,WAJlC1W,EAAK2F,GAMN0U,MAEDra,EAAK2F,OAGbyW,KAAA,cAAKC,OACAC,EAAOjC,YACJ,IAAIkC,QAAQ,SAAAC,GAEN,SAAXC,SACKC,EAAQJ,EAAKF,KACjBE,EAAKF,KAAO,KACZniB,EAAY6e,KAAOA,EAAIA,EAAEwD,MAAWxD,EAAEsD,MAAQtD,IAAMwD,KAAUA,EAAKF,KAAOM,GAC1EF,EAAQ1D,GACRwD,EAAKF,KAAOM,MANV5D,EAAI7e,EAAYoiB,GAAeA,EAAchd,GAQ7Cid,EAAKxd,UAAsC,IAAzBwd,EAAK/W,iBAAqC,GAAZ+W,EAAK1Z,MAAe0Z,EAAK/Z,QAAU+Z,EAAK1Z,IAAM,EACjG6Z,KAEAH,EAAKK,MAAQF,SAKhBpR,KAAA,gBACCF,GAAWkP,qCAlSAra,QACNA,KAAOA,OACPgE,QAAUhE,EAAK8T,OAAS,GACxBuG,KAAKhY,QAAUrC,EAAKqF,SAAWgU,EAAAA,GAAY,EAAIrZ,EAAKqF,QAAU,UAC7D5C,QAAUzC,EAAKqb,aAAe,OAC9BzK,QAAU5Q,EAAKsb,QAAUtb,EAAK2Q,eAE/B/N,IAAM,EACXsC,GAAamV,MAAOra,EAAKwC,SAAU,EAAG,QACjC4S,KAAOpV,EAAKoV,KACblD,SACE2E,KAAO3E,GACHkD,KAAKnQ,KAAKoV,MAEpB/H,GAAiBvN,GAAQwT,OAyR3BhZ,GAAagb,GAAUzN,UAAW,CAACzJ,MAAM,EAAGzB,OAAO,EAAGF,KAAK,EAAGa,OAAO,EAAGO,MAAM,EAAGjB,OAAO,EAAGQ,QAAQ,EAAGuO,OAAM,EAAO3Q,OAAO,KAAMnB,UAAS,EAAO2D,QAAQ,EAAGG,IAAI,EAAGpC,IAAI,EAAGoc,MAAM,EAAGjZ,QAAQT,EAAUyZ,MAAM,EAAG9B,KAAI,EAAO5X,KAAK,QAyBhNwC,iCAEAzF,EAAW6D,yBAAX7D,IAAAA,EAAO,mBACZA,UACDkL,OAAS,KACT9H,oBAAsBpD,EAAKoD,oBAC3B9B,qBAAuBtB,EAAKsB,qBAC5B4C,MAAQ7J,EAAY2F,EAAK6c,cAC9B3c,GAAmB0D,GAAe5D,EAAKC,QAAUC,4BAAuB2D,GACxE7D,EAAK2b,UAAYmB,EAAKlB,UACtB5b,EAAK+a,QAAU+B,EAAK/B,QAAO,GAC3B/a,EAAKoL,eAAiB/G,6BAAqBrE,EAAKoL,8EAGjD2R,GAAA,YAAGphB,EAASqE,EAAM6D,UACjB6B,GAAiB,EAAG+U,UAAWJ,MACxBA,QAGR5S,KAAA,cAAK9L,EAASqE,EAAM6D,UACnB6B,GAAiB,EAAG+U,UAAWJ,MACxBA,QAGR2C,OAAA,gBAAOrhB,EAASshB,EAAUC,EAAQrZ,UACjC6B,GAAiB,EAAG+U,UAAWJ,MACxBA,QAGRC,IAAA,aAAI3e,EAASqE,EAAM6D,UAClB7D,EAAKwC,SAAW,EAChBxC,EAAKC,OAASoa,KACdta,GAAiBC,GAAMqb,cAAgBrb,EAAKqF,OAAS,GACrDrF,EAAKkC,kBAAoBlC,EAAKkC,oBAC1BgE,GAAMvK,EAASqE,EAAM+D,GAAesW,KAAMxW,GAAW,GAClDwW,QAGRpE,KAAA,cAAKS,EAAU9Q,EAAQ/B,UACfD,GAAeyW,KAAMnU,GAAMiX,YAAY,EAAGzG,EAAU9Q,GAAS/B,MAIrEuZ,UAAA,mBAAUzhB,EAAS6G,EAAUxC,EAAMqd,EAASxZ,EAAUyZ,EAAeC,UACpEvd,EAAKwC,SAAWA,EAChBxC,EAAKqd,QAAUrd,EAAKqd,SAAWA,EAC/Brd,EAAKwd,WAAaF,EAClBtd,EAAKyd,iBAAmBF,EACxBvd,EAAKC,OAASoa,SACVnU,GAAMvK,EAASqE,EAAM+D,GAAesW,KAAMxW,IACvCwW,QAGRqD,YAAA,qBAAY/hB,EAAS6G,EAAUxC,EAAMqd,EAASxZ,EAAUyZ,EAAeC,UACtEvd,EAAKgG,aAAe,EACpBjG,GAAiBC,GAAMkC,gBAAkB7H,EAAY2F,EAAKkC,iBACnDmY,KAAK+C,UAAUzhB,EAAS6G,EAAUxC,EAAMqd,EAASxZ,EAAUyZ,EAAeC,MAGlFI,cAAA,uBAAchiB,EAAS6G,EAAUya,EAAUC,EAAQG,EAASxZ,EAAUyZ,EAAeC,UACpFL,EAAOjX,QAAUgX,EACjBld,GAAiBmd,GAAQhb,gBAAkB7H,EAAY6iB,EAAOhb,iBACvDmY,KAAK+C,UAAUzhB,EAAS6G,EAAU0a,EAAQG,EAASxZ,EAAUyZ,EAAeC,MAGpFhf,OAAA,gBAAOwD,EAAWpD,EAAgBC,OAMhCF,EAAMgC,EAAOS,EAAMyZ,EAAW1F,EAAe0I,EAAYC,EAAY5Z,EAAW6Z,EAAWC,EAAezC,EAAM7K,EAL7GuN,EAAW3D,KAAKhX,MACnB4a,EAAO5D,KAAKxY,OAASwY,KAAKxX,gBAAkBwX,KAAKvX,MACjDwC,EAAM+U,KAAK1Y,KACX+C,EAAQ3C,GAAa,EAAI,EAAI5E,GAAc4E,GAC3Cmc,EAAiB7D,KAAK1W,OAAS,GAAQ5B,EAAY,IAAOsY,KAAKvb,WAAawG,aAEpEpF,GAA2B+d,EAARvZ,GAA6B,GAAb3C,IAAmB2C,EAAQuZ,GACnEvZ,IAAU2V,KAAK9X,QAAU3D,GAASsf,EAAe,IAChDF,IAAa3D,KAAKhX,OAASiC,IAC9BZ,GAAS2V,KAAKhX,MAAQ2a,EACtBjc,GAAasY,KAAKhX,MAAQ2a,GAE3Btf,EAAOgG,EACPoZ,EAAYzD,KAAKzY,OAEjBgc,IADA3Z,EAAYoW,KAAKzX,KAEbsb,IACH5Y,IAAQ0Y,EAAW3D,KAAK1W,SAEvB5B,GAAcpD,IAAoB0b,KAAK1W,OAAS5B,IAE9CsY,KAAKhY,QAAS,IACjBiZ,EAAOjB,KAAKzJ,MACZsE,EAAgB5P,EAAM+U,KAAK5X,QACvB4X,KAAKhY,SAAW,GAAKN,EAAY,SAC7BsY,KAAKtY,UAA0B,IAAhBmT,EAAsBnT,EAAWpD,EAAgBC,MAExEF,EAAOvB,GAAcuH,EAAQwQ,GACzBxQ,IAAUuZ,GACbrD,EAAYP,KAAKhY,QACjB3D,EAAO4G,KAGPsV,KADAmD,EAAgB5gB,GAAcuH,EAAQwQ,MAErB0F,IAAcmD,IAC9Brf,EAAO4G,EACPsV,KAEMtV,EAAP5G,IAAeA,EAAO4G,IAEvByY,EAAgBzb,GAAgB+X,KAAK9X,OAAQ2S,IAC5C8I,GAAY3D,KAAK9X,QAAUwb,IAAkBnD,GAAaP,KAAK9X,OAASwb,EAAgB7I,EAAgBmF,KAAK1Y,MAAQ,IAAMoc,EAAgBnD,GACxIU,GAAqB,EAAZV,IACZlc,EAAO4G,EAAM5G,EACb+R,EAAS,GAUNmK,IAAcmD,IAAkB1D,KAAK8D,MAAO,KAC3CC,EAAa9C,GAAyB,EAAhByC,EACzBM,EAAYD,KAAe9C,GAAqB,EAAZV,MACrCA,EAAYmD,IAAkBK,GAAaA,GAC3CJ,EAAWI,EAAY,EAAI1Z,EAAQY,EAAMA,EAAMZ,OAC1CyZ,MAAQ,OACR5f,OAAOyf,IAAavN,EAAS,EAAItT,GAAcyd,EAAY1F,IAAiBvW,GAAiB2G,GAAK6Y,MAAQ,OAC1G5b,OAASmC,GACb/F,GAAkB0b,KAAKpa,QAAUsL,GAAU8O,KAAM,iBAC7Cra,KAAKse,gBAAkB7N,IAAW4J,KAAK2B,aAAamC,MAAQ,GAC5DH,GAAYA,IAAa3D,KAAKhX,OAAUua,IAAgBvD,KAAKzX,KAAQyX,KAAKra,KAAKue,WAAalE,KAAKpa,SAAWoa,KAAK7Y,YAC9G6Y,QAER/U,EAAM+U,KAAK1Y,KACXsc,EAAO5D,KAAKvX,MACRub,SACEF,MAAQ,EACbH,EAAWI,EAAY9Y,GAAO,UACzB/G,OAAOyf,GAAU,QACjBhe,KAAKse,gBAAkB7N,GAAU4J,KAAK2B,mBAEvCmC,MAAQ,GACR9D,KAAKzX,MAAQgb,SACVvD,KAGR7J,GAAmB6J,KAAM5J,OAGvB4J,KAAKmE,YAAcnE,KAAKoE,UAAYpE,KAAK8D,MAAQ,IACpDN,EA3wCmB,SAAtBa,oBAAuBjgB,EAAWuf,EAAUtf,OACvCgC,KACOsd,EAAPtf,MACHgC,EAAQjC,EAAUiS,OACXhQ,GAASA,EAAMkB,QAAUlD,GAAM,IAClB,YAAfgC,EAAM0U,MAAsB1U,EAAMkB,OAASoc,SACvCtd,EAERA,EAAQA,EAAMO,eAGfP,EAAQjC,EAAUkgB,MACXje,GAASA,EAAMkB,QAAUlD,GAAM,IAClB,YAAfgC,EAAM0U,MAAsB1U,EAAMkB,OAASoc,SACvCtd,EAERA,EAAQA,EAAMM,OA2vCD0d,CAAoBrE,KAAMld,GAAc6gB,GAAW7gB,GAAcuB,OAE7EgG,GAAShG,GAAQA,EAAOmf,EAAWjc,cAIhCW,OAASmC,OACTrB,MAAQ3E,OACR8C,MAAQyC,EAERoW,KAAKvb,gBACJqd,UAAY9B,KAAKra,KAAK4e,cACtB9f,SAAW,OACX6E,OAAS5B,EACdic,EAAW,IAEPA,GAAYtf,IAASC,IAAmBic,IAC5CrP,GAAU8O,KAAM,WACZA,KAAK9X,SAAWmC,UACZ2V,QAGG2D,GAARtf,GAAiC,GAAbqD,MACvBrB,EAAQ2Z,KAAK3J,OACNhQ,GAAO,IACbS,EAAOT,EAAMO,OACRP,EAAMc,MAAQ9C,GAAQgC,EAAMkB,SAAWlB,EAAMkC,KAAOib,IAAend,EAAO,IAC1EA,EAAMT,SAAWoa,YACbA,KAAK9b,OAAOwD,EAAWpD,EAAgBC,MAE/C8B,EAAMnC,OAAmB,EAAZmC,EAAMkC,KAAWlE,EAAOgC,EAAMkB,QAAUlB,EAAMkC,KAAOlC,EAAMmB,OAASnB,EAAMmC,gBAAkBnC,EAAMoC,QAAUpE,EAAOgC,EAAMkB,QAAUlB,EAAMkC,IAAKjE,EAAgBC,GACvKF,IAAS2b,KAAKhX,QAAWgX,KAAKzX,MAAQgb,EAAa,CACtDC,EAAa,EACb1c,IAASuD,GAAU2V,KAAK1W,QAAUT,UAIpCxC,EAAQS,MAEH,CACNT,EAAQ2Z,KAAKsE,cACTE,EAAe9c,EAAY,EAAIA,EAAYrD,EACxCgC,GAAO,IACbS,EAAOT,EAAMM,OACRN,EAAMc,MAAQqd,GAAgBne,EAAMgB,OAAShB,EAAMkC,KAAOib,IAAend,EAAO,IAChFA,EAAMT,SAAWoa,YACbA,KAAK9b,OAAOwD,EAAWpD,EAAgBC,MAE/C8B,EAAMnC,OAAmB,EAAZmC,EAAMkC,KAAWic,EAAene,EAAMkB,QAAUlB,EAAMkC,KAAOlC,EAAMmB,OAASnB,EAAMmC,gBAAkBnC,EAAMoC,QAAU+b,EAAene,EAAMkB,QAAUlB,EAAMkC,IAAKjE,EAAgBC,GAAUC,IAAe6B,EAAM5B,UAAY4B,EAAM3B,WACxOL,IAAS2b,KAAKhX,QAAWgX,KAAKzX,MAAQgb,EAAa,CACtDC,EAAa,EACb1c,IAASuD,GAAU2V,KAAK1W,OAASkb,GAAgB3b,EAAWA,UAI9DxC,EAAQS,MAGN0c,IAAelf,SACbkd,QACLgC,EAAWtf,OAAeyf,GAARtf,EAAmB,GAAKwE,GAAUS,OAAiBqa,GAARtf,EAAmB,GAAK,EACjF2b,KAAKzX,iBACHhB,OAASkc,EACd/a,GAAQsX,MACDA,KAAK9b,OAAOwD,EAAWpD,EAAgBC,QAG3Cud,YAAcxd,GAAkB4M,GAAU8O,KAAM,YAAY,IAC5D3V,IAAUuZ,GAAQ5D,KAAK9X,QAAU8X,KAAKxX,kBAAsB6B,GAASsZ,KAAeF,IAAczD,KAAKzY,QAAU3E,KAAK+F,IAAIiB,KAAehH,KAAK+F,IAAIqX,KAAKzX,MAAWyX,KAAK8D,SAC1Kpc,GAAcuD,KAAUZ,IAAUuZ,GAAmB,EAAX5D,KAAKzX,MAAc8B,GAAS2V,KAAKzX,IAAM,IAAOxB,GAAkBiZ,KAAM,GAC5G1b,GAAoBoD,EAAY,IAAMic,IAActZ,IAASsZ,GAAaC,IAC9E1S,GAAU8O,KAAO3V,IAAUuZ,GAAqB,GAAblc,EAAiB,aAAe,qBAAsB,SACpF4a,OAAWjY,EAAQuZ,GAA2B,EAAnB5D,KAAKpW,aAAoBoW,KAAKsC,kBAI1DtC,QAGR7W,IAAA,aAAI9C,EAAOmD,iBACV3J,EAAU2J,KAAcA,EAAWE,GAAesW,KAAMxW,EAAUnD,MAC5DA,aAAiB6Z,IAAY,IAC9Bja,EAASI,UACZA,EAAM3D,QAAQ,SAAAvB,UAAOsjB,EAAKtb,IAAIhI,EAAKqI,KAC5BwW,QAEJtgB,EAAU2G,UACN2Z,KAAK0E,SAASre,EAAOmD,OAEzB5J,EAAYyG,UAGR2Z,KAFP3Z,EAAQwF,GAAMiX,YAAY,EAAGzc,UAKxB2Z,OAAS3Z,EAAQkD,GAAeyW,KAAM3Z,EAAOmD,GAAYwW,QAGjE2E,YAAA,qBAAY5O,EAAe6O,EAAeC,EAAkBC,YAAhD/O,IAAAA,GAAS,YAAM6O,IAAAA,GAAS,YAAMC,IAAAA,GAAY,YAAMC,IAAAA,GAAoBrW,WAC3E3K,EAAI,GACPuC,EAAQ2Z,KAAK3J,OACPhQ,GACFA,EAAMkB,QAAUud,IACfze,aAAiBwF,GACpB+Y,GAAU9gB,EAAE8G,KAAKvE,IAEjBwe,GAAa/gB,EAAE8G,KAAKvE,GACpB0P,GAAUjS,EAAE8G,WAAF9G,EAAUuC,EAAMse,aAAY,EAAMC,EAAQC,MAGtDxe,EAAQA,EAAMO,aAER9C,KAGRihB,QAAA,iBAAQhF,WACHiF,EAAahF,KAAK2E,YAAY,EAAG,EAAG,GACvCnjB,EAAIwjB,EAAWnjB,OACVL,QACDwjB,EAAWxjB,GAAGmE,KAAKoa,KAAOA,SACtBiF,EAAWxjB,MAKrB0F,OAAA,gBAAOb,UACF3G,EAAU2G,GACN2Z,KAAKiF,YAAY5e,GAErBzG,EAAYyG,GACR2Z,KAAKkF,aAAa7e,IAE1BA,EAAMT,SAAWoa,MAAQnZ,GAAsBmZ,KAAM3Z,GACjDA,IAAU2Z,KAAKjW,eACbA,QAAUiW,KAAKsE,OAEdld,GAAS4Y,UAGjBtY,UAAA,mBAAUA,EAAWpD,UACf8b,UAAUve,aAGVuiB,SAAW,GACXpE,KAAK7Z,KAAO6Z,KAAKzX,WAChBhB,OAASzE,GAAc4H,GAAQrG,MAAmB,EAAX2b,KAAKzX,IAAUb,EAAYsY,KAAKzX,KAAOyX,KAAKxX,gBAAkBd,IAAcsY,KAAKzX,mBAExHb,oBAAUA,EAAWpD,QACtB8f,SAAW,EACTpE,MARCA,KAAK9X,UAWdwc,SAAA,kBAAS9T,EAAOpH,eACVqH,OAAOD,GAASlH,GAAesW,KAAMxW,GACnCwW,QAGRiF,YAAA,qBAAYrU,iBACJoP,KAAKnP,OAAOD,GACZoP,QAGRmF,SAAA,kBAAS3b,EAAU6S,EAAU9Q,OACxB9E,EAAIoF,GAAMiX,YAAY,EAAGzG,GAAYjb,EAAYmK,UACrD9E,EAAEsU,KAAO,eACJoJ,UAAY,EACV5a,GAAeyW,KAAMvZ,EAAGiD,GAAesW,KAAMxW,OAGrD4b,YAAA,qBAAY5b,OACPnD,EAAQ2Z,KAAK3J,WACjB7M,EAAWE,GAAesW,KAAMxW,GACzBnD,GACFA,EAAMkB,SAAWiC,GAA2B,YAAfnD,EAAM0U,MACtChU,GAAkBV,GAEnBA,EAAQA,EAAMO,SAIhBse,aAAA,sBAAa5jB,EAAS+jB,EAAOC,WACxBV,EAAS5E,KAAKuF,YAAYjkB,EAASgkB,GACtC9jB,EAAIojB,EAAO/iB,OACLL,KACLgkB,KAAsBZ,EAAOpjB,IAAOojB,EAAOpjB,GAAGwP,KAAK1P,EAAS+jB,UAEvDrF,QAGRuF,YAAA,qBAAYjkB,EAASgkB,WAKnBG,EAJG3hB,EAAI,GACP4hB,EAAgBxjB,GAAQZ,GACxB+E,EAAQ2Z,KAAK3J,OACbsP,EAAe9lB,EAAUylB,GAEnBjf,GACFA,aAAiBwF,GAChBvI,GAAkB+C,EAAMuf,SAAUF,KAAmBC,IAAiBH,IAAsBnf,EAAM5B,UAAY4B,EAAMkC,MAASlC,EAAMya,WAAW,IAAMwE,GAAcjf,EAAMya,WAAWza,EAAMmC,iBAAmB8c,GAAcA,GAAcjf,EAAMub,aACjP9d,EAAE8G,KAAKvE,IAEGof,EAAWpf,EAAMkf,YAAYG,EAAeJ,IAAazjB,QACpEiC,EAAE8G,WAAF9G,EAAU2hB,GAEXpf,EAAQA,EAAMO,aAER9C,KAUR+hB,QAAA,iBAAQrc,EAAU7D,GACjBA,EAAOA,GAAQ,OAIdmgB,EAHGC,EAAK/F,KACR/E,EAAUvR,GAAeqc,EAAIvc,GAC3BoC,EAAqDjG,EAArDiG,QAASoa,EAA4CrgB,EAA5CqgB,QAASC,EAAmCtgB,EAAnCsgB,cAAepe,EAAoBlC,EAApBkC,gBAEnCjE,EAAQiI,GAAM6W,GAAGqD,EAAI7gB,GAAa,CACjCgI,KAAMvH,EAAKuH,MAAQ,OACnB1C,MAAM,EACN3C,iBAAiB,EACjBxD,KAAM4W,EACNzB,UAAW,OACXrR,SAAUxC,EAAKwC,UAAavF,KAAK+F,KAAKsS,GAAYrP,GAAW,SAAUA,EAAWA,EAAQvH,KAAO0hB,EAAG/c,QAAU+c,EAAGnc,cAAiBf,EAClImd,QAAS,sBACRD,EAAGvE,SACEsE,EAAS,KACT3d,EAAWxC,EAAKwC,UAAYvF,KAAK+F,KAAKsS,GAAYrP,GAAW,SAAUA,EAAWA,EAAQvH,KAAO0hB,EAAG/c,QAAU+c,EAAGnc,aACpHhG,EAAM0D,OAASa,GAAa0C,GAAajH,EAAOuE,EAAU,EAAG,GAAGjE,OAAON,EAAMoF,OAAO,GAAM,GAC3F8c,EAAU,EAEXE,GAAWA,EAAQ3Q,MAAMzR,EAAOqiB,GAAiB,MAEhDtgB,WACGkC,EAAkBjE,EAAMM,OAAO,GAAKN,KAG5CsiB,YAAA,qBAAYC,EAAcC,EAAYzgB,UAC9Bqa,KAAK6F,QAAQO,EAAYlhB,GAAa,CAAC0G,QAAQ,CAACvH,KAAKqF,GAAesW,KAAMmG,KAAiBxgB,OAGnG0V,OAAA,yBACQ2E,KAAKjW,WAGbsc,UAAA,mBAAUC,mBAAAA,IAAAA,EAAYtG,KAAKhX,OACnBwH,GAAqBwP,KAAMtW,GAAesW,KAAMsG,OAGxDC,cAAA,uBAAcC,mBAAAA,IAAAA,EAAaxG,KAAKhX,OACxBwH,GAAqBwP,KAAMtW,GAAesW,KAAMwG,GAAa,MAGrEC,aAAA,sBAAa9mB,UACLygB,UAAUve,OAASme,KAAKkB,KAAKvhB,GAAO,GAAQqgB,KAAKuG,cAAcvG,KAAKhX,MAAQH,MAGpF6d,cAAA,uBAAc7X,EAAQ8X,EAAc7B,YAAAA,IAAAA,EAAmB,WAGrD7f,EAFGoB,EAAQ2Z,KAAK3J,OAChBxF,EAASmP,KAAKnP,OAERxK,GACFA,EAAMkB,QAAUud,IACnBze,EAAMkB,QAAUsH,EAChBxI,EAAMgB,MAAQwH,GAEfxI,EAAQA,EAAMO,SAEX+f,MACE1hB,KAAK4L,EACLA,EAAO5L,IAAM6f,IAChBjU,EAAO5L,IAAM4J,UAITzH,GAAS4Y,SAGjB2B,WAAA,oBAAWiF,OACNvgB,EAAQ2Z,KAAK3J,gBACZyN,MAAQ,EACNzd,GACNA,EAAMsb,WAAWiF,GACjBvgB,EAAQA,EAAMO,yBAEF+a,qBAAWiF,MAGzBC,MAAA,eAAMC,YAAAA,IAAAA,GAAgB,WAEpBhgB,EADGT,EAAQ2Z,KAAK3J,OAEVhQ,GACNS,EAAOT,EAAMO,WACRM,OAAOb,GACZA,EAAQS,cAEJX,MAAQ6Z,KAAKhX,MAAQgX,KAAK9X,OAAS8X,KAAKM,OAAS,GACtDwG,IAAkB9G,KAAKnP,OAAS,IACzBzJ,GAAS4Y,SAGjBxX,cAAA,uBAAc7I,OAKZ+G,EAAM1D,EAAO4C,EAJVwI,EAAM,EACT6T,EAAOjC,KACP3Z,EAAQ4b,EAAKqC,MACbb,EAAYhV,KAET2R,UAAUve,cACNogB,EAAKrY,WAAWqY,EAAKja,QAAU,EAAIia,EAAK9Z,WAAa8Z,EAAKzZ,kBAAoByZ,EAAKX,YAAc3hB,EAAQA,OAE7GsiB,EAAKza,OAAQ,KAChB5B,EAASqc,EAAKrc,OACPS,GACNK,EAAOL,EAAMM,MACbN,EAAMmB,QAAUnB,EAAMmC,gBAEVib,GADZzgB,EAAQqD,EAAMkB,SACW0a,EAAKpY,OAASxD,EAAMkC,MAAQ0Z,EAAK6B,OACzD7B,EAAK6B,MAAQ,EACbva,GAAe0Y,EAAM5b,EAAOrD,EAAQqD,EAAMsD,OAAQ,GAAGma,MAAQ,GAE7DL,EAAYzgB,EAETA,EAAQ,GAAKqD,EAAMkC,MACtB6F,GAAOpL,IACD4C,IAAWqc,EAAK9b,KAASP,GAAUA,EAAOmD,qBAC/CkZ,EAAK1a,QAAUvE,EAAQif,EAAK1Z,IAC5B0Z,EAAKjZ,OAAShG,EACdif,EAAK/Z,QAAUlF,GAEhBif,EAAKyE,eAAe1jB,GAAO,GAAQ,UACnCygB,EAAY,GAEbpd,EAAMgB,KAAO+G,GAAO/H,EAAMkC,MAAQ6F,EAAM/H,EAAMgB,MAC9ChB,EAAQK,EAETmE,GAAaoX,EAAOA,IAASpc,GAAmBoc,EAAKjZ,MAAQoF,EAAO6T,EAAKjZ,MAAQoF,EAAK,EAAG,GACzF6T,EAAKza,OAAS,SAERya,EAAKxZ,gBAGNse,WAAP,oBAAkB1iB,MACbwB,EAAgB0C,MACnBpE,GAAgB0B,EAAiBwC,GAAwBhE,EAAMwB,IAC/D4E,EAAqBC,GAAQC,OAE1BD,GAAQC,OAASgQ,GAAc,CAClCA,IAAgB1B,EAAQC,WAAa,QACjC7S,EAAQR,EAAgBwQ,YACvBhQ,IAAUA,EAAMkC,MAAS0Q,EAAQC,WAAaxO,GAAQqO,WAAWlX,OAAS,EAAG,MAC1EwE,IAAUA,EAAMkC,KACtBlC,EAAQA,EAAMO,MAEfP,GAASqE,GAAQ8T,qBA3fS0B,IAkgB9Bhb,GAAakG,GAASqH,UAAW,CAACqR,MAAM,EAAGK,UAAU,EAAGC,SAAS,IA8GjD,SAAf4C,GAAgBrmB,EAAUgF,EAAM/B,EAAOuM,EAAO1O,EAAQH,OACjD2lB,EAAQC,EAAIC,EAAU3lB,KACtBgR,GAAS7R,KAAwL,KAA1KsmB,EAAS,IAAIzU,GAAS7R,IAAa6Q,KAAK/P,EAAQwlB,EAAOjV,QAAUrM,EAAKhF,GAdnF,SAAfymB,aAAgBzhB,EAAMwK,EAAO1O,EAAQH,EAASsC,MAC7ChE,EAAY+F,KAAUA,EAAO0hB,GAAmB1hB,EAAM/B,EAAOuM,EAAO1O,EAAQH,KACvEvB,EAAU4F,IAAUA,EAAK2hB,OAAS3hB,EAAKyG,UAAanG,EAASN,IAASsU,EAActU,UACjFjG,EAAUiG,GAAQ0hB,GAAmB1hB,EAAM/B,EAAOuM,EAAO1O,EAAQH,GAAWqE,MAGnFV,EADGQ,EAAO,OAENR,KAAKU,EACTF,EAAKR,GAAKoiB,GAAmB1hB,EAAKV,GAAIrB,EAAOuM,EAAO1O,EAAQH,UAEtDmE,EAIsG2hB,CAAazhB,EAAKhF,GAAWwP,EAAO1O,EAAQH,EAASsC,GAAQA,EAAOuM,EAAO7O,KACvLsC,EAAM2G,IAAM2c,EAAK,IAAIrU,GAAUjP,EAAM2G,IAAK9I,EAAQd,EAAU,EAAG,EAAGsmB,EAAO/iB,OAAQ+iB,EAAQ,EAAGA,EAAOM,UAC/F3jB,IAAUoU,OACbmP,EAAWvjB,EAAMyc,UAAUzc,EAAMgiB,SAASliB,QAAQjC,IAClDD,EAAIylB,EAAOxV,OAAO5P,OACXL,KACN2lB,EAASF,EAAOxV,OAAOjQ,IAAM0lB,SAIzBD,EAsKS,SAAjBO,GAAkB9U,EAAMvR,EAAKsmB,EAAUC,OAErCziB,EAAGnB,EADAoJ,EAAO/L,EAAI+L,MAAQwa,GAAY,kBAE/BzhB,EAAS9E,GACZ2C,EAAI2jB,EAAS/U,KAAU+U,EAAS/U,GAAQ,IAExCvR,EAAIuB,QAAQ,SAAC/C,EAAO6B,UAAMsC,EAAE8G,KAAK,CAACnE,EAAGjF,GAAKL,EAAIU,OAAS,GAAK,IAAKO,EAAGzC,EAAOgoB,EAAGza,eAEzEjI,KAAK9D,EACT2C,EAAI2jB,EAASxiB,KAAOwiB,EAASxiB,GAAK,IAC5B,SAANA,GAAgBnB,EAAE8G,KAAK,CAACnE,EAAGrD,WAAWsP,GAAOtQ,EAAGjB,EAAI8D,GAAI0iB,EAAGza,IArR/D,IAuGCsY,GACAoC,GAxDAhW,GAAgB,SAAhBA,cAAyBnQ,EAAQiR,EAAM1P,EAAOG,EAAKgN,EAAO7O,EAASwQ,EAAU+V,EAAcC,EAAWC,GACrGnoB,EAAYuD,KAASA,EAAMA,EAAIgN,GAAS,EAAG1O,EAAQH,QAIlD4lB,EAHGc,EAAevmB,EAAOiR,GACzBuV,EAAyB,QAAVjlB,EAAmBA,EAASpD,EAAYooB,GAAgCF,EAAYrmB,EAAQiR,EAAKhP,QAAQ,SAAW9D,EAAY6B,EAAO,MAAQiR,EAAKrP,OAAO,KAAQqP,EAAO,MAAQA,EAAKrP,OAAO,IAAIykB,GAAarmB,EAAOiR,KAA9JsV,EACvEE,EAAUtoB,EAAYooB,GAA+BF,EAAYK,GAAuBC,GAAlDC,MAEnC3oB,EAAUyD,MACRA,EAAIO,QAAQ,aAChBP,EAAMiN,GAAejN,IAEA,MAAlBA,EAAID,OAAO,OACdgkB,EAAKnkB,GAAeklB,EAAa9kB,IAAQ4I,GAAQkc,IAAgB,KAChD,IAAPf,IACT/jB,EAAM+jB,MAIJa,GAAYE,IAAgB9kB,GAAOykB,UAClCpa,MAAMya,EAAc9kB,IAAgB,KAARA,GAMhC6kB,GAAkBtV,KAAQjR,GAAWf,EAAegS,EAAMvP,GAxE7B,SAA7BmlB,2BAAsC7mB,EAAQiR,EAAM1P,EAAOG,EAAK+kB,EAAQL,EAAcC,OAIvFtT,EAAQ+T,EAAW7T,EAAO8T,EAAQC,EAAOC,EAAUC,EAAW7kB,EAH3DojB,EAAK,IAAIrU,GAAUmN,KAAKzV,IAAK9I,EAAQiR,EAAM,EAAG,EAAGkW,GAAsB,KAAMV,GAChF/X,EAAQ,EACR0Y,EAAa,MAEd3B,EAAGpY,EAAI9L,EACPkkB,EAAGS,EAAIxkB,EACPH,GAAS,IAEJ2lB,IADLxlB,GAAO,IACeO,QAAQ,cAC7BP,EAAMiN,GAAejN,IAElB0kB,IAEHA,EADA/jB,EAAI,CAACd,EAAOG,GACI1B,EAAQiR,GACxB1P,EAAQc,EAAE,GACVX,EAAMW,EAAE,IAETykB,EAAYvlB,EAAM6B,MAAMwV,KAAyB,GACzC7F,EAAS6F,GAAqBpO,KAAK9I,IAC1CqlB,EAAShU,EAAO,GAChBiU,EAAQtlB,EAAI6S,UAAU7F,EAAOqE,EAAOrE,OAChCuE,EACHA,GAASA,EAAQ,GAAK,EACS,UAArB+T,EAAMplB,QAAQ,KACxBqR,EAAQ,GAEL8T,IAAWD,EAAUM,OACxBH,EAAWtlB,WAAWmlB,EAAUM,EAAW,KAAO,EAElD3B,EAAG3c,IAAM,CACR3D,MAAOsgB,EAAG3c,IACVtF,EAAIwjB,GAAwB,IAAfI,EAAoBJ,EAAQ,IACzCnY,EAAGoY,EACHxU,EAAwB,MAArBsU,EAAOtlB,OAAO,GAAaH,GAAe2lB,EAAUF,GAAUE,EAAWtlB,WAAWolB,GAAUE,EACjGI,EAAIpU,GAASA,EAAQ,EAAK9R,KAAKC,MAAQ,GAExCsN,EAAQkK,GAAqBrF,kBAG/BkS,EAAGhT,EAAK/D,EAAQhN,EAAItB,OAAUsB,EAAI6S,UAAU7F,EAAOhN,EAAItB,QAAU,GACjEqlB,EAAG6B,GAAKjB,GACJxN,GAAQrF,KAAK9R,IAAQwlB,KACxBzB,EAAGS,EAAI,QAEHpd,IAAM2c,GA4BwBtL,KAAKoE,KAAMve,EAAQiR,EAAMuV,EAAa9kB,EAAK+kB,EAAQL,GAAgB5O,EAAQ4O,aAAcC,KAN1HZ,EAAK,IAAIrU,GAAUmN,KAAKzV,IAAK9I,EAAQiR,GAAOuV,GAAe,EAAG9kB,GAAO8kB,GAAe,GAA6B,kBAAlBD,EAA8BgB,GAAiBC,GAAc,EAAGf,GAC/JJ,IAAcZ,EAAG6B,GAAKjB,GACtBhW,GAAYoV,EAAGpV,SAASA,EAAUkO,KAAMve,GAChCue,KAAKzV,IAAM2c,IAmCtB5c,GAAa,SAAbA,WAAc1G,EAAOS,EAAMgG,OAWzB6e,EAAW1nB,EAAGyD,EAAGiiB,EAAIzlB,EAAQ0nB,EAAaC,EAAQznB,EAASslB,EAAQE,EAAUhX,EAAOkZ,EAAaC,EAV9F3jB,EAAO/B,EAAM+B,KACduH,EAAkGvH,EAAlGuH,KAAMtB,EAA4FjG,EAA5FiG,QAAS/D,EAAmFlC,EAAnFkC,gBAAiB2C,EAAkE7E,EAAlE6E,KAAM+Z,EAA4D5e,EAA5D4e,SAAU5Y,EAAkDhG,EAAlDgG,aAAc2K,EAAoC3Q,EAApC2Q,SAAUxQ,EAA0BH,EAA1BG,UAAWgC,EAAenC,EAAfmC,WACrFmD,EAAMrH,EAAM0D,KACZiiB,EAAc3lB,EAAMc,SACpBpD,EAAUsC,EAAMgiB,SAChBhgB,EAAShC,EAAMgC,OAEf4jB,EAAe5jB,GAA0B,WAAhBA,EAAOmV,KAAqBnV,EAAOD,KAAKrE,QAAUA,EAC3EmoB,EAAsC,SAArB7lB,EAAM8lB,aAA2B9R,EAClDmO,EAAKniB,EAAMsF,aAEZ6c,GAAQjgB,GAAcoH,IAAUA,EAAO,QACvCtJ,EAAM4S,MAAQrJ,GAAWD,EAAMqM,EAAUrM,MACzCtJ,EAAM6S,OAASH,EAAWtH,GAAY7B,IAAwB,IAAbmJ,EAAoBpJ,EAAOoJ,EAAUiD,EAAUrM,OAAS,EACrGoJ,GAAY1S,EAAM2S,QAAU3S,EAAMoE,UACrCsO,EAAW1S,EAAM6S,OACjB7S,EAAM6S,OAAS7S,EAAM4S,MACrB5S,EAAM4S,MAAQF,GAEf1S,EAAM+lB,OAAS5D,KAAQpgB,EAAKgG,cACvBoa,GAAOjgB,IAAcH,EAAKqd,QAAU,IAExCqG,GADA1nB,EAAUL,EAAQ,GAAKW,GAAUX,EAAQ,IAAIK,QAAU,IAC9BgE,EAAKhE,EAAQ+Q,MACtCwW,EAAY3jB,GAAeI,EAAMgN,IAC7B4W,IACHA,EAAYjgB,OAAS,GAAKigB,EAAYtY,SAAS,GAC9C5M,EAAO,GAAKsH,GAAgB9D,IAAoBC,EAAcyhB,EAAYrlB,QAAQ,GAAG,GAAQqlB,EAAY5hB,OAAOgE,GAAgBV,EAAMrD,GAAsB2S,IAE7JgP,EAAYtlB,MAAQ,GAEjB2H,MACH7E,GAAkBnD,EAAMc,SAAWmH,GAAMoU,IAAI3e,EAAS4D,GAAa,CAAC6V,KAAM,UAAWvB,WAAW,EAAO5T,OAAQA,EAAQiC,iBAAiB,EAAM2C,MAAO+e,GAAevpB,EAAYwK,GAAOoB,QAAS,KAAM6N,MAAO,EAAG8K,SAAUA,GAAa,kBAAMrT,GAAUtN,EAAO,aAAcof,QAAS,GAAIpX,KACzRhI,EAAMc,SAASyB,IAAM,EACrBvC,EAAMc,SAASqc,KAAOnd,EACrBS,EAAO,IAAMG,IAAgBqD,IAAoBC,IAAiBlE,EAAMc,SAASiD,OAAOC,IACrFC,GACCoD,GAAO5G,GAAQ,GAAKgG,GAAS,cAChChG,IAAST,EAAM0F,OAASjF,SAIpB,GAAIsH,GAAgBV,IAErBse,KACJllB,IAASwD,GAAkB,GAC3B5C,EAAIC,GAAa,CAChBsU,WAAW,EACXuB,KAAM,cACNvQ,KAAM3C,IAAoB0hB,GAAevpB,EAAYwK,GACrD3C,gBAAiBA,EACjBmb,QAAS,EACTpd,OAAQA,GACNsjB,GACHG,IAAgBpkB,EAAEtD,EAAQ+Q,MAAQ2W,GAClCtiB,GAAkBnD,EAAMc,SAAWmH,GAAMoU,IAAI3e,EAAS2D,IACtDrB,EAAMc,SAASyB,IAAM,EACrBvC,EAAMc,SAASqc,KAAOnd,EACrBS,EAAO,IAAOG,EAAaZ,EAAMc,SAASiD,OAAOC,IAAuBhE,EAAMc,SAASR,QAAQ,GAAG,IACnGN,EAAM0F,OAASjF,EACVwD,GAEE,IAAKxD,cADXiG,WAAW1G,EAAMc,SAAUmE,EAAUA,OAMxCjF,EAAM2G,IAAM3G,EAAMgmB,SAAW,EAC7Bpf,EAAQS,GAAOjL,EAAYwK,IAAWA,IAASS,EAC1CzJ,EAAI,EAAGA,EAAIF,EAAQO,OAAQL,IAAK,IAEpC4nB,GADA3nB,EAASH,EAAQE,IACDE,OAASL,GAASC,GAASE,GAAGE,MAC9CkC,EAAMyc,UAAU7e,GAAK2lB,EAAW,GAChCnjB,GAAYolB,EAAOrJ,KAAOlc,GAAYhC,QAAU8B,KAChDwM,EAAQqZ,IAAgBloB,EAAUE,EAAIgoB,EAAY9lB,QAAQjC,GACtDE,IAA0G,KAA9FslB,EAAS,IAAItlB,GAAW6P,KAAK/P,EAAQ4nB,GAAeH,EAAWtlB,EAAOuM,EAAOqZ,KAC5F5lB,EAAM2G,IAAM2c,EAAK,IAAIrU,GAAUjP,EAAM2G,IAAK9I,EAAQwlB,EAAO/lB,KAAM,EAAG,EAAG+lB,EAAO/iB,OAAQ+iB,EAAQ,EAAGA,EAAOM,UACtGN,EAAOxV,OAAO/O,QAAQ,SAAAxB,GAASimB,EAASjmB,GAAQgmB,IAChDD,EAAOM,WAAa4B,EAAc,KAE9BxnB,GAAW0nB,MACVpkB,KAAKikB,EACL1W,GAASvN,KAAOgiB,EAASD,GAAa/hB,EAAGikB,EAAWtlB,EAAOuM,EAAO1O,EAAQ+nB,IAC7EvC,EAAOM,WAAa4B,EAAc,GAElChC,EAASliB,GAAKiiB,EAAKtV,GAAcgK,KAAKhY,EAAOnC,EAAQwD,EAAG,MAAOikB,EAAUjkB,GAAIkL,EAAOqZ,EAAa,EAAG7jB,EAAKkiB,cAI5GjkB,EAAMimB,KAAOjmB,EAAMimB,IAAIroB,IAAMoC,EAAMoN,KAAKvP,EAAQmC,EAAMimB,IAAIroB,IACtDioB,GAAiB7lB,EAAM2G,MAC1Bib,GAAoB5hB,EACpBiC,EAAgBqf,aAAazjB,EAAQ0lB,EAAUvjB,EAAMkd,WAAWzc,IAChEilB,GAAe1lB,EAAMgC,OACrB4f,GAAoB,GAErB5hB,EAAM2G,KAAOC,IAASxG,GAAYolB,EAAOrJ,IAAM,GAEhDoJ,GAAeW,GAA0BlmB,GACzCA,EAAMmmB,SAAWnmB,EAAMmmB,QAAQnmB,GAEhCA,EAAMke,UAAYyC,EAClB3gB,EAAMa,WAAab,EAAMimB,KAAOjmB,EAAM2G,OAAS+e,EAC9CxjB,GAAazB,GAAQ,GAAM0hB,EAAG7hB,OAAOuK,GAAS,GAAM,IAyEtD4Y,GAAqB,SAArBA,mBAAsB1nB,EAAOiE,EAAOpC,EAAGC,EAAQH,UAAa1B,EAAYD,GAASA,EAAMic,KAAKhY,EAAOpC,EAAGC,EAAQH,GAAY5B,EAAUC,KAAWA,EAAM+D,QAAQ,WAAc0M,GAAezQ,GAASA,GACnMqqB,GAAqBpP,GAAiB,4DACtCqP,GAAsB,GACvB3nB,GAAa0nB,GAAqB,kDAAmD,SAAA9oB,UAAQ+oB,GAAoB/oB,GAAQ,QA8B5G2K,8BAEAvK,EAASqE,EAAM6D,EAAU0gB,SACf,iBAAVvkB,IACV6D,EAASrB,SAAWxC,EACpBA,EAAO6D,EACPA,EAAW,UAMXuc,EAAIvkB,EAAGiE,EAAMhC,EAAGwB,EAAGklB,EAAWC,EAAaC,mBAJtCH,EAAcvkB,EAAOD,GAAiBC,WACsEA,KAA5GwC,IAAAA,SAAUsR,IAAAA,MAAO5R,IAAAA,gBAAiBmb,IAAAA,QAASxJ,IAAAA,UAAW1T,IAAAA,UAAWX,IAAAA,SAAU4L,IAAAA,cAAeuF,IAAAA,SAC/F1Q,EAASD,EAAKC,QAAUC,EACxB6f,GAAiBzf,EAAS3E,IAAY2Y,EAAc3Y,GAAWzB,EAAUyB,EAAQ,IAAO,WAAYqE,GAAS,CAACrE,GAAWY,GAAQZ,QAE7HskB,SAAWF,EAAc7jB,OAASR,GAASqkB,GAAiB5kB,EAAM,eAAiBQ,EAAU,gCAAiC2X,EAAQG,iBAAmB,KACzJiH,UAAY,KACZqJ,WAAalQ,EACd1T,GAAakd,GAAW7iB,EAAgBgI,IAAahI,EAAgBsZ,GAAQ,IAChF9T,EAAO2kB,EAAK3kB,MACZogB,EAAKuE,EAAKphB,SAAW,IAAIkC,GAAS,CAAC2P,KAAM,SAAU5V,SAAUA,GAAY,GAAI7D,QAASsE,GAA0B,WAAhBA,EAAOmV,KAAoBnV,EAAOD,KAAKrE,QAAUokB,KAC9I1U,OACH+U,EAAGngB,OAASmgB,EAAG5f,8BACf4f,EAAGxe,OAAS,EACRyb,GAAW7iB,EAAgBgI,IAAahI,EAAgBsZ,GAAQ,IACnEhW,EAAIiiB,EAAc7jB,OAClBuoB,EAAcpH,GAAWhW,GAAWgW,GAChCjjB,EAAUijB,OACR/d,KAAK+d,GACJgH,GAAmBtmB,QAAQuB,MACRolB,EAAvBA,GAA4C,IACzBplB,GAAK+d,EAAQ/d,QAI9BzD,EAAI,EAAGA,EAAIiC,EAAGjC,KAClBiE,EAAOF,GAAeI,EAAMskB,KACvBjH,QAAU,EACf1M,IAAa7Q,EAAK6Q,SAAWA,GAC7B+T,GAAsB9pB,GAAOkF,EAAM4kB,GACnCF,EAAYzE,EAAclkB,GAE1BiE,EAAK0C,UAAYkf,GAAmBlf,4BAAgB3G,EAAG2oB,EAAWzE,GAClEjgB,EAAKgU,QAAU4N,GAAmB5N,4BAAajY,EAAG2oB,EAAWzE,IAAkB,GAAK4E,EAAK3gB,QACpFqZ,GAAiB,IAANvf,GAAWgC,EAAKgU,UAC1B9P,OAAS8P,EAAQhU,EAAKgU,QACtBlS,QAAUkS,EACfhU,EAAKgU,MAAQ,GAEdsM,EAAGrD,GAAGyH,EAAW1kB,EAAM2kB,EAAcA,EAAY5oB,EAAG2oB,EAAWzE,GAAiB,GAChFK,EAAGvP,MAAQpB,GAASuK,KAErBoG,EAAG5d,WAAcA,EAAWsR,EAAQ,EAAM6Q,EAAKphB,SAAW,OACpD,GAAIpD,EAAW,CACrBJ,GAAiBR,GAAa6gB,EAAGpgB,KAAKR,SAAU,CAAC+H,KAAK,UACtD6Y,EAAGvP,MAAQrJ,GAAWrH,EAAUoH,MAAQvH,EAAKuH,MAAQ,YAEpDpJ,EAAGymB,EAAInoB,EADJiC,EAAO,KAEP4B,EAASH,GACZA,EAAUpD,QAAQ,SAAAiI,UAASob,EAAGrD,GAAGgD,EAAe/a,EAAO,OACvDob,EAAG5d,eACG,KAEDlD,KADLQ,EAAO,GACGK,EACH,SAANb,GAAsB,aAANA,GAAoBuiB,GAAeviB,EAAGa,EAAUb,GAAIQ,EAAMK,EAAU4hB,cAEhFziB,KAAKQ,MACT3B,EAAI2B,EAAKR,GAAG6H,KAAK,SAAChJ,EAAGgL,UAAMhL,EAAE2C,EAAIqI,EAAErI,IAE9BjF,EADL6C,EAAO,EACK7C,EAAIsC,EAAEjC,OAAQL,KAEzBY,EAAI,CAAC8K,MADLqd,EAAKzmB,EAAEtC,IACOmmB,EAAGxf,UAAWoiB,EAAG9jB,GAAKjF,EAAIsC,EAAEtC,EAAI,GAAGiF,EAAI,IAAM,IAAM0B,IAC/DlD,GAAKslB,EAAGnoB,EACV2jB,EAAGrD,GAAGgD,EAAetjB,EAAGiC,GACxBA,GAAQjC,EAAE+F,SAGZ4d,EAAG5d,WAAaA,GAAY4d,EAAGrD,GAAG,GAAI,CAACva,SAAUA,EAAW4d,EAAG5d,cAGjEA,GAAYmiB,EAAKniB,SAAUA,EAAW4d,EAAG5d,mBAGpCe,SAAW,SAGC,IAAdsQ,GAAuB5B,IAC1B4N,6BACA3f,EAAgBqf,aAAaQ,GAC7BF,GAAoB,GAErBjc,GAAe3D,4BAAc4D,GAC7B7D,EAAK2b,UAAYgJ,EAAK/I,UACtB5b,EAAK+a,QAAU4J,EAAK5J,QAAO,IACvB7Y,IAAqBM,IAAarC,GAAawkB,EAAK/iB,SAAWzE,GAAc8C,EAAOoD,QAAUhJ,EAAY6H,IAxpEvF,SAAxB2iB,sBAAwBpmB,UAAcA,GAAcA,EAAUmE,KAAOiiB,sBAAsBpmB,EAAUwB,QAwpE8B4kB,6BAA+C,WAAhB5kB,EAAOmV,UAClK7S,QAAUW,IACV3E,OAAOtB,KAAKwL,IAAI,GAAIqL,IAAU,IAEpC1I,GAAiB/G,6BAAqB+G,4DAGvC7M,OAAA,gBAAOwD,EAAWpD,EAAgBC,OAMhCF,EAAM6iB,EAAI3G,EAAW1F,EAAe6I,EAAetN,EAAQmM,EAAOrZ,EAAUoN,EALzEqN,EAAW3D,KAAKhX,MACnB4a,EAAO5D,KAAKvX,MACZwC,EAAM+U,KAAK1Y,KACXmjB,EAAa/iB,EAAY,EACzB2C,EAAqBuZ,EAAO/a,EAAnBnB,IAAgC+iB,EAAc7G,EAAQlc,EAAYmB,EAAY,EAAInB,KAEvFuD,GAEE,GAAIZ,IAAU2V,KAAK9X,SAAWR,GAAanD,IAAWyb,KAAKvb,UAAYub,KAAK9X,QAAY8X,KAAKtb,UAAasb,KAAK1W,OAAS,GAAOmhB,GAAezK,KAAK/b,MAAO,IAChKI,EAAOgG,EACPnB,EAAW8W,KAAK9W,SACZ8W,KAAKhY,QAAS,IACjB6S,EAAgB5P,EAAM+U,KAAK5X,QACvB4X,KAAKhY,SAAW,GAAKyiB,SACjBzK,KAAKtY,UAA0B,IAAhBmT,EAAsBnT,EAAWpD,EAAgBC,MAExEF,EAAOvB,GAAcuH,EAAQwQ,GACzBxQ,IAAUuZ,GACbrD,EAAYP,KAAKhY,QACjB3D,EAAO4G,IAGPsV,KADAmD,EAAgB5gB,GAAcuH,EAAQwQ,MAErB0F,IAAcmD,GAC9Brf,EAAO4G,EACPsV,KACiBtV,EAAP5G,IACVA,EAAO4G,IAGTmL,EAAS4J,KAAKzJ,OAAsB,EAAZgK,KAEvBjK,EAAW0J,KAAKvJ,OAChBpS,EAAO4G,EAAM5G,GAEdqf,EAAgBzb,GAAgB+X,KAAK9X,OAAQ2S,GACzCxW,IAASsf,IAAapf,GAASyb,KAAKvb,UAAY8b,IAAcmD,cAE5Dxb,OAASmC,EACP2V,KAEJO,IAAcmD,IACjBxa,GAAY8W,KAAKvJ,QAAUN,GAAmBjN,EAAUkN,GAEpD4J,KAAKra,KAAKse,gBAAkB7N,IAAW4J,KAAK8D,OAASzf,IAASwW,GAAiBmF,KAAKvb,gBAClFqf,MAAQvf,EAAQ,OAChBL,OAAOpB,GAAc+X,EAAgB0F,IAAY,GAAMoB,aAAamC,MAAQ,QAK/E9D,KAAKvb,SAAU,IACf2F,GAAkB4V,KAAMyK,EAAa/iB,EAAYrD,EAAME,EAAOD,EAAgB+F,eAC5EnC,OAAS,EACP8X,UAEJ2D,IAAa3D,KAAKhX,OAAWzE,GAASyb,KAAKra,KAAKse,eAAiB1D,IAAcmD,UAC3E1D,QAEJ/U,IAAQ+U,KAAK1Y,YACT0Y,KAAK9b,OAAOwD,EAAWpD,EAAgBC,WAI3C2D,OAASmC,OACTrB,MAAQ3E,GAER2b,KAAK7Y,MAAQ6Y,KAAKzX,WACjBpB,KAAO,OACPlD,MAAQ,QAGTse,MAAQA,GAASjM,GAAY0J,KAAKxJ,OAAOnS,EAAO4G,GACjD+U,KAAK2J,aACHpH,MAAQA,EAAQ,EAAIA,GAGtBle,IAASsf,IAAarf,IAAmBic,IAC5CrP,GAAU8O,KAAM,WACZA,KAAK9X,SAAWmC,UACZ2V,SAGTkH,EAAKlH,KAAKzV,IACH2c,GACNA,EAAG3T,EAAEgP,EAAO2E,EAAGhZ,GACfgZ,EAAKA,EAAGtgB,MAERsC,GAAYA,EAAShF,OAAOwD,EAAY,EAAIA,EAAYwB,EAAS5B,KAAO4B,EAASsN,MAAMnS,EAAO2b,KAAK1Y,MAAOhD,EAAgBC,IAAYyb,KAAKtb,WAAasb,KAAK1W,OAAS5B,GAEnKsY,KAAK8B,YAAcxd,IACtBmmB,GAAchjB,GAAeuY,KAAMtY,EAAWpD,EAAgBC,GAC9D2M,GAAU8O,KAAM,kBAGZhY,SAAWuY,IAAcmD,GAAiB1D,KAAKra,KAAKue,WAAa5f,GAAkB0b,KAAKpa,QAAUsL,GAAU8O,KAAM,YAElH3V,IAAU2V,KAAKvX,OAAU4B,GAAU2V,KAAK9X,SAAWmC,IACvDogB,IAAezK,KAAK8B,WAAara,GAAeuY,KAAMtY,EAAW,GAAM,IACtEA,GAAcuD,KAAUZ,IAAU2V,KAAKvX,OAAoB,EAAXuX,KAAKzX,MAAc8B,GAAS2V,KAAKzX,IAAM,IAAOxB,GAAkBiZ,KAAM,GAC/G1b,GAAoBmmB,IAAe9G,KAActZ,GAASsZ,GAAYvN,KAC7ElF,GAAU8O,KAAO3V,IAAUuZ,EAAO,aAAe,qBAAsB,SAClEtB,OAAWjY,EAAQuZ,GAA2B,EAAnB5D,KAAKpW,aAAoBoW,KAAKsC,gBA7rEvC,SAA3BoI,yBAA4B9mB,EAAO8D,EAAWpD,EAAgBC,OAK5D2iB,EAAI3G,EAAWmD,EAJZiH,EAAY/mB,EAAM2e,MACrBA,EAAQ7a,EAAY,IAAOA,KAAgB9D,EAAM2D,QAJpB,SAA/BqjB,oCAAiChlB,IAAAA,cAAYA,GAAUA,EAAO2C,KAAO3C,EAAOnB,WAAamB,EAAOke,QAAUle,EAAOwD,UAAY,GAAKwhB,6BAA6BhlB,IAIlGglB,CAA6BhnB,KAAaA,EAAMa,WAAYqF,GAAmBlG,MAAcA,EAAM2E,IAAM,GAAK3E,EAAMuC,IAAIoC,IAAM,KAAOuB,GAAmBlG,IAAY,EAAI,EACnOod,EAAcpd,EAAMwE,QACpBiC,EAAQ,KAEL2W,GAAepd,EAAMoE,UACxBqC,EAAQhB,GAAO,EAAGzF,EAAM6E,MAAOf,GAC/B6Y,EAAYtY,GAAgBoC,EAAO2W,GACnCpd,EAAM2S,OAAsB,EAAZgK,IAAmBgC,EAAQ,EAAIA,GAC3ChC,IAActY,GAAgBrE,EAAMsE,OAAQ8Y,KAC/C2J,EAAY,EAAIpI,EAChB3e,EAAM+B,KAAKse,eAAiBrgB,EAAMa,UAAYb,EAAM+d,eAGlDY,IAAUoI,GAAanmB,GAAcD,GAASX,EAAM0F,SAAWT,IAAcnB,GAAa9D,EAAM0F,OAAS,KACvG1F,EAAMa,UAAY2F,GAAkBxG,EAAO8D,EAAWnD,EAAOD,EAAgB+F,cAGlFqZ,EAAgB9f,EAAM0F,OACtB1F,EAAM0F,OAAS5B,IAAcpD,EAAiBuE,EAAW,GACtCvE,EAAnBA,GAAoCoD,IAAcgc,EAClD9f,EAAM2e,MAAQA,EACd3e,EAAM+lB,QAAUpH,EAAQ,EAAIA,GAC5B3e,EAAMoF,MAAQ,EACdpF,EAAMsE,OAASmC,EACf6c,EAAKtjB,EAAM2G,IACJ2c,GACNA,EAAG3T,EAAEgP,EAAO2E,EAAGhZ,GACfgZ,EAAKA,EAAGtgB,MAETc,EAAY,GAAKD,GAAe7D,EAAO8D,EAAWpD,GAAgB,GAClEV,EAAMke,YAAcxd,GAAkB4M,GAAUtN,EAAO,YACvDyG,GAASzG,EAAMoE,UAAY1D,GAAkBV,EAAMgC,QAAUsL,GAAUtN,EAAO,aACzE8D,GAAa9D,EAAM6E,OAASf,EAAY,IAAM9D,EAAM2e,QAAUA,IAClEA,GAASxb,GAAkBnD,EAAO,GAC7BU,GAAmBE,IACvB0M,GAAUtN,EAAQ2e,EAAQ,aAAe,qBAAsB,GAC/D3e,EAAM0e,OAAS1e,EAAM0e,eAGZ1e,EAAM0F,SACjB1F,EAAM0F,OAAS5B,GAojEfgjB,CAAyB1K,KAAMtY,EAAWpD,EAAgBC,UAoGpDyb,QAGR1e,QAAA,0BACQ0e,KAAK4F,YAGbjE,WAAA,oBAAWiF,UACRA,GAAS5G,KAAKra,KAAKgG,eAAkBqU,KAAKtb,SAAW,QAClD6F,IAAMyV,KAAK6J,IAAM7J,KAAK8B,UAAY9B,KAAK/b,MAAQ+b,KAAKuC,MAAQ,OAC5DlC,UAAY,QACZnX,UAAY8W,KAAK9W,SAASyY,WAAWiF,eAC7BjF,qBAAWiF,MAGzBiE,QAAA,iBAAQlqB,EAAUhB,EAAOqD,EAAO8nB,EAAiBC,GAChD9S,GAAiBvN,GAAQwT,YACpB3V,KAAOyX,KAAKqB,WAEhBkB,EADGle,EAAOzB,KAAKyL,IAAI2R,KAAK1Y,MAAO0Y,KAAK7Z,IAAI6C,MAAQgX,KAAKzY,QAAUyY,KAAKzX,iBAEhE9D,UAAY6F,GAAW0V,KAAM3b,GAClCke,EAAQvC,KAAKxJ,MAAMnS,EAAO2b,KAAK1Y,MA5UZ,SAApB0jB,kBAAqBpnB,EAAOjD,EAAUhB,EAAOqD,EAAO8nB,EAAiBvI,EAAOle,EAAM0mB,OAEhF7D,EAAI+D,EAAQC,EAAQ1pB,EADjB2pB,GAAYvnB,EAAM2G,KAAO3G,EAAMgmB,WAAchmB,EAAMgmB,SAAW,KAAKjpB,OAElEwqB,MACJA,EAAUvnB,EAAMgmB,SAASjpB,GAAY,GACrCuqB,EAAStnB,EAAMyc,UACf7e,EAAIoC,EAAMgiB,SAAS/jB,OACZL,KAAK,KACX0lB,EAAKgE,EAAO1pB,GAAGb,KACLumB,EAAGhZ,GAAKgZ,EAAGhZ,EAAE3D,QACtB2c,EAAKA,EAAGhZ,EAAE3D,IACH2c,GAAMA,EAAGjiB,IAAMtE,GAAYumB,EAAG6B,KAAOpoB,GAC3CumB,EAAKA,EAAGtgB,UAGLsgB,SAEJU,GAAsB,EACtBhkB,EAAM+B,KAAKhF,GAAY,MACvB2J,GAAW1G,EAAOS,GAClBujB,GAAsB,EACfmD,EAAgBjqB,EAAMH,EAAW,2BAA6B,EAEtEwqB,EAAQvgB,KAAKsc,OAGf1lB,EAAI2pB,EAAQtpB,OACLL,MAEN0lB,GADA+D,EAASE,EAAQ3pB,IACL+I,KAAO0gB,GAChB3a,GAAKtN,GAAmB,IAAVA,GAAiB8nB,EAA0B5D,EAAG5W,GAAKtN,GAAS,GAAKuf,EAAQ2E,EAAGhT,EAAzClR,EACpDkkB,EAAGhT,EAAIvU,EAAQunB,EAAG5W,EAClB2a,EAAOtD,IAAMsD,EAAOtD,EAAIhlB,GAAOhD,GAASoM,GAAQkf,EAAOtD,IACvDsD,EAAOnc,IAAMmc,EAAOnc,EAAIoY,EAAG5W,EAAIvE,GAAQkf,EAAOnc,IAoT1Ckc,CAAkBhL,KAAMrf,EAAUhB,EAAOqD,EAAO8nB,EAAiBvI,EAAOle,EAAM0mB,GAC1E/K,KAAK6K,QAAQlqB,EAAUhB,EAAOqD,EAAO8nB,EAAiB,IAG/DhiB,GAAekX,KAAM,QAChBpa,QAAUQ,GAAmB4Z,KAAK7Z,IAAK6Z,KAAM,SAAU,QAASA,KAAK7Z,IAAI0D,MAAQ,SAAW,GAC1FmW,KAAK9b,OAAO,OAGpB8M,KAAA,cAAK1P,EAASqE,eAAAA,IAAAA,EAAO,SACfrE,GAAaqE,GAAiB,QAATA,eACpB1B,MAAQ+b,KAAKzV,IAAM,OACnB3E,OAASkL,GAAWkP,MAAQA,KAAKjP,eAAiBiP,KAAKjP,cAAcC,OAAOxM,GAC1Ewb,QAEJA,KAAK9W,SAAU,KACd0a,EAAO5D,KAAK9W,SAASV,4BACpBU,SAASgc,aAAa5jB,EAASqE,EAAM6f,KAA0D,IAArCA,GAAkB7f,KAAK6T,WAAoBnD,QAAUvF,GAAWkP,WAC1Hpa,QAAUge,IAAS5D,KAAK9W,SAASV,iBAAmBqC,GAAamV,KAAMA,KAAK1Y,KAAO0Y,KAAK9W,SAAST,MAAQmb,EAAM,EAAG,GAChH5D,SAMPoL,EAAkBC,EAAWC,EAAmBjG,EAAOpgB,EAAGiiB,EAAI1lB,EAJ3DkkB,EAAgB1F,KAAK4F,SACxB2F,EAAiBjqB,EAAUY,GAAQZ,GAAWokB,EAC9C8F,EAAkBxL,KAAKK,UACvBoL,EAAUzL,KAAKzV,SAEV5E,GAAiB,QAATA,IAz4EA,SAAf+lB,aAAgBC,EAAIC,WACfpqB,EAAImqB,EAAG9pB,OACVgD,EAAQrD,IAAMoqB,EAAG/pB,OACXgD,GAASrD,KAAOmqB,EAAGnqB,KAAOoqB,EAAGpqB,YAC7BA,EAAI,EAq4EsBkqB,CAAahG,EAAe6F,SACnD,QAAT5lB,IAAmBqa,KAAKzV,IAAM,GACvBuG,GAAWkP,UAEnBoL,EAAmBpL,KAAK6J,IAAM7J,KAAK6J,KAAO,GAC7B,QAATlkB,IACCjG,EAAUiG,KACbV,EAAI,GACJ3C,GAAaqD,EAAM,SAAAzE,UAAQ+D,EAAE/D,GAAQ,IACrCyE,EAAOV,GAERU,EAtVkB,SAApBkmB,kBAAqBvqB,EAASqE,OAG5BF,EAAMR,EAAGzD,EAAG6Q,EAFT1Q,EAAUL,EAAQ,GAAKW,GAAUX,EAAQ,IAAIK,QAAU,EAC1DmqB,EAAmBnqB,GAAWA,EAAQ0Q,YAElCyZ,SACGnmB,MAGHV,KADLQ,EAAOlF,GAAO,GAAIoF,GACRmmB,KACL7mB,KAAKQ,MAERjE,GADA6Q,EAAUyZ,EAAgB7mB,GAAGxC,MAAM,MACvBZ,OACNL,KACLiE,EAAK4M,EAAQ7Q,IAAMiE,EAAKR,UAKpBQ,EAoUComB,CAAkBnG,EAAe/f,IAEzCnE,EAAIkkB,EAAc7jB,OACXL,SACD+pB,EAAe7nB,QAAQgiB,EAAclkB,QAUpCyD,KATLomB,EAAYG,EAAgBhqB,GACf,QAATmE,GACHylB,EAAiB5pB,GAAKmE,EACtB0f,EAAQgG,EACRC,EAAoB,KAEpBA,EAAoBF,EAAiB5pB,GAAK4pB,EAAiB5pB,IAAM,GACjE6jB,EAAQ1f,GAEC0f,GACT6B,EAAKmE,GAAaA,EAAUpmB,MAErB,SAAUiiB,EAAGhZ,IAAuB,IAAjBgZ,EAAGhZ,EAAE8C,KAAK/L,IAClC4B,GAAsBmZ,KAAMkH,EAAI,cAE1BmE,EAAUpmB,IAEQ,QAAtBqmB,IACHA,EAAkBrmB,GAAK,eAKtBR,WAAaub,KAAKzV,KAAOkhB,GAAW3a,GAAWkP,MAC7CA,YAID0C,GAAP,YAAUphB,EAASqE,EAAnB,UACQ,IAAIkG,MAAMvK,EAASqE,EAD3B,UAIOyH,KAAP,cAAY9L,EAASqE,UACb0F,GAAiB,EAAG+U,kBAGrB0C,YAAP,qBAAmBrJ,EAAO4C,EAAU9Q,EAAQlL,UACpC,IAAIwL,MAAMwQ,EAAU,EAAG,CAACxU,iBAAgB,EAAO2C,MAAK,EAAOgP,WAAU,EAAOC,MAAMA,EAAO0J,WAAW9G,EAAU0P,kBAAkB1P,EAAU+G,iBAAiB7X,EAAQygB,wBAAwBzgB,EAAQkR,cAAcpc,WAGlNsiB,OAAP,gBAAcrhB,EAASshB,EAAUC,UACzBxX,GAAiB,EAAG+U,kBAGrBH,IAAP,aAAW3e,EAASqE,UACnBA,EAAKwC,SAAW,EAChBxC,EAAKqb,cAAgBrb,EAAKqF,OAAS,GAC5B,IAAIa,MAAMvK,EAASqE,UAGpBuf,aAAP,sBAAoB5jB,EAAS+jB,EAAOC,UAC5Bzf,EAAgBqf,aAAa5jB,EAAS+jB,EAAOC,WA1U3BpF,IA8U3Bhb,GAAa2G,GAAM4G,UAAW,CAACmT,SAAS,GAAI3hB,MAAM,EAAGS,SAAS,EAAGmlB,IAAI,EAAGE,QAAQ,IAWhFznB,GAAa,sCAAuC,SAAApB,GACnD2K,GAAM3K,GAAQ,eACT6kB,EAAK,IAAI3a,GACZG,EAASgQ,GAAOK,KAAKwE,UAAW,UACjC7U,EAAOvJ,OAAgB,kBAATd,EAA2B,EAAI,EAAG,EAAG,GAC5C6kB,EAAG7kB,GAAMmU,MAAM0Q,EAAIxa,MA2BR,SAAnB0gB,GAAoBxqB,EAAQd,EAAUhB,UAAU8B,EAAOyqB,aAAavrB,EAAUhB,GAkDxD,SAAtBwsB,GAAuB1qB,EAAQd,EAAUhB,EAAOob,GAC/CA,EAAKqR,KAAK3qB,EAAQd,EAAUoa,EAAK+N,EAAElN,KAAKb,EAAKnX,MAAOjE,EAAOob,EAAKsR,IAAKtR,GAtDvE,IAAIsN,GAAe,SAAfA,aAAgB5mB,EAAQd,EAAUhB,UAAU8B,EAAOd,GAAYhB,GAClEyoB,GAAc,SAAdA,YAAe3mB,EAAQd,EAAUhB,UAAU8B,EAAOd,GAAUhB,IAC5DwoB,GAAuB,SAAvBA,qBAAwB1mB,EAAQd,EAAUhB,EAAOob,UAAStZ,EAAOd,GAAUoa,EAAKgO,GAAIppB,IAEpFyS,GAAa,SAAbA,WAAc3Q,EAAQd,UAAaf,EAAY6B,EAAOd,IAAaynB,GAActoB,EAAa2B,EAAOd,KAAcc,EAAOyqB,aAAeD,GAAmB5D,IAC5JY,GAAe,SAAfA,aAAgB1G,EAAOxH,UAASA,EAAKkF,IAAIlF,EAAKtU,EAAGsU,EAAK9V,EAAGrC,KAAKC,MAAkC,KAA3BkY,EAAKzK,EAAIyK,EAAK7G,EAAIqO,IAAoB,IAASxH,IACpHiO,GAAiB,SAAjBA,eAAkBzG,EAAOxH,UAASA,EAAKkF,IAAIlF,EAAKtU,EAAGsU,EAAK9V,KAAM8V,EAAKzK,EAAIyK,EAAK7G,EAAIqO,GAAQxH,IACxF6N,GAAuB,SAAvBA,qBAAgCrG,EAAOxH,OAClCmM,EAAKnM,EAAKxQ,IACb+F,EAAI,OACAiS,GAASxH,EAAKjM,EAClBwB,EAAIyK,EAAKjM,OACH,GAAc,IAAVyT,GAAexH,EAAK4M,EAC9BrX,EAAIyK,EAAK4M,MACH,MACCT,GACN5W,EAAI4W,EAAGjiB,GAAKiiB,EAAG4B,EAAI5B,EAAG4B,EAAE5B,EAAG5W,EAAI4W,EAAGhT,EAAIqO,GAAU3f,KAAKC,MAA8B,KAAvBqkB,EAAG5W,EAAI4W,EAAGhT,EAAIqO,IAAkB,KAAUjS,EACtG4W,EAAKA,EAAGtgB,MAET0J,GAAKyK,EAAK7G,EAEX6G,EAAKkF,IAAIlF,EAAKtU,EAAGsU,EAAK9V,EAAGqL,EAAGyK,IAE7BpJ,GAAoB,SAApBA,kBAA6B4Q,EAAOxH,WAC/BmM,EAAKnM,EAAKxQ,IACP2c,GACNA,EAAG3T,EAAEgP,EAAO2E,EAAGhZ,GACfgZ,EAAKA,EAAGtgB,OAGVmL,GAAqB,SAArBA,mBAA8BD,EAAUlO,EAAOnC,EAAQd,WAErDmG,EADGogB,EAAKlH,KAAKzV,IAEP2c,GACNpgB,EAAOogB,EAAGtgB,MACVsgB,EAAGjiB,IAAMtE,GAAYumB,EAAGpV,SAASA,EAAUlO,EAAOnC,GAClDylB,EAAKpgB,GAGP+K,GAAoB,SAApBA,kBAA6BlR,WAE3B2rB,EAA0BxlB,EADvBogB,EAAKlH,KAAKzV,IAEP2c,GACNpgB,EAAOogB,EAAGtgB,MACLsgB,EAAGjiB,IAAMtE,IAAaumB,EAAGqF,IAAOrF,EAAGqF,KAAO5rB,EAC9CkG,GAAsBmZ,KAAMkH,EAAI,OACrBA,EAAGsF,MACdF,EAA2B,GAE5BpF,EAAKpgB,SAEEwlB,GAKTxC,GAA4B,SAA5BA,0BAA4BlkB,WAE1BkB,EAAM2lB,EAAKC,EAAOC,EADfzF,EAAKthB,EAAO2E,IAGT2c,GAAI,KACVpgB,EAAOogB,EAAGtgB,MACV6lB,EAAMC,EACCD,GAAOA,EAAIG,GAAK1F,EAAG0F,IACzBH,EAAMA,EAAI7lB,OAENsgB,EAAGvgB,MAAQ8lB,EAAMA,EAAI9lB,MAAQgmB,GACjCzF,EAAGvgB,MAAMC,MAAQsgB,EAEjBwF,EAAQxF,GAEJA,EAAGtgB,MAAQ6lB,GACfA,EAAI9lB,MAAQugB,EAEZyF,EAAOzF,EAERA,EAAKpgB,EAENlB,EAAO2E,IAAMmiB,GAIF7Z,wBAiBZf,SAAA,kBAAStP,EAAMoB,EAAOnC,QAChB2qB,KAAOpM,KAAKoM,MAAQpM,KAAKC,SACzBA,IAAMkM,QACNrD,EAAItmB,OACJ6pB,GAAK5qB,OACLmC,MAAQA,iCApBFkD,EAAMrF,EAAQiR,EAAM1P,EAAO6pB,EAAQC,EAAU/R,EAAMmN,EAAQX,QACjE9gB,EAAIhF,OACJ6O,EAAItN,OACJkR,EAAI2Y,OACJ5nB,EAAIyN,OACJa,EAAIuZ,GAAY7D,QAChB/a,EAAI6M,GAAQiF,UACZC,IAAMiI,GAAUG,QAChBuE,GAAKrF,GAAY,QACjB3gB,MAAQE,KAEZA,EAAKH,MAAQqZ,MAgBhB1d,GAAasY,GAAiB,sOAAuO,SAAA1Z,UAAQyR,GAAezR,GAAQ,IACpSV,GAASusB,SAAWvsB,GAASwsB,UAAYnhB,GACzCrL,GAASysB,aAAezsB,GAAS0sB,YAAc9hB,GAC/CvF,EAAkB,IAAIuF,GAAS,CAACoX,cAAc,EAAOrd,SAAUoU,EAAWtS,oBAAoB,EAAM8Y,GAAG,OAAQhX,mBAAmB,IAClIkQ,EAAQ4O,aAAe/S,GAoBV,SAAZqY,GAAY7hB,UAASyN,GAAWzN,IAAS8hB,IAAarZ,IAAI,SAAA0K,UAAKA,MAC9C,SAAjB4O,SACKhpB,EAAOuZ,KAAKC,MACfyP,EAAU,GACiB,EAAxBjpB,EAAOkpB,KACVJ,GAAU,kBACVK,GAAO9qB,QAAQ,SAAAwR,OAGbrP,EAAOI,EAAGwoB,EAAUC,EAFjBC,EAAUzZ,EAAEyZ,QACfC,EAAa1Z,EAAE0Z,eAEX3oB,KAAK0oB,GACT9oB,EAAQwH,EAAKwhB,WAAWF,EAAQ1oB,IAAIqoB,WAC1BG,EAAW,GACjB5oB,IAAU+oB,EAAW3oB,KACxB2oB,EAAW3oB,GAAKJ,EAChB6oB,EAAU,GAGRA,IACHxZ,EAAEvM,SACF8lB,GAAYH,EAAQ1iB,KAAKsJ,MAG3BiZ,GAAU,oBACVG,EAAQ5qB,QAAQ,SAAAwR,UAAKA,EAAE4Z,QAAQ5Z,EAAG,SAAA1R,UAAQ0R,EAAE/K,IAAI,KAAM3G,OACtD+qB,GAAiBlpB,EACjB8oB,GAAU,eA/Bb,OAAIK,GAAS,GACZzU,GAAa,GACbqU,GAAc,GACdG,GAAiB,EACjBQ,GAAa,EA+BRC,2BASL7kB,IAAA,aAAIjI,EAAMsB,EAAMnC,GAYV,SAAJoe,SAGEjK,EAFG9N,EAAOmR,EACVoW,EAAehM,EAAK3V,gBAErB5F,GAAQA,IAASub,GAAQvb,EAAKqU,KAAKnQ,KAAKqX,GACxC5hB,IAAU4hB,EAAK3V,SAAWA,GAASjM,IACnCwX,EAAWoK,EACXzN,EAAShS,EAAK6S,MAAM4M,EAAM7B,WAC1BxgB,EAAY4U,IAAWyN,EAAKiM,GAAGtjB,KAAK4J,GACpCqD,EAAWnR,EACXub,EAAK3V,SAAW2hB,EAChBhM,EAAKkM,YAAa,EACX3Z,EAlBL5U,EAAYsB,KACfb,EAAQmC,EACRA,EAAOtB,EACPA,EAAOtB,OAEJqiB,EAAOjC,YAeXiC,EAAK0K,KAAOlO,GACLvd,IAAStB,EAAc6e,GAAEwD,EAAM,SAAAzf,UAAQyf,EAAK9Y,IAAI,KAAM3G,KAAStB,EAAQ+gB,EAAK/gB,GAAQud,GAAKA,OAEjG2P,OAAA,gBAAO5rB,OACFkE,EAAOmR,EACXA,EAAW,KACXrV,EAAKwd,MACLnI,EAAWnR,MAEZ2nB,UAAA,yBACKvqB,EAAI,eACHiX,KAAKrY,QAAQ,SAAAilB,UAAMA,aAAaqG,QAAWlqB,EAAE8G,WAAF9G,EAAU6jB,EAAE0G,aAAgB1G,aAAa9b,MAAY8b,EAAE/hB,QAA4B,WAAlB+hB,EAAE/hB,OAAOmV,OAAsBjX,EAAE8G,KAAK+c,KAChJ7jB,MAER+iB,MAAA,sBACMqH,GAAGrsB,OAASme,KAAKjF,KAAKlZ,OAAS,MAErCmP,KAAA,cAAKrJ,EAAQkmB,iBACRlmB,qBAGFlB,EAFGme,EAAS0J,EAAKD,YACjB7sB,EAAI8sB,EAAKvT,KAAKlZ,OAERL,KAES,YADfiF,EAAI6nB,EAAKvT,KAAKvZ,IACRuZ,OACLtU,EAAEkB,SACFlB,EAAEke,aAAY,GAAM,GAAM,GAAOjiB,QAAQ,SAAAkB,UAASghB,EAAO5iB,OAAO4iB,EAAOlhB,QAAQE,GAAQ,UAIzFghB,EAAO7Q,IAAI,SAAAtN,SAAc,CAAC+M,EAAG/M,EAAEa,MAAQb,EAAEkD,QAAWlD,EAAEsa,OAASta,EAAEsa,KAAKpb,KAAKkC,gBAAmBpB,EAAEqa,WAAW,IAAK,EAAA,EAAWra,EAAAA,KAAKqG,KAAK,SAAChJ,EAAGgL,UAAMA,EAAE0E,EAAI1P,EAAE0P,IAAK,EAAA,IAAW9Q,QAAQ,SAAA6rB,UAAKA,EAAE9nB,EAAEkB,OAAOA,KAC/LnG,EAAI8sB,EAAKvT,KAAKlZ,OACPL,MACNiF,EAAI6nB,EAAKvT,KAAKvZ,cACG4J,GACD,WAAX3E,EAAEsU,OACLtU,EAAEsK,eAAiBtK,EAAEsK,cAAcpJ,SACnClB,EAAEuK,QAGDvK,aAAaoF,KAAUpF,EAAEkB,QAAUlB,EAAEkB,OAAOA,GAGhD2mB,EAAKJ,GAAGxrB,QAAQ,SAAA+b,UAAKA,EAAE9W,EAAQ2mB,KAC/BA,EAAKH,YAAa,UAEbpT,KAAKrY,QAAQ,SAAAilB,UAAKA,EAAE3W,MAAQ2W,EAAE3W,cAE/B6V,QACDgH,UACCrsB,EAAIgsB,GAAO3rB,OACRL,KACNgsB,GAAOhsB,GAAGue,KAAOC,KAAKD,IAAMyN,GAAOxrB,OAAOR,EAAG,OAUhDmG,OAAA,gBAAOyJ,QACDJ,KAAKI,GAAU,+BAjGT5O,EAAMnC,QACZiM,SAAWjM,GAASiM,GAASjM,QAC7B0a,KAAO,QACPmT,GAAK,QACLC,YAAa,OACbpO,GAAKgO,KACVvrB,GAAQwd,KAAK7W,IAAI3G,UAkGbgsB,8BAMLrlB,IAAA,aAAIykB,EAAYprB,EAAMnC,GACrBN,EAAU6tB,KAAgBA,EAAa,CAACN,QAASM,QAGhDa,EAAIxpB,EAAGypB,EAFJnS,EAAU,IAAIyR,GAAQ,EAAG3tB,GAAS2f,KAAK3f,OAC1CsuB,EAAOpS,EAAQqR,WAAa,OAMxB3oB,KAJL4S,IAAa0E,EAAQjQ,WAAaiQ,EAAQjQ,SAAWuL,EAASvL,eACzDsiB,SAAShkB,KAAK2R,GACnB/Z,EAAO+Z,EAAQpT,IAAI,UAAW3G,GAC9B+Z,EAAQoR,QAAUC,EAEP,QAAN3oB,EACHypB,EAAS,GAETD,EAAKpiB,EAAKwhB,WAAWD,EAAW3oB,OAE/BuoB,GAAO9pB,QAAQ6Y,GAAW,GAAKiR,GAAO5iB,KAAK2R,IAC1CoS,EAAK1pB,GAAKwpB,EAAGnB,WAAaoB,EAAS,GACpCD,EAAGI,YAAcJ,EAAGI,YAAYxB,IAAkBoB,EAAGK,iBAAiB,SAAUzB,YAInFqB,GAAUlsB,EAAK+Z,EAAS,SAAAkC,UAAKlC,EAAQpT,IAAI,KAAMsV,KACxCuB,SAWRrY,OAAA,gBAAOyJ,QACDJ,KAAKI,GAAU,QAErBJ,KAAA,cAAKrJ,QACCinB,SAASlsB,QAAQ,SAAAwR,UAAKA,EAAElD,KAAKrJ,GAAQ,sCA1C/BtH,QACNuuB,SAAW,QACXvuB,MAAQA,EACbwX,GAAYA,EAASkD,KAAKnQ,KAAKoV,MAkDjC,IAAMte,GAAQ,CACbqtB,oEAAkBC,2BAAAA,kBACjBA,EAAKtsB,QAAQ,SAAA0O,UAAUD,GAAcC,MAEtClI,2BAASvD,UACD,IAAIyF,GAASzF,IAErB4f,iCAAYjkB,EAASgkB,UACbzf,EAAgB0f,YAAYjkB,EAASgkB,IAE7C2J,iCAAYxtB,EAAQd,EAAUuuB,EAAMC,GACnCzvB,EAAU+B,KAAYA,EAASS,GAAQT,GAAQ,QAC3C2tB,EAASntB,GAAUR,GAAU,IAAIyQ,IACpCmd,EAASH,EAAOlqB,GAAeL,SACvB,WAATuqB,IAAsBA,EAAO,IACrBztB,EAAmBd,EAA8I0uB,GAAS7c,GAAS7R,IAAa6R,GAAS7R,GAAUuR,KAAQkd,GAAQ3tB,EAAQd,EAAUuuB,EAAMC,IAA7N,SAACxuB,EAAUuuB,EAAMC,UAAYE,GAAS7c,GAAS7R,IAAa6R,GAAS7R,GAAUuR,KAAQkd,GAAQ3tB,EAAQd,EAAUuuB,EAAMC,KAA5I1tB,GAElB6tB,iCAAY7tB,EAAQd,EAAUuuB,MAET,GADpBztB,EAASS,GAAQT,IACNI,OAAY,KAClB0tB,EAAU9tB,EAAOsS,IAAI,SAAAtN,UAAKhG,GAAK6uB,YAAY7oB,EAAG9F,EAAUuuB,KAC3DzrB,EAAI8rB,EAAQ1tB,cACN,SAAAlC,WACF6B,EAAIiC,EACFjC,KACL+tB,EAAQ/tB,GAAG7B,IAId8B,EAASA,EAAO,IAAM,OAClB8P,EAASiB,GAAS7R,GACrB0M,EAAQpL,GAAUR,GAClBwD,EAAKoI,EAAM1L,UAAY0L,EAAM1L,QAAQ0Q,SAAW,IAAI1R,IAAcA,EAClEunB,EAAS3W,EAAS,SAAA5R,OACbsF,EAAI,IAAIsM,EACZyG,EAAYzN,IAAM,EAClBtF,EAAEuM,KAAK/P,EAAQytB,EAAOvvB,EAAQuvB,EAAOvvB,EAAOqY,EAAa,EAAG,CAACvW,IAC7DwD,EAAEf,OAAO,EAAGe,GACZ+S,EAAYzN,KAAOoH,GAAkB,EAAGqG,IACrC3K,EAAM4S,IAAIxe,EAAQwD,UAChBsM,EAAS2W,EAAS,SAAAvoB,UAASuoB,EAAOzmB,EAAQwD,EAAGiqB,EAAOvvB,EAAQuvB,EAAOvvB,EAAO0N,EAAO,KAEzFmiB,yBAAQ/tB,EAAQd,EAAUgF,GAEjB,SAAPnD,GAAQ7C,EAAOqD,EAAO8nB,UAAoBlnB,EAAMinB,QAAQlqB,EAAUhB,EAAOqD,EAAO8nB,SAD7ElnB,EAAQnD,GAAKiiB,GAAGjhB,EAAQyD,WAAevE,GAAW,UAAS+f,QAAQ,IAAMsC,QAAS,KAAIrd,GAAQ,YAElGnD,GAAKoB,MAAQA,EACNpB,IAERitB,+BAAWnuB,UACiD,EAApDuE,EAAgB0f,YAAYjkB,GAAS,GAAMO,QAEnDsD,2BAASxF,UACRA,GAASA,EAAMuN,OAASvN,EAAMuN,KAAOC,GAAWxN,EAAMuN,KAAMqM,EAAUrM,OAC/D9H,GAAWmU,EAAW5Z,GAAS,KAEvCyR,uBAAOzR,UACCyF,GAAW6T,EAAStZ,GAAS,KAErC+vB,8CAAgBxuB,IAAAA,KAAMyuB,IAAAA,OAAQC,IAAAA,QAASzqB,IAAAA,SAAU0qB,IAAAA,gBAC/CD,GAAW,IAAIntB,MAAM,KAAKC,QAAQ,SAAAotB,UAAcA,IAAetd,GAASsd,KAAgBtvB,GAASsvB,IAAehvB,EAAMI,EAAO,oBAAsB4uB,EAAa,cACjKpV,GAASxZ,GAAQ,SAACI,EAASqE,EAAMogB,UAAO4J,EAAOztB,GAAQZ,GAAU4D,GAAaS,GAAQ,GAAIR,GAAW4gB,IACjG8J,IACHzkB,GAASqH,UAAUvR,GAAQ,SAASI,EAASqE,EAAM6D,UAC3CwW,KAAK7W,IAAIuR,GAASxZ,GAAMI,EAASvB,EAAU4F,GAAQA,GAAQ6D,EAAW7D,IAAS,GAAIqa,MAAOxW,MAIpGumB,mCAAa7uB,EAAMgM,GAClBkI,GAASlU,GAAQiM,GAAWD,IAE7B8iB,6BAAU9iB,EAAMiS,UACRiB,UAAUve,OAASsL,GAAWD,EAAMiS,GAAe/J,IAE3D2P,yBAAQhF,UACAla,EAAgBkf,QAAQhF,IAEhCkQ,+BAAWtqB,EAAWuqB,YAAXvqB,IAAAA,EAAO,QAEhBU,EAAOS,EADJif,EAAK,IAAI3a,GAASzF,OAEtBogB,EAAGhd,kBAAoB/I,EAAY2F,EAAKoD,mBACxClD,EAAgBqB,OAAO6e,GACvBA,EAAG5f,IAAM,EACT4f,EAAG/c,MAAQ+c,EAAG7d,OAASrC,EAAgBmD,MACvC3C,EAAQR,EAAgBwQ,OACjBhQ,GACNS,EAAOT,EAAMO,OACTspB,IAA0B7pB,EAAMiB,MAAQjB,aAAiBwF,IAASxF,EAAMV,KAAKwd,aAAe9c,EAAMuf,SAAS,IAC9Grc,GAAewc,EAAI1f,EAAOA,EAAMkB,OAASlB,EAAMsD,QAEhDtD,EAAQS,SAETyC,GAAe1D,EAAiBkgB,EAAI,GAC7BA,GAERxJ,QAAS,iBAAC/Z,EAAMnC,UAAUmC,EAAO,IAAIwrB,GAAQxrB,EAAMnC,GAASwX,GAC5DgW,WAAY,oBAAAxtB,UAAS,IAAImuB,GAAWnuB,IACpC8vB,kBAAmB,oCAAM3C,GAAO9qB,QAAQ,SAAAwR,OAEtCkc,EAAOnrB,EADJ0pB,EAAOza,EAAE0Z,eAER3oB,KAAK0pB,EACLA,EAAK1pB,KACR0pB,EAAK1pB,IAAK,EACVmrB,EAAQ,GAGVA,GAASlc,EAAEvM,YACN0lB,MACNyB,2CAAiBxjB,EAAM+Q,OAClBvY,EAAIiV,GAAWzN,KAAUyN,GAAWzN,GAAQ,KAC/CxH,EAAEJ,QAAQ2Y,IAAavY,EAAE8G,KAAKyR,IAEhCgU,iDAAoB/kB,EAAM+Q,OACrBvY,EAAIiV,GAAWzN,GAClB9J,EAAIsC,GAAKA,EAAEJ,QAAQ2Y,GACf,GAAL7a,GAAUsC,EAAE9B,OAAOR,EAAG,IAEvB8uB,MAAO,CAAEC,KA3iFF,SAAPA,KAAgBliB,EAAKD,EAAKzO,OACrB6wB,EAAQpiB,EAAMC,SACXpI,EAASoI,GAAO4B,GAAW5B,EAAKkiB,KAAK,EAAGliB,EAAIxM,QAASuM,GAAOtC,GAAmBnM,EAAO,SAAAA,UAAW6wB,GAAS7wB,EAAQ0O,GAAOmiB,GAASA,EAASniB,KAyiFpIoiB,SAviFJ,SAAXA,SAAYpiB,EAAKD,EAAKzO,OACjB6wB,EAAQpiB,EAAMC,EACjBqiB,EAAgB,EAARF,SACFvqB,EAASoI,GAAO4B,GAAW5B,EAAKoiB,SAAS,EAAGpiB,EAAIxM,OAAS,GAAIuM,GAAOtC,GAAmBnM,EAAO,SAAAA,UAE7F0O,GAAgBmiB,GADvB7wB,GAAS+wB,GAAS/wB,EAAQ0O,GAAOqiB,GAASA,GAAS,GAClBA,EAAQ/wB,EAASA,MAkiF3BqN,WAAAA,GAAYD,OAAAA,GAAQqC,KAAAA,GAAMuhB,UA7iFvC,SAAZA,UAAatiB,EAAKD,EAAKzO,UAAUkc,GAASxN,EAAKD,EAAK,EAAG,EAAGzO,IA6iFIoM,QAAAA,GAAS6kB,MAnqF/D,SAARA,MAASviB,EAAKD,EAAKzO,UAAUmM,GAAmBnM,EAAO,SAAAyC,UAAKiH,GAAOgF,EAAKD,EAAKhM,MAmqFCgR,WAAAA,GAAYlR,QAAAA,GAASoK,SAAAA,GAAUuP,SAAAA,GAAUgV,KA/iFhH,SAAPA,kCAAWC,2BAAAA,yBAAc,SAAAnxB,UAASmxB,EAAUC,OAAO,SAAC3uB,EAAGqc,UAAMA,EAAErc,IAAIzC,KA+iF0DqxB,QA9iFnH,SAAVA,QAAWxuB,EAAM0sB,UAAS,SAAAvvB,UAAS6C,EAAKY,WAAWzD,KAAWuvB,GAAQnjB,GAAQpM,MA8iFwDsxB,YA7gFxH,SAAdA,YAAejuB,EAAOG,EAAK8N,EAAUigB,OAChC1uB,EAAOgL,MAAMxK,EAAQG,GAAO,EAAI,SAAA8B,UAAM,EAAIA,GAAKjC,EAAQiC,EAAI9B,OAC1DX,EAAM,KAGTyC,EAAGzD,EAAG2vB,EAAe1tB,EAAG2tB,EAFrBC,EAAW3xB,EAAUsD,GACxBsuB,EAAS,OAEG,IAAbrgB,IAAsBigB,EAAS,KAAOjgB,EAAW,MAC7CogB,EACHruB,EAAQ,CAACiC,EAAGjC,GACZG,EAAM,CAAC8B,EAAG9B,QAEJ,GAAI8C,EAASjD,KAAWiD,EAAS9C,GAAM,KAC7CguB,EAAgB,GAChB1tB,EAAIT,EAAMnB,OACVuvB,EAAK3tB,EAAI,EACJjC,EAAI,EAAGA,EAAIiC,EAAGjC,IAClB2vB,EAAcvmB,KAAKqmB,YAAYjuB,EAAMxB,EAAE,GAAIwB,EAAMxB,KAElDiC,IACAjB,EAAO,cAAAyC,GACNA,GAAKxB,MACDjC,EAAIoB,KAAKyL,IAAI+iB,IAAMnsB,UAChBksB,EAAc3vB,GAAGyD,EAAIzD,IAE7ByP,EAAW9N,OACA+tB,IACXluB,EAAQzC,GAAO0F,EAASjD,GAAS,GAAK,GAAIA,QAEtCmuB,EAAe,KACdlsB,KAAK9B,EACTyO,GAAcgK,KAAK0V,EAAQtuB,EAAOiC,EAAG,MAAO9B,EAAI8B,IAEjDzC,EAAO,cAAAyC,UAAK0M,GAAkB1M,EAAGqsB,KAAYD,EAAWruB,EAAMiC,EAAIjC,YAG7D8I,GAAmBmF,EAAUzO,IA0+E8GqK,QAAAA,IACnJ0kB,QAASnxB,EACToxB,QAAS9W,GACT+W,OAAQ/mB,GACRqc,WAAY3b,GAAS2b,WACrB6I,QAASpd,GACTkf,eAAgB7rB,EAChB8rB,KAAM,CAAC9e,UAAAA,GAAW+e,QAAS3wB,EAAY4K,MAAAA,GAAOT,SAAAA,GAAU8U,UAAAA,GAAW2R,SAAU5vB,GAAW4E,sBAAAA,GAAuBirB,UAAW,4BAAMttB,GAAY+X,QAAS,iBAAAwV,UAAcA,GAASla,IAAYA,EAASkD,KAAKnQ,KAAKmnB,GAAQA,EAAMvV,KAAO3E,GAAiBA,GAAama,mBAAoB,4BAAAryB,UAASiY,EAAsBjY,KAGlT2C,GAAa,8CAA+C,SAAApB,UAAQQ,GAAMR,GAAQ2K,GAAM3K,KACxFwJ,GAAQvB,IAAIiC,GAAS2b,YACrB/O,EAActW,GAAMghB,GAAG,GAAI,CAACva,SAAS,IAQX,SAAtB8pB,GAAuBhL,EAAQvU,WAC7BwU,EAAKD,EAAO1c,IACT2c,GAAMA,EAAGjiB,IAAMyN,GAAQwU,EAAGqF,KAAO7Z,GAAQwU,EAAG6B,KAAOrW,GACzDwU,EAAKA,EAAGtgB,aAEFsgB,EAkBe,SAAvBgL,GAAwBhxB,EAAM4Q,SACtB,CACN5Q,KAAMA,EACN8Q,QAAS,EACTR,mBAAK/P,EAAQkE,EAAM/B,GAClBA,EAAMmmB,QAAU,SAAAnmB,OACXuuB,EAAMltB,KACNvF,EAAUiG,KACbwsB,EAAO,GACP7vB,GAAaqD,EAAM,SAAAzE,UAAQixB,EAAKjxB,GAAQ,IACxCyE,EAAOwsB,GAEJrgB,EAAU,KAER7M,KADLktB,EAAO,GACGxsB,EACTwsB,EAAKltB,GAAK6M,EAASnM,EAAKV,IAEzBU,EAAOwsB,GAjCI,SAAhBC,cAAiBxuB,EAAOyuB,OAErBptB,EAAGzD,EAAG0lB,EADH5lB,EAAUsC,EAAMgiB,aAEf3gB,KAAKotB,MACT7wB,EAAIF,EAAQO,OACLL,MAEK0lB,GADXA,EAAKtjB,EAAMyc,UAAU7e,GAAGyD,KACRiiB,EAAGhZ,KACdgZ,EAAG3c,MACN2c,EAAK+K,GAAoB/K,EAAIjiB,IAE9BiiB,GAAMA,EAAGpV,UAAYoV,EAAGpV,SAASugB,EAAUptB,GAAIrB,EAAOtC,EAAQE,GAAIyD,IAwBnEmtB,CAAcxuB,EAAO+B,MA1C1B,IAiDalF,GAAOiB,GAAMqtB,eAAe,CACvC7tB,KAAK,OACLsQ,mBAAK/P,EAAQkE,EAAM/B,EAAOuM,EAAO7O,OAC5B2D,EAAGiiB,EAAI9kB,MAEN6C,UADArB,MAAQA,EACH+B,EACTvD,EAAIX,EAAOY,aAAa4C,IAAM,IAC9BiiB,EAAKlH,KAAK7W,IAAI1H,EAAQ,gBAAiBW,GAAK,GAAK,GAAIuD,EAAKV,GAAIkL,EAAO7O,EAAS,EAAG,EAAG2D,IACjFsnB,GAAKtnB,EACRiiB,EAAGpY,EAAI1M,OACFqP,OAAO7G,KAAK3F,IAGnBf,uBAAOqe,EAAOxH,WACTmM,EAAKnM,EAAKxQ,IACP2c,GACN1iB,EAAa0iB,EAAGjH,IAAIiH,EAAGzgB,EAAGygB,EAAGjiB,EAAGiiB,EAAGpY,EAAGoY,GAAMA,EAAG3T,EAAEgP,EAAO2E,EAAGhZ,GAC3DgZ,EAAKA,EAAGtgB,QAGR,CACF1F,KAAK,WACLsQ,mBAAK/P,EAAQ9B,WACR6B,EAAI7B,EAAMkC,OACPL,UACD2H,IAAI1H,EAAQD,EAAGC,EAAOD,IAAM,EAAG7B,EAAM6B,GAAI,EAAG,EAAG,EAAG,EAAG,EAAG,KAIhE0wB,GAAqB,aAAcjjB,IACnCijB,GAAqB,aACrBA,GAAqB,OAAQ9iB,MACzB1N,GAELmK,GAAMwS,QAAUjT,GAASiT,QAAU5d,GAAK4d,QAAU,SAClDtG,EAAa,EACb9X,KAAmBsS,KCpqGD,SAAjB+f,GAAkB/P,EAAOxH,UAASA,EAAKkF,IAAIlF,EAAKtU,EAAGsU,EAAK9V,EAAIrC,KAAKC,MAAkC,KAA3BkY,EAAKzK,EAAIyK,EAAK7G,EAAIqO,IAAkB,IAASxH,EAAKhM,EAAGgM,GACxG,SAArBwX,GAAsBhQ,EAAOxH,UAASA,EAAKkF,IAAIlF,EAAKtU,EAAGsU,EAAK9V,EAAa,IAAVsd,EAAcxH,EAAK4M,EAAK/kB,KAAKC,MAAkC,KAA3BkY,EAAKzK,EAAIyK,EAAK7G,EAAIqO,IAAkB,IAASxH,EAAKhM,EAAGgM,GAC1H,SAA9ByX,GAA+BjQ,EAAOxH,UAASA,EAAKkF,IAAIlF,EAAKtU,EAAGsU,EAAK9V,EAAGsd,EAAS3f,KAAKC,MAAkC,KAA3BkY,EAAKzK,EAAIyK,EAAK7G,EAAIqO,IAAkB,IAASxH,EAAKhM,EAAIgM,EAAKjM,EAAGiM,GACnI,SAAxB0X,GAAyBlQ,EAAOxH,OAC3Bpb,EAAQob,EAAKzK,EAAIyK,EAAK7G,EAAIqO,EAC9BxH,EAAKkF,IAAIlF,EAAKtU,EAAGsU,EAAK9V,KAAMtF,GAASA,EAAQ,GAAK,GAAK,KAAOob,EAAKhM,EAAGgM,GAE7C,SAA1B2X,GAA2BnQ,EAAOxH,UAASA,EAAKkF,IAAIlF,EAAKtU,EAAGsU,EAAK9V,EAAGsd,EAAQxH,EAAK4M,EAAI5M,EAAKjM,EAAGiM,GAC1D,SAAnC4X,GAAoCpQ,EAAOxH,UAASA,EAAKkF,IAAIlF,EAAKtU,EAAGsU,EAAK9V,EAAa,IAAVsd,EAAcxH,EAAKjM,EAAIiM,EAAK4M,EAAG5M,GAC1F,SAAlB6X,GAAmBnxB,EAAQd,EAAUhB,UAAU8B,EAAO6lB,MAAM3mB,GAAYhB,EACvD,SAAjBkzB,GAAkBpxB,EAAQd,EAAUhB,UAAU8B,EAAO6lB,MAAMwL,YAAYnyB,EAAUhB,GAC9D,SAAnBozB,GAAoBtxB,EAAQd,EAAUhB,UAAU8B,EAAOC,MAAMf,GAAYhB,EAC1D,SAAfqzB,GAAgBvxB,EAAQd,EAAUhB,UAAU8B,EAAOC,MAAMuxB,OAASxxB,EAAOC,MAAMwxB,OAASvzB,EAC/D,SAAzBwzB,GAA0B1xB,EAAQd,EAAUhB,EAAOob,EAAMwH,OACpDlV,EAAQ5L,EAAOC,MACnB2L,EAAM4lB,OAAS5lB,EAAM6lB,OAASvzB,EAC9B0N,EAAM+lB,gBAAgB7Q,EAAOlV,GAED,SAA7BgmB,GAA8B5xB,EAAQd,EAAUhB,EAAOob,EAAMwH,OACxDlV,EAAQ5L,EAAOC,MACnB2L,EAAM1M,GAAYhB,EAClB0N,EAAM+lB,gBAAgB7Q,EAAOlV,GAIjB,SAAbimB,GAAsB3yB,EAAU4yB,cAC3B9xB,EAASue,KAAKve,OACjB6lB,EAAQ7lB,EAAO6lB,MACfja,EAAQ5L,EAAOC,SACXf,KAAY6yB,IAAoBlM,EAAO,SACtCmM,IAAMzT,KAAKyT,KAAO,GACN,cAAb9yB,SAKI+yB,GAAiBC,UAAUlxB,MAAM,KAAKC,QAAQ,SAAAuC,UAAKquB,GAAW1X,KAAK6G,EAAMxd,EAAGsuB,UAJnF5yB,EAAW+yB,GAAiB/yB,IAAaA,GAC/B+C,QAAQ,KAAO/C,EAAS8B,MAAM,KAAKC,QAAQ,SAAAoB,UAAK2e,EAAKgR,IAAI3vB,GAAK8vB,GAAKnyB,EAAQqC,KAAOkc,KAAKyT,IAAI9yB,GAAY0M,EAAMW,EAAIX,EAAM1M,GAAYizB,GAAKnyB,EAAQd,GAC1JA,IAAakzB,KAAyB7T,KAAKyT,IAAIK,QAAUzmB,EAAMymB,SAItB,GAAtC9T,KAAKqF,MAAM3hB,QAAQqwB,WACnB1mB,EAAM2mB,WACJC,KAAOxyB,EAAOY,aAAa,wBAC3BgjB,MAAMza,KAAKipB,GAAsBN,EAAU,KAEjD5yB,EAAWozB,IAEXzM,GAASiM,IAAavT,KAAKqF,MAAMza,KAAKjK,EAAU4yB,EAAUjM,EAAM3mB,IAEnC,SAA/BuzB,GAA+B5M,GAC1BA,EAAM6M,YACT7M,EAAM8M,eAAe,aACrB9M,EAAM8M,eAAe,SACrB9M,EAAM8M,eAAe,WAGR,SAAfC,SAKE7yB,EAAGyD,EAJAogB,EAAQrF,KAAKqF,MAChB5jB,EAASue,KAAKve,OACd6lB,EAAQ7lB,EAAO6lB,MACfja,EAAQ5L,EAAOC,UAEXF,EAAI,EAAGA,EAAI6jB,EAAMxjB,OAAQL,GAAG,EAC3B6jB,EAAM7jB,EAAE,GAEa,IAAf6jB,EAAM7jB,EAAE,GAClBC,EAAO4jB,EAAM7jB,IAAI6jB,EAAM7jB,EAAE,IAEzBC,EAAO4jB,EAAM7jB,IAAM6jB,EAAM7jB,EAAE,GAJ3B6jB,EAAM7jB,EAAE,GAAM8lB,EAAMjC,EAAM7jB,IAAM6jB,EAAM7jB,EAAE,GAAM8lB,EAAM8M,eAAwC,OAAzB/O,EAAM7jB,GAAG6B,OAAO,EAAE,GAAcgiB,EAAM7jB,GAAK6jB,EAAM7jB,GAAGoT,QAAQ0f,GAAU,OAAOvd,kBAO9IiJ,KAAKyT,IAAK,KACRxuB,KAAK+a,KAAKyT,IACdpmB,EAAMpI,GAAK+a,KAAKyT,IAAIxuB,GAEjBoI,EAAM2mB,MACT3mB,EAAM+lB,kBACN3xB,EAAOyqB,aAAa,kBAAmBlM,KAAKiU,MAAQ,MAErDzyB,EAAIgD,OACQhD,EAAEgZ,SAAa8M,EAAMyM,MAChCG,GAA6B5M,GACzBja,EAAMymB,SAAWxM,EAAMuM,MAC1BvM,EAAMuM,KAAyB,IAAMxmB,EAAMymB,QAAU,KACrDzmB,EAAMymB,QAAU,EAChBzmB,EAAM+lB,mBAEP/lB,EAAM8hB,QAAU,IAIF,SAAjBoF,GAAkB9yB,EAAQ+yB,OACrBC,EAAQ,CACXhzB,OAAAA,EACA4jB,MAAO,GACP1d,OAAQ0sB,GACRK,KAAMpB,WAEP7xB,EAAOC,OAASjB,GAAKkxB,KAAKE,SAASpwB,GACnC+yB,GAAc/yB,EAAO6lB,OAAS7lB,EAAO2K,UAAYooB,EAAW/xB,MAAM,KAAKC,QAAQ,SAAAuC,UAAKwvB,EAAMC,KAAKzvB,KACxFwvB,EAGS,SAAjBE,GAAkBrpB,EAAMspB,OACnBjN,EAAIhb,GAAKkoB,gBAAkBloB,GAAKkoB,iBAAiBD,GAAM,gCAAgChgB,QAAQ,SAAU,QAAStJ,GAAQqB,GAAKC,cAActB,UAC1Iqc,GAAKA,EAAEL,MAAQK,EAAIhb,GAAKC,cAActB,GAEvB,SAAvBwpB,GAAwBrzB,EAAQd,EAAUo0B,OACrCC,EAAKC,iBAAiBxzB,UACnBuzB,EAAGr0B,IAAaq0B,EAAGE,iBAAiBv0B,EAASiU,QAAQ0f,GAAU,OAAOvd,gBAAkBie,EAAGE,iBAAiBv0B,KAAeo0B,GAAsBD,GAAqBrzB,EAAQ0zB,GAAiBx0B,IAAaA,EAAU,IAAO,GAczN,SAAZy0B,MAnIgB,SAAhBn1B,sBAAyC,oBAAZC,QAoIxBD,IAAmBC,OAAOie,WAC7B9R,GAAOnM,OACPyM,GAAON,GAAK8R,SACZkX,GAAc1oB,GAAK2oB,gBACnBC,GAAWZ,GAAe,QAAU,CAACrN,MAAM,IAC1BqN,GAAe,OAChCZ,GAAiBoB,GAAiBpB,IAClCF,GAAuBE,GAAiB,SACxCwB,GAASjO,MAAMkO,QAAU,2DACzBC,KAAgBN,GAAiB,eACjC3wB,GAAa/D,GAAKkxB,KAAKG,UACvB4D,GAAiB,GAGO,SAA1BC,GAA0Bl0B,OAIxBm0B,EAHGC,EAAQp0B,EAAOq0B,gBAClB9B,EAAMW,GAAe,MAAQkB,GAASA,EAAMxzB,aAAa,UAAa,8BACtE0zB,EAAQt0B,EAAOu0B,WAAU,GAE1BD,EAAMzO,MAAM2O,QAAU,QACtBjC,EAAIkC,YAAYH,GAChBV,GAAYa,YAAYlC,OAEvB4B,EAAOG,EAAMI,UACZ,MAAOxO,WACTqM,EAAIoC,YAAYL,GAChBV,GAAYe,YAAYpC,GACjB4B,EAEiB,SAAzBS,GAA0B50B,EAAQ60B,WAC7B90B,EAAI80B,EAAgBz0B,OACjBL,QACFC,EAAO80B,aAAaD,EAAgB90B,WAChCC,EAAOY,aAAai0B,EAAgB90B,IAInC,SAAXg1B,GAAW/0B,OACNg1B,EAAQC,MAEXD,EAASh1B,EAAO00B,UACf,MAAOQ,GACRF,EAASd,GAAwBl0B,GACjCi1B,EAAS,SAETD,IAAWA,EAAOG,OAASH,EAAOI,SAAYH,IAAWD,EAASd,GAAwBl0B,KAEnFg1B,GAAWA,EAAOG,OAAUH,EAAOzoB,GAAMyoB,EAAOxoB,EAA8IwoB,EAAzI,CAACzoB,GAAIqoB,GAAuB50B,EAAQ,CAAC,IAAI,KAAK,QAAU,EAAGwM,GAAGooB,GAAuB50B,EAAQ,CAAC,IAAI,KAAK,QAAU,EAAGm1B,MAAM,EAAGC,OAAO,GAEzL,SAATC,GAASnP,YAAQA,EAAEoP,QAAYpP,EAAEqP,aAAcrP,EAAEmO,kBAAoBU,GAAS7O,IAC5D,SAAlBsP,GAAmBx1B,EAAQd,MACtBA,EAAU,KAEZu2B,EADG5P,EAAQ7lB,EAAO6lB,MAEf3mB,KAAY6yB,IAAmB7yB,IAAakzB,KAC/ClzB,EAAWozB,IAERzM,EAAM8M,gBAEW,QADpB8C,EAAcv2B,EAAS0C,OAAO,EAAE,KACqB,WAAzB1C,EAAS0C,OAAO,EAAE,KAC7C1C,EAAW,IAAMA,GAElB2mB,EAAM8M,eAA+B,OAAhB8C,EAAuBv2B,EAAWA,EAASiU,QAAQ0f,GAAU,OAAOvd,gBAEzFuQ,EAAM6P,gBAAgBx2B,IAIL,SAApBy2B,GAAqBnQ,EAAQxlB,EAAQd,EAAU02B,EAAWl0B,EAAKm0B,OAC1DpQ,EAAK,IAAIrU,GAAUoU,EAAO1c,IAAK9I,EAAQd,EAAU,EAAG,EAAG22B,EAAe3E,GAAmCD,WAC7GzL,EAAO1c,IAAM2c,GACVpY,EAAIuoB,EACPnQ,EAAGS,EAAIxkB,EACP8jB,EAAOxV,OAAO7G,KAAKjK,GACZumB,EAKS,SAAjBqQ,GAAkB91B,EAAQd,EAAUhB,EAAOuvB,OAUzCsI,EAAI5xB,EAAQyH,EAAOoqB,EAThBC,EAAWt0B,WAAWzD,IAAU,EACnCg4B,GAAWh4B,EAAQ,IAAIoF,OAAO1B,QAAQq0B,EAAW,IAAI71B,SAAW,KAChEylB,EAAQiO,GAASjO,MACjBsQ,EAAaC,GAAe5iB,KAAKtU,GACjCm3B,EAA6C,QAAjCr2B,EAAOs2B,QAAQhhB,cAC3BihB,GAAmBF,EAAY,SAAW,WAAaF,EAAa,QAAU,UAE9EK,EAAoB,OAAT/I,EACXgJ,EAAqB,MAAThJ,KAETA,IAASyI,IAAYD,GAAYS,GAAqBjJ,IAASiJ,GAAqBR,UAChFD,KAEK,OAAZC,GAAqBM,IAAcP,EAAWH,GAAe91B,EAAQd,EAAUhB,EAAO,OACvF83B,EAAQh2B,EAAOs1B,QAAUD,GAAOr1B,IAC3By2B,GAAyB,MAAZP,KAAqBnE,GAAgB7yB,KAAcA,EAAS+C,QAAQ,iBACrF8zB,EAAKC,EAAQh2B,EAAO00B,UAAUyB,EAAa,QAAU,UAAYn2B,EAAOu2B,GACjEr1B,GAAOu1B,EAAYR,EAAWF,EAX5B,IAW0CE,EAAW,IAAMF,MAErElQ,EAAMsQ,EAAa,QAAU,UAbnB,KAayCK,EAAWN,EAAUzI,GACxEtpB,EAAoB,QAATspB,IAAmBvuB,EAAS+C,QAAQ,UAAuB,OAATwrB,GAAiBztB,EAAOy0B,cAAgB4B,EAAcr2B,EAASA,EAAOu1B,WAC/HS,IACH7xB,GAAUnE,EAAOq0B,iBAAmB,IAAIkB,YAEpCpxB,GAAUA,IAAW+G,IAAS/G,EAAOswB,cACzCtwB,EAAS+G,GAAKyrB,OAEf/qB,EAAQzH,EAAOlE,QACFw2B,GAAa7qB,EAAMupB,OAASgB,GAAcvqB,EAAMhJ,OAASqG,GAAQrG,OAASgJ,EAAM8hB,eACrFxsB,GAAO+0B,EAAWrqB,EAAMupB,MAvBtB,SAyBLsB,GAA2B,WAAbv3B,GAAsC,UAAbA,GAMzCu3B,GAAyB,MAAZP,GAAqBU,GAAoBvD,GAAqBlvB,EAAQ,cAAgB0hB,EAAM9d,SAAWsrB,GAAqBrzB,EAAQ,aACjJmE,IAAWnE,IAAY6lB,EAAM9d,SAAW,UACzC5D,EAAOswB,YAAYX,IACnBiC,EAAKjC,GAASyC,GACdpyB,EAAOwwB,YAAYb,IACnBjO,EAAM9d,SAAW,eAXgD,KAC7DpH,EAAIX,EAAO6lB,MAAM3mB,GACrBc,EAAO6lB,MAAM3mB,GA3BL,IA2B0BuuB,EAClCsI,EAAK/1B,EAAOu2B,GACZ51B,EAAKX,EAAO6lB,MAAM3mB,GAAYyB,EAAK60B,GAAgBx1B,EAAQd,UASxDi3B,GAAcM,KACjB7qB,EAAQpL,GAAU2D,IACZvB,KAAOqG,GAAQrG,KACrBgJ,EAAMupB,MAAQhxB,EAAOoyB,IAGhBr1B,GAAOs1B,EAAWT,EAAKE,EA5CpB,IA4CwCF,GAAME,EA5C9C,IA4CkEF,EAAKE,EAAW,GAuBpE,SAAzBY,GAAkC72B,EAAQiR,EAAM1P,EAAOG,OACjDH,GAAmB,SAAVA,EAAkB,KAC3BiC,EAAIkwB,GAAiBziB,EAAMjR,EAAQ,GACtC6O,EAAIrL,GAAK6vB,GAAqBrzB,EAAQwD,EAAG,GACtCqL,GAAKA,IAAMtN,GACd0P,EAAOzN,EACPjC,EAAQsN,GACW,gBAAToC,IACV1P,EAAQ8xB,GAAqBrzB,EAAQ,uBAMtCqC,EAAG0Q,EAAQ+jB,EAAa7P,EAAUhU,EAAO8jB,EAAYC,EAAUjQ,EAAQC,EAAOiQ,EAASC,EAHpFzR,EAAK,IAAIrU,GAAUmN,KAAKzV,IAAK9I,EAAO6lB,MAAO5U,EAAM,EAAG,EAAGkW,IAC1DzY,EAAQ,EACR0Y,EAAa,KAEd3B,EAAGpY,EAAI9L,EACPkkB,EAAGS,EAAIxkB,EACPH,GAAS,GAEG,UADZG,GAAO,MAENq1B,EAAa/2B,EAAO6lB,MAAM5U,GAC1BjR,EAAO6lB,MAAM5U,GAAQvP,EACrBA,EAAM2xB,GAAqBrzB,EAAQiR,IAASvP,EAC5Cq1B,EAAc/2B,EAAO6lB,MAAM5U,GAAQ8lB,EAAcvB,GAAgBx1B,EAAQiR,IAG1EoC,GADAhR,EAAI,CAACd,EAAOG,IAGZA,EAAMW,EAAE,GACRy0B,GAFAv1B,EAAQc,EAAE,IAEUe,MAAMuP,KAAoB,IAClCjR,EAAI0B,MAAMuP,KAAoB,IAC5BvS,OAAQ,MACb2S,EAASJ,GAAgBnI,KAAK9I,IACrCs1B,EAAWjkB,EAAO,GAClBiU,EAAQtlB,EAAI6S,UAAU7F,EAAOqE,EAAOrE,OAChCuE,EACHA,GAASA,EAAQ,GAAK,EACS,UAArB+T,EAAMplB,QAAQ,IAAuC,UAArBolB,EAAMplB,QAAQ,KACxDqR,EAAQ,GAEL+jB,KAAcD,EAAaD,EAAY1P,MAAiB,MAC3DH,EAAWtlB,WAAWo1B,IAAe,EACrCG,EAAYH,EAAWn1B,QAAQqlB,EAAW,IAAI7mB,QACtB,MAAvB42B,EAASv1B,OAAO,KAAgBu1B,EAAW11B,GAAe2lB,EAAU+P,GAAYE,GACjFnQ,EAASplB,WAAWq1B,GACpBC,EAAUD,EAASp1B,QAAQmlB,EAAS,IAAI3mB,QACxCsO,EAAQiE,GAAgBY,UAAY0jB,EAAQ72B,OACvC62B,IACJA,EAAUA,GAAWzf,EAAQI,MAAM3G,IAASimB,EACxCxoB,IAAUhN,EAAItB,SACjBsB,GAAOu1B,EACPxR,EAAGS,GAAK+Q,IAGNC,IAAcD,IACjBhQ,EAAW6O,GAAe91B,EAAQiR,EAAM8lB,EAAYE,IAAY,GAGjExR,EAAG3c,IAAM,CACR3D,MAAOsgB,EAAG3c,IACVtF,EAAIwjB,GAAyB,IAAfI,EAAqBJ,EAAQ,IAC3CnY,EAAGoY,EACHxU,EAAGsU,EAASE,EACZI,EAAIpU,GAASA,EAAQ,GAAe,WAAThC,EAAoB9P,KAAKC,MAAQ,IAI/DqkB,EAAGhT,EAAK/D,EAAQhN,EAAItB,OAAUsB,EAAI6S,UAAU7F,EAAOhN,EAAItB,QAAU,QAEjEqlB,EAAG3T,EAAa,YAATb,GAA8B,SAARvP,EAAiBwvB,GAAmCD,UAElFpY,GAAQrF,KAAK9R,KAAS+jB,EAAGS,EAAI,QACxBpd,IAAM2c,EAIoB,SAAhC0R,GAAgCj5B,OAC3B8C,EAAQ9C,EAAM8C,MAAM,KACvBuL,EAAIvL,EAAM,GACVwL,EAAIxL,EAAM,IAAM,YACP,QAANuL,GAAqB,WAANA,GAAwB,SAANC,GAAsB,UAANA,IACpDtO,EAAQqO,EACRA,EAAIC,EACJA,EAAItO,GAEL8C,EAAM,GAAKo2B,GAAkB7qB,IAAMA,EACnCvL,EAAM,GAAKo2B,GAAkB5qB,IAAMA,EAC5BxL,EAAMkS,KAAK,KAEC,SAApBmkB,GAAqBvW,EAAOxH,MACvBA,EAAKnX,OAASmX,EAAKnX,MAAMoF,QAAU+R,EAAKnX,MAAM0D,KAAM,KAKtDoL,EAAMqmB,EAAiBv3B,EAJpBC,EAASsZ,EAAKtU,EACjB6gB,EAAQ7lB,EAAO6lB,MACfjC,EAAQtK,EAAKhM,EACb1B,EAAQ5L,EAAOC,SAEF,QAAV2jB,IAA6B,IAAVA,EACtBiC,EAAMkO,QAAU,GAChBuD,EAAkB,WAGlBv3B,GADA6jB,EAAQA,EAAM5iB,MAAM,MACVZ,QACI,IAALL,GACRkR,EAAO2S,EAAM7jB,GACTgyB,GAAgB9gB,KACnBqmB,EAAkB,EAClBrmB,EAAiB,oBAATA,EAA8BmhB,GAAuBE,IAE9DkD,GAAgBx1B,EAAQiR,GAGtBqmB,IACH9B,GAAgBx1B,EAAQsyB,IACpB1mB,IACHA,EAAM2mB,KAAOvyB,EAAO01B,gBAAgB,aACpC7P,EAAM0R,MAAQ1R,EAAM2R,OAAS3R,EAAM6M,UAAY,OAC/C+E,GAAgBz3B,EAAQ,GACxB4L,EAAM8hB,QAAU,EAChB+E,GAA6B5M,MA6Fd,SAAnB6R,GAAmBx5B,SAAoB,6BAAVA,GAAkD,SAAVA,IAAqBA,EACrD,SAArCy5B,GAAqC33B,OAChC43B,EAAevE,GAAqBrzB,EAAQsyB,WACzCoF,GAAiBE,GAAgBC,GAAoBD,EAAah2B,OAAO,GAAGwB,MAAMgP,IAASE,IAAIpR,IAE1F,SAAb42B,GAAc93B,EAAQ+3B,OAIpB5zB,EAAQ6zB,EAAatH,EAAMuH,EAHxBrsB,EAAQ5L,EAAOC,OAASO,GAAUR,GACrC6lB,EAAQ7lB,EAAO6lB,MACfqS,EAASP,GAAmC33B,UAEzC4L,EAAM2mB,KAAOvyB,EAAOY,aAAa,aAGP,iBAD7Bs3B,EAAS,EADTxH,EAAO1wB,EAAOkyB,UAAUiG,QAAQC,cAAcF,QAC/B71B,EAAGquB,EAAKrjB,EAAGqjB,EAAKje,EAAGie,EAAKjkB,EAAGikB,EAAKxK,EAAGwK,EAAK1T,IACxC9J,KAAK,KAA0B2kB,GAAoBK,GACxDA,IAAWL,IAAsB73B,EAAOq4B,cAAgBr4B,IAAW4zB,IAAgBhoB,EAAM2mB,MAEnG7B,EAAO7K,EAAM2O,QACb3O,EAAM2O,QAAU,SAChBrwB,EAASnE,EAAOu1B,cACCv1B,EAAOq4B,cAAiBr4B,EAAOiN,wBAAwBkoB,SACvE8C,EAAa,EACbD,EAAch4B,EAAOs4B,mBACrB1E,GAAYa,YAAYz0B,IAEzBk4B,EAASP,GAAmC33B,GAC5C0wB,EAAQ7K,EAAM2O,QAAU9D,EAAQ8E,GAAgBx1B,EAAQ,WACpDi4B,IACHD,EAAc7zB,EAAOo0B,aAAav4B,EAAQg4B,GAAe7zB,EAASA,EAAOswB,YAAYz0B,GAAU4zB,GAAYe,YAAY30B,KAGjH+3B,GAA2B,EAAhBG,EAAO93B,OAAc,CAAC83B,EAAO,GAAIA,EAAO,GAAIA,EAAO,GAAIA,EAAO,GAAIA,EAAO,IAAKA,EAAO,KAAOA,GAE9F,SAAlBM,GAAmBx4B,EAAQy4B,EAAQC,EAAkBC,EAAQC,EAAaC,OAWxE7D,EAAQ8D,EAAgBtsB,EAVrBZ,EAAQ5L,EAAOC,MAClBi4B,EAASU,GAAed,GAAW93B,GAAQ,GAC3C+4B,EAAantB,EAAMotB,SAAW,EAC9BC,EAAartB,EAAMstB,SAAW,EAC9BC,EAAavtB,EAAMwtB,SAAW,EAC9BC,EAAaztB,EAAM0tB,SAAW,EAC7Bj3B,EAAsB61B,KAAnB7qB,EAAmB6qB,KAAhBzlB,EAAgBylB,KAAbzrB,EAAayrB,KAAVqB,EAAUrB,KAANsB,EAAMtB,KACvBuB,EAAchB,EAAOz3B,MAAM,KAC3Bg4B,EAAUr3B,WAAW83B,EAAY,KAAO,EACxCP,EAAUv3B,WAAW83B,EAAY,KAAO,EAEpCf,EAQMR,IAAWL,KAAsBiB,EAAez2B,EAAIoK,EAAIY,EAAIoF,KAEtEjG,EAAIwsB,IAAY3rB,EAAIyrB,GAAeI,GAAW72B,EAAIy2B,IAAiBz2B,EAAIm3B,EAAKnsB,EAAIksB,GAAMT,EACtFE,EAFIA,GAAWvsB,EAAIqsB,GAAeI,IAAYzmB,EAAIqmB,IAAiBrmB,EAAI+mB,EAAK/sB,EAAI8sB,GAAMT,EAGtFI,EAAU1sB,IAVVwsB,GADAhE,EAASD,GAAS/0B,IACDuM,IAAMktB,EAAY,GAAGx3B,QAAQ,KAAO+2B,EAAU,IAAMhE,EAAOG,MAAQ6D,GACpFE,EAAUlE,EAAOxoB,KAAQitB,EAAY,IAAMA,EAAY,IAAIx3B,QAAQ,KAAQi3B,EAAU,IAAMlE,EAAOI,OAAS8D,IAYxGP,IAAsB,IAAXA,GAAoB/sB,EAAM+sB,QACxCY,EAAKP,EAAUD,EACfS,EAAKN,EAAUD,EACfrtB,EAAMwtB,QAAUD,GAAcI,EAAKl3B,EAAIm3B,EAAK/mB,GAAK8mB,EACjD3tB,EAAM0tB,QAAUD,GAAcE,EAAKlsB,EAAImsB,EAAK/sB,GAAK+sB,GAEjD5tB,EAAMwtB,QAAUxtB,EAAM0tB,QAAU,EAEjC1tB,EAAMotB,QAAUA,EAChBptB,EAAMstB,QAAUA,EAChBttB,EAAM+sB,SAAWA,EACjB/sB,EAAM6sB,OAASA,EACf7sB,EAAM8sB,mBAAqBA,EAC3B14B,EAAO6lB,MAAMuM,IAAwB,UACjCyG,IACHlD,GAAkBkD,EAAyBjtB,EAAO,UAAWmtB,EAAYC,GACzErD,GAAkBkD,EAAyBjtB,EAAO,UAAWqtB,EAAYC,GACzEvD,GAAkBkD,EAAyBjtB,EAAO,UAAWutB,EAAYvtB,EAAMwtB,SAC/EzD,GAAkBkD,EAAyBjtB,EAAO,UAAWytB,EAAYztB,EAAM0tB,UAEhFt5B,EAAOyqB,aAAa,kBAAmBuO,EAAU,IAAME,GAsKtC,SAAlBQ,GAAmB15B,EAAQuB,EAAOrD,OAC7BuvB,EAAOnjB,GAAQ/I,UACZL,GAAOS,WAAWJ,GAASI,WAAWm0B,GAAe91B,EAAQ,IAAK9B,EAAQ,KAAMuvB,KAAUA,EAmHxE,SAA1BkM,GAAmCnU,EAAQxlB,EAAQd,EAAU+nB,EAAU+P,OAMrE4C,EAAWnU,EALRoU,EAAM,IACTjK,EAAW3xB,EAAU+4B,GAErB5L,EADSzpB,WAAWq1B,IAAcpH,IAAaoH,EAAS/0B,QAAQ,OAAU63B,GAAW,GACnE7S,EAClB8S,EAAc9S,EAAWmE,EAAU,aAEhCwE,IAEe,WADlBgK,EAAY5C,EAASh2B,MAAM,KAAK,MAE/BoqB,GAAUyO,KACKzO,QACdA,GAAWA,EAAS,EAAKyO,GAAOA,GAGhB,OAAdD,GAAsBxO,EAAS,EAClCA,GAAWA,EAASyO,MAAiBA,KAAUzO,EAASyO,GAAOA,EACvC,QAAdD,GAAgC,EAATxO,IACjCA,GAAWA,EAASyO,MAAiBA,KAAUzO,EAASyO,GAAOA,IAGjErU,EAAO1c,IAAM2c,EAAK,IAAIrU,GAAUoU,EAAO1c,IAAK9I,EAAQd,EAAU+nB,EAAUmE,EAAQ0F,IAChFrL,EAAGS,EAAI6T,EACPtU,EAAGnY,EAAI,MACPkY,EAAOxV,OAAO7G,KAAKjK,GACZumB,EAEE,SAAVuU,GAAWh6B,EAAQi6B,OACb,IAAIz2B,KAAKy2B,EACbj6B,EAAOwD,GAAKy2B,EAAOz2B,UAEbxD,EAEc,SAAtBk6B,GAAuB1U,EAAQ2U,EAAYn6B,OAIzCo6B,EAAU52B,EAAGuzB,EAAYC,EAAU/P,EAAUF,EAAmBkQ,EAH7DoD,EAAaL,GAAQ,GAAIh6B,EAAOC,OAEnC4lB,EAAQ7lB,EAAO6lB,UAeXriB,KAbD62B,EAAW9H,KACdwE,EAAa/2B,EAAOY,aAAa,aACjCZ,EAAOyqB,aAAa,YAAa,IACjC5E,EAAMyM,IAAkB6H,EACxBC,EAAW3C,GAAgBz3B,EAAQ,GACnCw1B,GAAgBx1B,EAAQsyB,IACxBtyB,EAAOyqB,aAAa,YAAasM,KAEjCA,EAAavD,iBAAiBxzB,GAAQsyB,IACtCzM,EAAMyM,IAAkB6H,EACxBC,EAAW3C,GAAgBz3B,EAAQ,GACnC6lB,EAAMyM,IAAkByE,GAEfhF,IACTgF,EAAasD,EAAW72B,OACxBwzB,EAAWoD,EAAS52B,KAlBV,gDAmB6BvB,QAAQuB,GAAK,IAGnDyjB,EAFY3c,GAAQysB,MACpBE,EAAU3sB,GAAQ0sB,IACmBlB,GAAe91B,EAAQwD,EAAGuzB,EAAYE,GAAWt1B,WAAWo1B,GACjGhQ,EAASplB,WAAWq1B,GACpBxR,EAAO1c,IAAM,IAAIsI,GAAUoU,EAAO1c,IAAKsxB,EAAU52B,EAAGyjB,EAAUF,EAASE,EAAU4J,IACjFrL,EAAO1c,IAAIwE,EAAI2pB,GAAW,EAC1BzR,EAAOxV,OAAO7G,KAAK3F,IAGrBw2B,GAAQI,EAAUC,OA35BhBzvB,GAAMM,GAAM0oB,GAAaK,GAAgBH,GAA0BwG,GAAqBv3B,GA+G3FixB,GDkkGcuG,GAA4I5mB,GAA5I4mB,OAAQC,GAAoI7mB,GAApI6mB,OAAQC,GAA4H9mB,GAA5H8mB,OAAQC,GAAoH/mB,GAApH+mB,OAAQC,GAA4GhnB,GAA5GgnB,OAAQ3c,GAAoGrK,GAApGqK,OAAQ4c,GAA4FjnB,GAA5FinB,KAAMC,GAAsFlnB,GAAtFknB,MAAOC,GAA+EnnB,GAA/EmnB,MAAOC,GAAwEpnB,GAAxEonB,MAAOC,GAAiErnB,GAAjEqnB,OAAQC,GAAyDtnB,GAAzDsnB,QAASC,GAAgDvnB,GAAhDunB,KAAM/c,GAA0CxK,GAA1CwK,YAAagd,GAA6BxnB,GAA7BwnB,OAAQC,GAAqBznB,GAArBynB,KAAMC,GAAe1nB,GAAf0nB,KAAMC,GAAS3nB,GAAT2nB,KC/qGjJvJ,GAAkB,GAClB+H,GAAW,IAAM34B,KAAK8W,GACtBsjB,GAAWp6B,KAAK8W,GAAK,IACrBujB,GAASr6B,KAAKs6B,MAEd5I,GAAW,WACXuD,GAAiB,uCACjBsF,GAAc,YACdzJ,GAAmB,CAAC0J,UAAU,qBAAsBpE,MAAM,gBAAiBqE,MAAM,WAwBjFtJ,GAAiB,YACjBF,GAAuBE,GAAiB,SAqFxCuJ,GAAY,qBAAqB76B,MAAM,KACvC0yB,GAAmB,SAAnBA,iBAAoBx0B,EAAU48B,EAASC,OAErCltB,GADOitB,GAAWhI,IACZjO,MACN9lB,EAAI,KACDb,KAAY2P,IAAMktB,SACd78B,MAERA,EAAWA,EAASuC,OAAO,GAAG0P,cAAgBjS,EAAS0C,OAAO,GACvD7B,OAAU87B,GAAU97B,GAAGb,KAAa2P,YACnC9O,EAAI,EAAK,MAAe,IAANA,EAAW,KAAa,GAALA,EAAU87B,GAAU97B,GAAK,IAAMb,GA+E7Ew3B,GAAuB,CAACsF,IAAI,EAAGC,IAAI,EAAGC,KAAK,GAC3CtF,GAAsB,CAAC7pB,KAAK,EAAGovB,KAAK,GAuDpChK,GAAO,SAAPA,KAAQnyB,EAAQd,EAAUuuB,EAAMC,OAC3BxvB,SACJ+1B,IAAkBN,KACbz0B,KAAY+yB,IAAkC,cAAb/yB,KACrCA,EAAW+yB,GAAiB/yB,IACd+C,QAAQ,OACrB/C,EAAWA,EAAS8B,MAAM,KAAK,IAG7B+wB,GAAgB7yB,IAA0B,cAAbA,GAChChB,EAAQu5B,GAAgBz3B,EAAQ0tB,GAChCxvB,EAAsB,oBAAbgB,EAAkChB,EAAMgB,GAAYhB,EAAMq0B,IAAMr0B,EAAMu6B,OAAS2D,GAAc/I,GAAqBrzB,EAAQoyB,KAAyB,IAAMl0B,EAAMm0B,QAAU,OAElLn0B,EAAQ8B,EAAO6lB,MAAM3mB,KACG,SAAVhB,IAAoBwvB,MAAaxvB,EAAQ,IAAI+D,QAAQ,WAClE/D,EAASm+B,GAAcn9B,IAAam9B,GAAcn9B,GAAUc,EAAQd,EAAUuuB,IAAU4F,GAAqBrzB,EAAQd,IAAawB,GAAaV,EAAQd,KAA2B,YAAbA,EAAyB,EAAI,IAG7LuuB,MAAWvvB,EAAQ,IAAIoF,OAAOrB,QAAQ,KAAO6zB,GAAe91B,EAAQd,EAAUhB,EAAOuvB,GAAQA,EAAOvvB,GA8E5Gk5B,GAAoB,CAACkF,IAAI,KAAMC,OAAO,OAAQrvB,KAAK,KAAMsvB,MAAM,OAAQrwB,OAAO,OAiD9EkwB,GAAgB,CACfI,+BAAWjX,EAAQxlB,EAAQd,EAAU83B,EAAU70B,MAC3B,gBAAfA,EAAMmX,KAAwB,KAC7BmM,EAAKD,EAAO1c,IAAM,IAAIsI,GAAUoU,EAAO1c,IAAK9I,EAAQd,EAAU,EAAG,EAAGm4B,WACxE5R,EAAGnY,EAAI0pB,EACPvR,EAAG0F,IAAM,GACT1F,EAAGtjB,MAAQA,EACXqjB,EAAOxV,OAAO7G,KAAKjK,GACZ,KA6EV24B,GAAoB,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,GAC/B6E,GAAwB,GAkFxBjF,GAAkB,SAAlBA,gBAAmBz3B,EAAQ0tB,OACtB9hB,EAAQ5L,EAAOC,OAAS,IAAIK,GAAQN,MACpC,MAAO4L,IAAU8hB,IAAY9hB,EAAM8hB,eAC/B9hB,MAQPW,EAAGC,EAAGmwB,EAAGnL,EAAQC,EAAQmL,EAAUC,EAAWC,EAAWC,EAAOC,EAAOC,EAAajE,EAASE,EAC7FhB,EAAQgF,EAAO5kB,EAAKC,EAAKlW,EAAGgL,EAAGoF,EAAGhG,EAAG0wB,EAAKC,EAAKC,EAAIC,EAAIC,EAAIC,EAAKC,EAAKC,EAAKC,EAAKC,EAAKC,EAPjFhY,EAAQ7lB,EAAO6lB,MAClBiY,EAAiBlyB,EAAM4lB,OAAS,EAEhCwK,EAAM,MACNzI,EAAKC,iBAAiBxzB,GACtBy4B,EAASpF,GAAqBrzB,EAAQoyB,KAAyB,WAGhE7lB,EAAIC,EAAImwB,EAAIC,EAAWC,EAAYC,EAAYC,EAAQC,EAAQC,EAAc,EAC7EzL,EAASC,EAAS,EAClB7lB,EAAM2mB,OAASvyB,EAAOs1B,SAAUD,GAAOr1B,IAEnCuzB,EAAGb,YACe,SAAjBa,EAAGb,WAAqC,SAAba,EAAGgE,OAAkC,SAAdhE,EAAGiE,SACxD3R,EAAMyM,KAAoC,SAAjBiB,EAAGb,UAAuB,gBAAkBa,EAAGb,UAAY,QAAQ1xB,MAAM,KAAKsB,MAAM,EAAG,GAAG4Q,KAAK,MAAQ,KAAO,KAAqB,SAAdqgB,EAAGiE,OAAoB,UAAYjE,EAAGiE,OAAS,KAAO,KAAoB,SAAbjE,EAAGgE,MAAmB,SAAWhE,EAAGgE,MAAMv2B,MAAM,KAAKkS,KAAK,KAAO,KAAO,KAA8B,SAAvBqgB,EAAGjB,IAA6BiB,EAAGjB,IAAkB,KAEhVzM,EAAM0R,MAAQ1R,EAAM2R,OAAS3R,EAAM6M,UAAY,QAGhDwF,EAASJ,GAAW93B,EAAQ4L,EAAM2mB,KAC9B3mB,EAAM2mB,MAIR8K,EAHGzxB,EAAM8hB,SACT4P,EAAKt9B,EAAO00B,UACZ+D,EAAU7sB,EAAMotB,QAAUsE,EAAG/wB,EAAK,OAASX,EAAMstB,QAAUoE,EAAG9wB,GAAK,KAC9D,KAECkhB,GAAW1tB,EAAOY,aAAa,mBAEtC43B,GAAgBx4B,EAAQq9B,GAAM5E,IAAU4E,GAAMzxB,EAAM8sB,kBAAmC,IAAjB9sB,EAAM+sB,OAAkBT,IAE/Fc,EAAUptB,EAAMotB,SAAW,EAC3BE,EAAUttB,EAAMstB,SAAW,EACvBhB,IAAWL,KACdx1B,EAAI61B,EAAO,GACX7qB,EAAI6qB,EAAO,GACXzlB,EAAIylB,EAAO,GACXzrB,EAAIyrB,EAAO,GACX3rB,EAAI4wB,EAAMjF,EAAO,GACjB1rB,EAAI4wB,EAAMlF,EAAO,GAGK,IAAlBA,EAAO93B,QACVoxB,EAASrwB,KAAKiX,KAAK/V,EAAIA,EAAIgL,EAAIA,GAC/BokB,EAAStwB,KAAKiX,KAAK3L,EAAIA,EAAIgG,EAAIA,GAC/BmqB,EAAYv6B,GAAKgL,EAAKmuB,GAAOnuB,EAAGhL,GAAKy3B,GAAW,GAChDiD,EAAStqB,GAAKhG,EAAK+uB,GAAO/oB,EAAGhG,GAAKqtB,GAAW8C,EAAW,KAC9CnL,GAAUtwB,KAAK+F,IAAI/F,KAAKmX,IAAIykB,EAAQxB,MAC1C3vB,EAAM2mB,MACThmB,GAAKysB,GAAWA,EAAU32B,EAAI62B,EAAUzmB,GACxCjG,GAAK0sB,GAAWF,EAAU3rB,EAAI6rB,EAAUzsB,MAKzCoxB,EAAM3F,EAAO,GACbyF,EAAMzF,EAAO,GACbsF,EAAMtF,EAAO,GACbuF,EAAMvF,EAAO,GACbwF,EAAMxF,EAAO,IACb0F,EAAM1F,EAAO,IACb3rB,EAAI2rB,EAAO,IACX1rB,EAAI0rB,EAAO,IACXyE,EAAIzE,EAAO,IAGX2E,GADAK,EAAQ1B,GAAOqC,EAAKH,IACA5D,GAEhBoD,IAGHG,EAAKF,GAFL7kB,EAAMnX,KAAKmX,KAAK4kB,IAEHM,GADbjlB,EAAMpX,KAAKoX,KAAK2kB,IAEhBI,EAAKF,EAAI9kB,EAAImlB,EAAIllB,EACjBglB,EAAKM,EAAIvlB,EAAIolB,EAAInlB,EACjBilB,EAAML,GAAK5kB,EAAIilB,EAAIllB,EACnBmlB,EAAML,GAAK7kB,EAAIklB,EAAInlB,EACnBolB,EAAMG,GAAKtlB,EAAImlB,EAAIplB,EACnBslB,EAAMD,GAAKplB,EAAIqlB,EAAItlB,EACnB6kB,EAAME,EACND,EAAME,EACNO,EAAMN,GAIPT,GADAI,EAAQ1B,IAAQ/oB,EAAGirB,IACC5D,GAChBoD,IACH5kB,EAAMnX,KAAKmX,KAAK4kB,GAKhBU,EAAMnxB,GAJN8L,EAAMpX,KAAKoX,KAAK2kB,IAIJU,EAAItlB,EAChBjW,EAJAg7B,EAAKh7B,EAAEiW,EAAIklB,EAAIjlB,EAKflL,EAJAiwB,EAAKjwB,EAAEiL,EAAImlB,EAAIllB,EAKf9F,EAJA8qB,EAAK9qB,EAAE6F,EAAIolB,EAAInlB,GAQhBqkB,GADAM,EAAQ1B,GAAOnuB,EAAGhL,IACCy3B,GACfoD,IAGHG,EAAKh7B,GAFLiW,EAAMnX,KAAKmX,IAAI4kB,IAEJ7vB,GADXkL,EAAMpX,KAAKoX,IAAI2kB,IAEfI,EAAKH,EAAI7kB,EAAI8kB,EAAI7kB,EACjBlL,EAAIA,EAAEiL,EAAIjW,EAAEkW,EACZ6kB,EAAMA,EAAI9kB,EAAI6kB,EAAI5kB,EAClBlW,EAAIg7B,EACJF,EAAMG,GAGHT,GAAwD,MAA3C17B,KAAK+F,IAAI21B,GAAa17B,KAAK+F,IAAI01B,KAC/CC,EAAYD,EAAW,EACvBE,EAAY,IAAMA,GAEnBtL,EAAStwB,GAAOC,KAAKiX,KAAK/V,EAAIA,EAAIgL,EAAIA,EAAIoF,EAAIA,IAC9Cgf,EAASvwB,GAAOC,KAAKiX,KAAKglB,EAAMA,EAAMS,EAAMA,IAC5CX,EAAQ1B,GAAO2B,EAAKC,GACpBL,EAA2B,KAAlB57B,KAAK+F,IAAIg2B,GAAmBA,EAAQpD,GAAW,EACxDmD,EAAcW,EAAM,GAAMA,EAAM,GAAMA,EAAMA,GAAO,GAGhDhyB,EAAM2mB,MACT8K,EAAKr9B,EAAOY,aAAa,aACzBgL,EAAMmyB,SAAW/9B,EAAOyqB,aAAa,YAAa,MAASiN,GAAiBrE,GAAqBrzB,EAAQsyB,KACzG+K,GAAMr9B,EAAOyqB,aAAa,YAAa4S,KAInB,GAAlBl8B,KAAK+F,IAAI61B,IAAe57B,KAAK+F,IAAI61B,GAAS,MACzCe,GACHtM,IAAW,EACXuL,GAAUH,GAAY,EAAK,KAAO,IAClCA,GAAaA,GAAY,EAAK,KAAO,MAErCnL,IAAW,EACXsL,GAAUA,GAAS,EAAK,KAAO,MAGjCrP,EAAUA,GAAW9hB,EAAM8hB,QAC3B9hB,EAAMW,EAAIA,IAAMX,EAAMoyB,SAAWzxB,KAAQmhB,GAAW9hB,EAAMoyB,WAAc78B,KAAKC,MAAMpB,EAAOi+B,YAAc,KAAO98B,KAAKC,OAAOmL,IAAM,GAAK,KAAOvM,EAAOi+B,YAAcryB,EAAMoyB,SAAW,IAAM,GAxInL,KAyINpyB,EAAMY,EAAIA,IAAMZ,EAAMsyB,SAAW1xB,KAAQkhB,GAAW9hB,EAAMsyB,WAAc/8B,KAAKC,MAAMpB,EAAOm+B,aAAe,KAAOh9B,KAAKC,OAAOoL,IAAM,GAAK,KAAOxM,EAAOm+B,aAAevyB,EAAMsyB,SAAW,IAAM,GAzIrL,KA0INtyB,EAAM+wB,EAAIA,EA1IJ,KA2IN/wB,EAAM4lB,OAAStwB,GAAOswB,GACtB5lB,EAAM6lB,OAASvwB,GAAOuwB,GACtB7lB,EAAMgxB,SAAW17B,GAAO07B,GAAYZ,EACpCpwB,EAAMixB,UAAY37B,GAAO27B,GAAab,EACtCpwB,EAAMkxB,UAAY57B,GAAO47B,GAAad,EACtCpwB,EAAMmxB,MAAQA,EAAQf,EACtBpwB,EAAMoxB,MAAQA,EAAQhB,EACtBpwB,EAAMwyB,qBAAuBnB,EAlJvB,MAmJDrxB,EAAMymB,QAAU1wB,WAAW82B,EAAOz3B,MAAM,KAAK,MAAS0sB,GAAW9hB,EAAMymB,SAAY,KACvFxM,EAAMuM,IAAwBgK,GAAc3D,IAE7C7sB,EAAMwtB,QAAUxtB,EAAM0tB,QAAU,EAChC1tB,EAAM8L,QAAUF,EAAQE,QACxB9L,EAAM+lB,gBAAkB/lB,EAAM2mB,IAAM8L,GAAuBrK,GAAcsK,GAAuBC,GAChG3yB,EAAM8hB,QAAU,EACT9hB,GAERwwB,GAAgB,SAAhBA,cAAgBl+B,UAAUA,EAAQA,EAAM8C,MAAM,MAAM,GAAK,IAAM9C,EAAM,IAKrEqgC,GAAyB,SAAzBA,uBAA0Bzd,EAAOlV,GAChCA,EAAM+wB,EAAI,MACV/wB,EAAMkxB,UAAYlxB,EAAMixB,UAAY,OACpCjxB,EAAM8L,QAAU,EAChB4mB,GAAqBxd,EAAOlV,IAE7B4yB,GAAW,OACXC,GAAU,MACVC,GAAkB,KAClBJ,GAAuB,SAAvBA,qBAAgCxd,EAAOlV,SAC4GA,GAAS2S,KAAtJyf,IAAAA,SAAUE,IAAAA,SAAU3xB,IAAAA,EAAGC,IAAAA,EAAGmwB,IAAAA,EAAGC,IAAAA,SAAUE,IAAAA,UAAWD,IAAAA,UAAWE,IAAAA,MAAOC,IAAAA,MAAOxL,IAAAA,OAAQC,IAAAA,OAAQ2M,IAAAA,qBAAsB1mB,IAAAA,QAAS1X,IAAAA,OAAQqyB,IAAAA,QACtI8H,EAAa,GACbwE,EAAqB,SAAZjnB,GAAsBoJ,GAAmB,IAAVA,IAA4B,IAAZpJ,KAGrD2a,IAAYwK,IAAc2B,IAAY1B,IAAc0B,IAAW,KAIjElmB,EAHG4kB,EAAQv7B,WAAWm7B,GAAavB,GACnCiC,EAAMr8B,KAAKoX,IAAI2kB,GACfQ,EAAMv8B,KAAKmX,IAAI4kB,GAEhBA,EAAQv7B,WAAWk7B,GAAatB,GAChCjjB,EAAMnX,KAAKmX,IAAI4kB,GACf3wB,EAAImtB,GAAgB15B,EAAQuM,EAAGixB,EAAMllB,GAAO+Z,GAC5C7lB,EAAIktB,GAAgB15B,EAAQwM,GAAIrL,KAAKoX,IAAI2kB,IAAU7K,GACnDsK,EAAIjD,GAAgB15B,EAAQ28B,EAAGe,EAAMplB,GAAO+Z,EAAUA,GAGnD+L,IAAyBK,KAC5BtE,GAAc,eAAiBiE,EAAuBM,KAEnDV,GAAYE,KACf/D,GAAc,aAAe6D,EAAW,MAAQE,EAAW,QAExDS,GAASpyB,IAAMkyB,IAAWjyB,IAAMiyB,IAAW9B,IAAM8B,KACpDtE,GAAewC,IAAM8B,IAAWE,EAAS,eAAiBpyB,EAAI,KAAOC,EAAI,KAAOmwB,EAAI,KAAO,aAAepwB,EAAI,KAAOC,EAAIkyB,IAEtH9B,IAAa4B,KAChBrE,GAAc,UAAYyC,EAAW8B,IAElC5B,IAAc0B,KACjBrE,GAAc,WAAa2C,EAAY4B,IAEpC7B,IAAc2B,KACjBrE,GAAc,WAAa0C,EAAY6B,IAEpC3B,IAAUyB,IAAYxB,IAAUwB,KACnCrE,GAAc,QAAU4C,EAAQ,KAAOC,EAAQ0B,IAEjC,IAAXlN,GAA2B,IAAXC,IACnB0I,GAAc,SAAW3I,EAAS,KAAOC,EAASiN,IAEnD1+B,EAAO6lB,MAAMyM,IAAkB6H,GAAc,mBAE9CkE,GAAuB,SAAvBA,qBAAgCvd,EAAOlV,OAIrCgzB,EAAKC,EAAK1B,EAAKC,EAAK1M,IAH0G9kB,GAAS2S,KAAnIyf,IAAAA,SAAUE,IAAAA,SAAU3xB,IAAAA,EAAGC,IAAAA,EAAGowB,IAAAA,SAAUG,IAAAA,MAAOC,IAAAA,MAAOxL,IAAAA,OAAQC,IAAAA,OAAQzxB,IAAAA,OAAQg5B,IAAAA,QAASE,IAAAA,QAASE,IAAAA,QAASE,IAAAA,QAASyE,IAAAA,SAClHxE,EAAK53B,WAAW4K,GAChBitB,EAAK73B,WAAW6K,GAEjBowB,EAAWj7B,WAAWi7B,GACtBG,EAAQp7B,WAAWo7B,IACnBC,EAAQr7B,WAAWq7B,MAGlBD,GADAC,EAAQr7B,WAAWq7B,GAEnBJ,GAAYI,GAETJ,GAAYG,GACfH,GAAYrB,GACZwB,GAASxB,GACTqD,EAAMz9B,KAAKmX,IAAIskB,GAAYpL,EAC3BqN,EAAM19B,KAAKoX,IAAIqkB,GAAYpL,EAC3B2L,EAAMh8B,KAAKoX,IAAIqkB,EAAWG,IAAUtL,EACpC2L,EAAMj8B,KAAKmX,IAAIskB,EAAWG,GAAStL,EAC/BsL,IACHC,GAASzB,GACT7K,EAAOvvB,KAAK29B,IAAI/B,EAAQC,GAExBG,GADAzM,EAAOvvB,KAAKiX,KAAK,EAAIsY,EAAOA,GAE5B0M,GAAO1M,EACHsM,IACHtM,EAAOvvB,KAAK29B,IAAI9B,GAEhB4B,GADAlO,EAAOvvB,KAAKiX,KAAK,EAAIsY,EAAOA,GAE5BmO,GAAOnO,IAGTkO,EAAM19B,GAAO09B,GACbC,EAAM39B,GAAO29B,GACb1B,EAAMj8B,GAAOi8B,GACbC,EAAMl8B,GAAOk8B,KAEbwB,EAAMpN,EACN4L,EAAM3L,EACNoN,EAAM1B,EAAM,IAER5D,MAAShtB,EAAI,IAAItK,QAAQ,OAAWu3B,MAAShtB,EAAI,IAAIvK,QAAQ,SACjEs3B,EAAKzD,GAAe91B,EAAQ,IAAKuM,EAAG,MACpCitB,EAAK1D,GAAe91B,EAAQ,IAAKwM,EAAG,QAEjCwsB,GAAWE,GAAWE,GAAWE,KACpCC,EAAKr4B,GAAOq4B,EAAKP,GAAWA,EAAU4F,EAAM1F,EAAUiE,GAAO/D,GAC7DI,EAAKt4B,GAAOs4B,EAAKN,GAAWF,EAAU6F,EAAM3F,EAAUkE,GAAO9D,KAE1D0E,GAAYE,KAEfxN,EAAO1wB,EAAO00B,UACd6E,EAAKr4B,GAAOq4B,EAAKyE,EAAW,IAAMtN,EAAKyE,OACvCqE,EAAKt4B,GAAOs4B,EAAK0E,EAAW,IAAMxN,EAAK0E,SAExC1E,EAAO,UAAYkO,EAAM,IAAMC,EAAM,IAAM1B,EAAM,IAAMC,EAAM,IAAM7D,EAAK,IAAMC,EAAK,IACnFx5B,EAAOyqB,aAAa,YAAaiG,GACjCqN,IAAa/9B,EAAO6lB,MAAMyM,IAAkB5B,IAsE9C7vB,GAAa,8BAA+B,SAACpB,EAAMiP,OAEjDoD,EAAI,QACJzE,EAAI,SACJrL,EAAI,OACJ4hB,GAASlV,EAAQ,EAAI,CAJd,MAIiBoD,EAAEzE,EAAErL,GAAK,CAJ1B,MAI6BA,EAJ7B,MAIkC8P,EAAGzE,EAAEyE,EAAGzE,EAAErL,IAAIsQ,IAAI,SAAAysB,UAAQrwB,EAAQ,EAAIjP,EAAOs/B,EAAO,SAAWA,EAAOt/B,IAChH48B,GAAuB,EAAR3tB,EAAY,SAAWjP,EAAOA,GAAS,SAAS+lB,EAAQxlB,EAAQd,EAAU83B,EAAU70B,OAC9FE,EAAG6B,KACHya,UAAUve,OAAS,SACtBiC,EAAIuhB,EAAMtR,IAAI,SAAArB,UAAQkhB,GAAK3M,EAAQvU,EAAM/R,KAEN,KADnCgF,EAAO7B,EAAE6Q,KAAK,MACFlS,MAAMqB,EAAE,IAAIjC,OAAeiC,EAAE,GAAK6B,EAE/C7B,GAAK20B,EAAW,IAAIh2B,MAAM,KAC1BkD,EAAO,GACP0f,EAAM3iB,QAAQ,SAACgQ,EAAMlR,UAAMmE,EAAK+M,GAAQ5O,EAAEtC,GAAKsC,EAAEtC,IAAMsC,GAAKtC,EAAI,GAAK,EAAK,KAC1EylB,EAAOzV,KAAK/P,EAAQkE,EAAM/B,UAoLlB68B,GAAkBpC,GACvBqC,GAhLQC,GAAY,CACxBz/B,KAAM,MACNoR,SAAU8iB,GACVtzB,+BAAWL,UACHA,EAAO6lB,OAAS7lB,EAAO2K,UAE/BoF,mBAAK/P,EAAQkE,EAAM/B,EAAOuM,EAAO7O,OAI/Bk3B,EAAYC,EAAUjQ,EAAQE,EAAUpd,EAAMs1B,EAAa37B,EAAG0zB,EAAWD,EAASmI,EAAUC,EAAoBC,EAAoB1zB,EAAO+sB,EAAQjR,EAAa6X,EAH7J3b,EAAQrF,KAAKvO,OAChB6V,EAAQ7lB,EAAO6lB,MACf1b,EAAUhI,EAAM+B,KAAKiG,YAOjB3G,KALLywB,IAAkBN,UAEb6L,OAASjhB,KAAKihB,QAAU1M,GAAe9yB,GAC5Cu/B,EAAchhB,KAAKihB,OAAO5b,WACrBzhB,MAAQA,EACH+B,KACC,cAANV,IAGJwzB,EAAW9yB,EAAKV,IACZuN,GAASvN,KAAM+hB,GAAa/hB,EAAGU,EAAM/B,EAAOuM,EAAO1O,EAAQH,OAG/DgK,SAAcmtB,EACdmI,EAAc9C,GAAc74B,GACf,aAATqG,IAEHA,SADAmtB,EAAWA,EAAS7c,KAAKhY,EAAOuM,EAAO1O,EAAQH,KAGnC,WAATgK,IAAsBmtB,EAAS/0B,QAAQ,aAC1C+0B,EAAWroB,GAAeqoB,IAEvBmI,EACHA,EAAY5gB,KAAMve,EAAQwD,EAAGwzB,EAAU70B,KAAWulB,EAAc,QAC1D,GAAsB,OAAlBlkB,EAAE5B,OAAO,EAAE,GACrBm1B,GAAcvD,iBAAiBxzB,GAAQyzB,iBAAiBjwB,GAAK,IAAIF,OACjE0zB,GAAY,GACZtkB,GAAUa,UAAY,EACjBb,GAAUc,KAAKujB,KACnBG,EAAY5sB,GAAQysB,GACpBE,EAAU3sB,GAAQ0sB,IAEnBC,EAAUC,IAAcD,IAAYF,EAAajB,GAAe91B,EAAQwD,EAAGuzB,EAAYE,GAAWA,GAAWC,IAAcF,GAAYE,QAClIxvB,IAAIme,EAAO,cAAekR,EAAYC,EAAUtoB,EAAO7O,EAAS,EAAG,EAAG2D,GAC3EogB,EAAMza,KAAK3F,GACX+7B,EAAYp2B,KAAK3F,EAAG,EAAGqiB,EAAMriB,SACvB,GAAa,cAATqG,EAAsB,IAC5BM,GAAW3G,KAAK2G,GACnB4sB,EAAoC,mBAAhB5sB,EAAQ3G,GAAqB2G,EAAQ3G,GAAG2W,KAAKhY,EAAOuM,EAAO1O,EAAQH,GAAWsK,EAAQ3G,GAC1GvF,EAAU84B,KAAgBA,EAAW90B,QAAQ,aAAe80B,EAAapoB,GAAeooB,IACxFzsB,GAAQysB,EAAa,KAAsB,SAAfA,IAA0BA,GAAcvf,EAAQI,MAAMpU,IAAM8G,GAAQ6nB,GAAKnyB,EAAQwD,KAAO,IACpF,OAA/BuzB,EAAa,IAAIt1B,OAAO,KAAes1B,EAAa5E,GAAKnyB,EAAQwD,KAElEuzB,EAAa5E,GAAKnyB,EAAQwD,GAE3ByjB,EAAWtlB,WAAWo1B,IACtBqI,EAAqB,WAATv1B,GAA4C,MAAvBmtB,EAASv1B,OAAO,IAAeu1B,EAASp1B,OAAO,EAAG,MACtEo1B,EAAWA,EAASp1B,OAAO,IACxCmlB,EAASplB,WAAWq1B,GAChBxzB,KAAKyuB,KACE,cAANzuB,IACc,IAAbyjB,GAAiD,WAA/BkL,GAAKnyB,EAAQ,eAA8B+mB,IAChEE,EAAW,GAEZsY,EAAYp2B,KAAK,aAAc,EAAG0c,EAAM4Z,YACxC9J,GAAkBpX,KAAMsH,EAAO,aAAcoB,EAAW,UAAY,SAAUF,EAAS,UAAY,UAAWA,IAErG,UAANvjB,GAAuB,cAANA,KACpBA,EAAIyuB,GAAiBzuB,IAClBvB,QAAQ,OAASuB,EAAIA,EAAExC,MAAM,KAAK,KAIvCq+B,EAAsB77B,KAAKuuB,WAIrByN,OAAOvM,KAAKzvB,GACZ87B,KACJ1zB,EAAQ5L,EAAOC,OACR0xB,kBAAoBztB,EAAKw7B,gBAAmBjI,GAAgBz3B,EAAQkE,EAAKw7B,gBAChF/G,GAAgC,IAAtBz0B,EAAKy7B,cAA0B/zB,EAAM+sB,QAC/C2G,EAAqB/gB,KAAKzV,IAAM,IAAIsI,GAAUmN,KAAKzV,IAAK+c,EAAOyM,GAAgB,EAAG,EAAG1mB,EAAM+lB,gBAAiB/lB,EAAO,GAAI,IACpGmf,IAAM,GAEhB,UAANvnB,OACEsF,IAAM,IAAIsI,GAAUmN,KAAKzV,IAAK8C,EAAO,SAAUA,EAAM6lB,QAAU2N,EAAW99B,GAAesK,EAAM6lB,OAAQ2N,EAAWrY,GAAUA,GAAUnb,EAAM6lB,QAAW,EAAGZ,SAC1J/nB,IAAIwE,EAAI,EACbsW,EAAMza,KAAK,SAAU3F,GACrBA,GAAK,QACC,CAAA,GAAU,oBAANA,EAAyB,CACnC+7B,EAAYp2B,KAAKipB,GAAsB,EAAGvM,EAAMuM,KAChD4E,EAAWG,GAA8BH,GACrCprB,EAAM2mB,IACTiG,GAAgBx4B,EAAQg3B,EAAU,EAAG2B,EAAQ,EAAGpa,QAEhD0Y,EAAUt1B,WAAWq1B,EAASh2B,MAAM,KAAK,KAAO,KACpC4K,EAAMymB,SAAWsD,GAAkBpX,KAAM3S,EAAO,UAAWA,EAAMymB,QAAS4E,GACtFtB,GAAkBpX,KAAMsH,EAAOriB,EAAG44B,GAAcrF,GAAaqF,GAAcpF,cAGtE,GAAU,cAANxzB,EAAmB,CAC7Bg1B,GAAgBx4B,EAAQg3B,EAAU,EAAG2B,EAAQ,EAAGpa,eAE1C,GAAI/a,KAAKk5B,GAAuB,CACtC/C,GAAwBpb,KAAM3S,EAAOpI,EAAGyjB,EAAUmY,EAAW99B,GAAe2lB,EAAUmY,EAAWpI,GAAYA,YAGvG,GAAU,iBAANxzB,EAAsB,CAChCmyB,GAAkBpX,KAAM3S,EAAO,SAAUA,EAAM+sB,OAAQ3B,YAEjD,GAAU,YAANxzB,EAAiB,CAC3BoI,EAAMpI,GAAKwzB,WAEL,GAAU,cAANxzB,EAAmB,CAC7B02B,GAAoB3b,KAAMyY,EAAUh3B,kBAGzBwD,KAAKqiB,IACjBriB,EAAIkwB,GAAiBlwB,IAAMA,MAGxB67B,IAAwBtY,GAAqB,IAAXA,KAAkBE,GAAyB,IAAbA,KAAoByU,GAAYloB,KAAKwjB,IAAcxzB,KAAKqiB,EAEhHkB,EAAXA,GAAoB,GADpBmQ,GAAaH,EAAa,IAAIn1B,QAAQqlB,EAAW,IAAI7mB,YAErD62B,EAAU3sB,GAAQ0sB,KAAexzB,KAAKgU,EAAQI,MAASJ,EAAQI,MAAMpU,GAAK0zB,MAChDjQ,EAAW6O,GAAe91B,EAAQwD,EAAGuzB,EAAYE,SACtEnuB,IAAM,IAAIsI,GAAUmN,KAAKzV,IAAKu2B,EAAqBzzB,EAAQia,EAAOriB,EAAGyjB,GAAWmY,EAAW99B,GAAe2lB,EAAUmY,EAAWrY,GAAUA,GAAUE,EAAYoY,GAAmC,OAAZpI,GAA0B,WAANzzB,IAAsC,IAAnBU,EAAK07B,UAA+C/O,GAAxBG,SACzPloB,IAAIwE,EAAI2pB,GAAW,EACpBC,IAAcD,GAAuB,MAAZA,SACvBnuB,IAAIuE,EAAI0pB,OACRjuB,IAAIgJ,EAAIif,SAER,GAAMvtB,KAAKqiB,EAQjBgR,GAAuB1c,KAAKoE,KAAMve,EAAQwD,EAAGuzB,EAAYqI,EAAWA,EAAWpI,EAAWA,WAPtFxzB,KAAKxD,OACH0H,IAAI1H,EAAQwD,EAAGuzB,GAAc/2B,EAAOwD,GAAI47B,EAAWA,EAAWpI,EAAWA,EAAUtoB,EAAO7O,QACzF,GAAU,mBAAN2D,EAAwB,CAClCvE,EAAeuE,EAAGwzB,YAMpBqI,IAAuB77B,KAAKqiB,EAAQ0Z,EAAYp2B,KAAK3F,EAAG,EAAGqiB,EAAMriB,IAA4B,mBAAfxD,EAAOwD,GAAqB+7B,EAAYp2B,KAAK3F,EAAG,EAAGxD,EAAOwD,MAAQ+7B,EAAYp2B,KAAK3F,EAAG,EAAGuzB,GAAc/2B,EAAOwD,KAC5LogB,EAAMza,KAAK3F,GAGbkkB,GAAeW,GAA0B9J,OAG1C9b,uBAAOqe,EAAOxH,MACTA,EAAKnX,MAAMoF,QAAUxE,aACpB0iB,EAAKnM,EAAKxQ,IACP2c,GACNA,EAAG3T,EAAEgP,EAAO2E,EAAGhZ,GACfgZ,EAAKA,EAAGtgB,WAGTmU,EAAKkmB,OAAOt5B,UAGduK,IAAK0hB,GACLvhB,QAASqhB,GACTvhB,6BAAU1Q,EAAQd,EAAUsmB,OACvBhiB,EAAIyuB,GAAiB/yB,UACxBsE,GAAKA,EAAEvB,QAAQ,KAAO,IAAO/C,EAAWsE,GACjCtE,KAAY6yB,IAAmB7yB,IAAakzB,KAAyBpyB,EAAOC,MAAMsM,GAAK4lB,GAAKnyB,EAAQ,MAAUwlB,GAAU8U,KAAwB9U,EAAuB,UAAbtmB,EAAuBqyB,GAAeD,IAAqBgJ,GAAsB9U,GAAU,MAAqB,UAAbtmB,EAAuBwyB,GAAyBE,IAA+B5xB,EAAO6lB,QAAUxnB,EAAa2B,EAAO6lB,MAAM3mB,IAAaiyB,IAAmBjyB,EAAS+C,QAAQ,KAAOmvB,GAAiBzgB,GAAW3Q,EAAQd,IAE5dgxB,KAAM,CAAEsF,gBAAAA,GAAiBsC,WAAAA,KAI1B94B,GAAK6vB,MAAMgR,YAAcnM,GACzB10B,GAAKkxB,KAAK4P,cAAgBhN,GAErBmM,GAAMp+B,IADDm+B,GAQP,+CAPwC,KADfpC,GAQsB,4CAPU,iFAAc,SAAAn9B,GAASsyB,GAAgBtyB,GAAQ,IAC1GoB,GAAa+7B,GAAU,SAAAn9B,GAAS+X,EAAQI,MAAMnY,GAAQ,MAAOi9B,GAAsBj9B,GAAQ,IAC3FwyB,GAAiBgN,GAAI,KAAOD,GAAmB,IAAMpC,GACrD/7B,GAI8K,6FAJxJ,SAAApB,OACjBuB,EAAQvB,EAAKuB,MAAM,KACvBixB,GAAiBjxB,EAAM,IAAMi+B,GAAIj+B,EAAM,MAGzCH,GAAa,+EAAgF,SAAApB,GAAS+X,EAAQI,MAAMnY,GAAQ,OAE5HT,GAAKsuB,eAAe4R,QC1nCda,GAAc/gC,GAAKsuB,eAAe4R,KAAclgC,GACrDghC,GAAkBD,GAAY7P,KAAK9lB"} \ No newline at end of file diff --git a/dot-line-system/public/images/0_2.png b/dot-line-system/public/images/0_2.png new file mode 100644 index 0000000..008cbfa Binary files /dev/null and b/dot-line-system/public/images/0_2.png differ diff --git a/dot-line-system/public/images/0_3.png b/dot-line-system/public/images/0_3.png new file mode 100644 index 0000000..6abd17a Binary files /dev/null and b/dot-line-system/public/images/0_3.png differ diff --git a/dot-line-system/public/images/disco.png b/dot-line-system/public/images/disco.png new file mode 100644 index 0000000..8588d2a Binary files /dev/null and b/dot-line-system/public/images/disco.png differ diff --git a/dot-line-system/public/images/entspannung.png b/dot-line-system/public/images/entspannung.png new file mode 100644 index 0000000..8673fea Binary files /dev/null and b/dot-line-system/public/images/entspannung.png differ diff --git a/dot-line-system/public/images/familie.png b/dot-line-system/public/images/familie.png new file mode 100644 index 0000000..e6c5420 Binary files /dev/null and b/dot-line-system/public/images/familie.png differ diff --git a/dot-line-system/public/images/familie2.png b/dot-line-system/public/images/familie2.png new file mode 100644 index 0000000..dbfd161 Binary files /dev/null and b/dot-line-system/public/images/familie2.png differ diff --git a/dot-line-system/public/images/feier.png b/dot-line-system/public/images/feier.png new file mode 100644 index 0000000..d849e60 Binary files /dev/null and b/dot-line-system/public/images/feier.png differ diff --git a/dot-line-system/public/images/gpt.png b/dot-line-system/public/images/gpt.png new file mode 100644 index 0000000..ea252e5 Binary files /dev/null and b/dot-line-system/public/images/gpt.png differ diff --git a/dot-line-system/public/images/grosseltern.png b/dot-line-system/public/images/grosseltern.png new file mode 100644 index 0000000..6572a1c Binary files /dev/null and b/dot-line-system/public/images/grosseltern.png differ diff --git a/dot-line-system/public/images/hochzeit.png b/dot-line-system/public/images/hochzeit.png new file mode 100644 index 0000000..ce61760 Binary files /dev/null and b/dot-line-system/public/images/hochzeit.png differ diff --git a/dot-line-system/public/images/kindergeburtstag.png b/dot-line-system/public/images/kindergeburtstag.png new file mode 100644 index 0000000..47a1a7b Binary files /dev/null and b/dot-line-system/public/images/kindergeburtstag.png differ diff --git a/dot-line-system/public/images/kinobesuch.png b/dot-line-system/public/images/kinobesuch.png new file mode 100644 index 0000000..6bc2472 Binary files /dev/null and b/dot-line-system/public/images/kinobesuch.png differ diff --git a/dot-line-system/public/images/klasse.png b/dot-line-system/public/images/klasse.png new file mode 100644 index 0000000..91124b8 Binary files /dev/null and b/dot-line-system/public/images/klasse.png differ diff --git a/dot-line-system/public/images/oma.png b/dot-line-system/public/images/oma.png new file mode 100644 index 0000000..941dbda Binary files /dev/null and b/dot-line-system/public/images/oma.png differ diff --git a/dot-line-system/public/images/pferd.png b/dot-line-system/public/images/pferd.png new file mode 100644 index 0000000..5992d19 Binary files /dev/null and b/dot-line-system/public/images/pferd.png differ diff --git a/dot-line-system/public/images/see.png b/dot-line-system/public/images/see.png new file mode 100644 index 0000000..59d79f9 Binary files /dev/null and b/dot-line-system/public/images/see.png differ diff --git a/dot-line-system/public/images/sonntag.png b/dot-line-system/public/images/sonntag.png new file mode 100644 index 0000000..3d5d677 Binary files /dev/null and b/dot-line-system/public/images/sonntag.png differ diff --git a/dot-line-system/public/images/work.png b/dot-line-system/public/images/work.png new file mode 100644 index 0000000..8943c4f Binary files /dev/null and b/dot-line-system/public/images/work.png differ diff --git a/dot-line-system/public/vite.svg b/dot-line-system/public/vite.svg new file mode 100644 index 0000000..e7b8dfb --- /dev/null +++ b/dot-line-system/public/vite.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/dot-line-system/readme.md b/dot-line-system/readme.md new file mode 100644 index 0000000..2d357b2 --- /dev/null +++ b/dot-line-system/readme.md @@ -0,0 +1,8 @@ +**Prepare the project** +npm install + +**Start the project** +npm start + +**Aufrufen** +http://localhost:5173/ \ No newline at end of file diff --git a/dot-line-system/src/ConnectedDotsVisualization.ts b/dot-line-system/src/ConnectedDotsVisualization.ts new file mode 100644 index 0000000..090a043 --- /dev/null +++ b/dot-line-system/src/ConnectedDotsVisualization.ts @@ -0,0 +1,519 @@ +// Define interfaces +export interface DotConfig { + id: number; + value: number; + x: number; + link?: string; // URL to navigate to when dot is clicked + imageUrl?: string; // Image to display in tooltip + title?: string; // Optional title for the tooltip + description?: string; // Optional description for the tooltip +} +export interface Config { + totalWidth: number; + height: number; + dotRadius: number; + xUnitSize: number; + tension: number; + showGrid: boolean; + tooltipWidth: number; + tooltipHeight: number; +} +interface ControlPoints { + x1: number; + y1: number; + x2: number; + y2: number; +} +interface TooltipEdges { + leftmost: number; + rightmost: number; +} +export class ConnectedDotsVisualization { + private config: Config; + private dots: DotConfig[]; + private preloadedImages: Map = new Map(); + // DOM Elements + private scrollContainer: HTMLElement; + private svg: SVGElement; + private gridGroup: SVGGElement; + private curvePath: SVGPathElement; + private dotsGroup: SVGGElement; + private tooltipGroup: SVGGElement; + // Active tooltip + private activeTooltip: SVGElement | null = null; + constructor( + containerId: string, + dots: DotConfig[], + config?: Partial + ) { + // Use the provided dots or empty array + this.dots = dots || []; + // Calculate the total width based on dots data + const xUnitSize = config?.xUnitSize || 80; + let calculatedWidth = 0; + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + calculatedWidth = (maxX - minX + 6) * xUnitSize; + } else { + calculatedWidth = 6 * xUnitSize; // Default width if no dots + } + // Default configuration + this.config = { + totalWidth: calculatedWidth, + height: window.innerHeight, + dotRadius: 6, + xUnitSize: xUnitSize, + tension: 0.5, + showGrid: false, + tooltipWidth: 128, + tooltipHeight: 128, + ...config, + }; + // Initialize DOM elements + this.scrollContainer = document.getElementById(containerId) as HTMLElement; + // Create SVG elements + this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); + this.gridGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.curvePath = document.createElementNS( + "http://www.w3.org/2000/svg", + "path" + ); + this.dotsGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + this.tooltipGroup = document.createElementNS( + "http://www.w3.org/2000/svg", + "g" + ); + // Initialize the visualization + this.addStyles(); + this.initializeSVG(); + this.setupEventListeners(); + this.preloadImages(); + this.render(); + } + private preloadImages(): void { + // Extract all unique image URLs from dots + const imageUrls: string[] = this.dots + .filter((dot) => dot.imageUrl) + // biome-ignore lint/style/noNonNullAssertion: + .map((dot) => dot.imageUrl!) + .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates + // Create a loading indicator (optional) + const loadingCount = { current: 0, total: imageUrls.length }; + if (imageUrls.length > 0) { + console.log(`Preloading ${imageUrls.length} images...`); + } + // Preload each image + for (const url of imageUrls) { + const img = new Image(); + // Optional loading events + img.onload = () => { + loadingCount.current++; + if (loadingCount.current === loadingCount.total) { + console.log("All images preloaded successfully"); + } + }; + img.onerror = () => { + loadingCount.current++; + console.error(`Failed to preload image: ${url}`); + }; + // Set src to start loading + img.src = url; + // Store in map for potential later use + this.preloadedImages.set(url, img); + } + } + private addStyles(): void { + // Add necessary styles for tooltips and interactions + const styleId = "connected-dots-styles"; + if (!document.getElementById(styleId)) { + const style = document.createElement("style"); + style.id = styleId; + // style.textContent = ` + + // `; + document.head.appendChild(style); + } + } + private initializeSVG(): void { + // Configure SVG + this.svg.setAttribute("width", `${this.config.totalWidth}`); + this.svg.setAttribute("height", `${this.config.height}`); + this.svg.style.overflow = "visible"; + this.scrollContainer.appendChild(this.svg); + // Configure grid group + this.gridGroup.classList.add("grid"); + this.svg.appendChild(this.gridGroup); + // Configure curve path + this.curvePath.setAttribute("fill", "none"); + this.curvePath.setAttribute("stroke", "white"); + this.curvePath.setAttribute("stroke-width", "2"); + this.curvePath.setAttribute("stroke-linecap", "round"); + this.curvePath.classList.add("curve-path"); + this.svg.appendChild(this.curvePath); + // Configure dots group + this.svg.appendChild(this.dotsGroup); + // Configure tooltip group (always on top) + this.tooltipGroup.classList.add("tooltips"); + this.svg.appendChild(this.tooltipGroup); + } + private setupEventListeners(): void { + // Event listeners removed as the controls were removed + } + private getDotX(x: number): number { + return (x + 3) * this.config.xUnitSize; + } + private getDotY(value: number): number { + const centerY = this.config.height / 1.625; + // Calculate raw Y position + // height of the amplitude + const rawY = centerY - (value / 3) * ((this.config.height / 2) * 0.7); + // Calculate minimum Y position to ensure tooltip fits + const minY = this.config.tooltipHeight + 30; // tooltip height + some padding + // Ensure Y is never less than minimum (never too high on screen) + return Math.max(rawY, minY); + } + private calculateBezierControlPoints( + dots: DotConfig[], + index: number + ): ControlPoints { + const tension = this.config.tension * 500; // Scale tension for Bezier curve Rundung Kurve + // Get current point and its neighbors + const curr = dots[index]; + const next = dots[index + 1]; + // Calculate control points for a smooth bezier curve + const x1 = this.getDotX(curr.x) + tension; + const y1 = this.getDotY(curr.value); + const x2 = this.getDotX(next.x) - tension; + const y2 = this.getDotY(next.value); + return { x1, y1, x2, y2 }; + } + private generateBezierPath(): string { + if (this.dots.length < 2) return ""; + let path = `M ${this.getDotX(this.dots[0].x)} ${this.getDotY( + this.dots[0].value + )}`; + for (let i = 0; i < this.dots.length - 1; i++) { + const { x1, y1, x2, y2 } = this.calculateBezierControlPoints( + this.dots, + i + ); + const nextX = this.getDotX(this.dots[i + 1].x); + const nextY = this.getDotY(this.dots[i + 1].value); + path += ` C ${x1} ${y1}, ${x2} ${y2}, ${nextX} ${nextY}`; + } + return path; + } + private drawGrid(): void { + // Clear previous grid + while (this.gridGroup.firstChild) { + this.gridGroup.removeChild(this.gridGroup.firstChild); + } + if (!this.config.showGrid) return; + // Horizontal grid lines + for (const value of [-3, -2, -1, 0, 1, 2, 3]) { + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", "0"); + line.setAttribute("y1", this.getDotY(value).toString()); + line.setAttribute("x2", this.config.totalWidth.toString()); + line.setAttribute("y2", this.getDotY(value).toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", "10"); + text.setAttribute("y", (this.getDotY(value) + 4).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.textContent = value.toString(); + this.gridGroup.appendChild(text); + } + // Vertical grid lines + const numVertLines = Math.ceil( + this.config.totalWidth / this.config.xUnitSize + ); + for (let i = 0; i < numVertLines; i++) { + const x = i * this.config.xUnitSize; + const xValue = i - 3; // Starting from -3 + const line = document.createElementNS( + "http://www.w3.org/2000/svg", + "line" + ); + line.setAttribute("x1", x.toString()); + line.setAttribute("y1", "0"); + line.setAttribute("x2", x.toString()); + line.setAttribute("y2", this.config.height.toString()); + line.setAttribute("stroke", "rgba(219, 39, 119, 0.4)"); + line.setAttribute("stroke-width", "1"); + this.gridGroup.appendChild(line); + if (xValue !== 0) { + const text = document.createElementNS( + "http://www.w3.org/2000/svg", + "text" + ); + text.setAttribute("x", x.toString()); + text.setAttribute("y", (this.config.height / 2 + 20).toString()); + text.setAttribute("fill", "rgba(219, 39, 119, 0.8)"); + text.setAttribute("font-size", "12"); + text.setAttribute("text-anchor", "middle"); + text.textContent = xValue.toString(); + this.gridGroup.appendChild(text); + } + } + } + + private createTooltip(dot: DotConfig, x: number, y: number): SVGElement { + const tooltip = document.createElementNS("http://www.w3.org/2000/svg", "g"); + tooltip.classList.add("dot-tooltip"); + tooltip.setAttribute("data-dot-id", dot.id.toString()); + + // Calculate tooltip dimensions and position + const tooltipWidth = 128; // Base width for your tooltip + const tooltipHeight = (4 / 3) * tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + let tooltipY = y - tooltipHeight - 10; // Positioned above the dot + tooltipY = Math.max(tooltipY, 10); // Ensure it doesn't go above the view + + // Create background rectangle + const bg = document.createElementNS("http://www.w3.org/2000/svg", "rect"); + bg.setAttribute("x", tooltipX.toString()); + bg.setAttribute("y", tooltipY.toString()); + bg.setAttribute("width", tooltipWidth.toString()); + bg.setAttribute("height", tooltipHeight.toString()); + bg.setAttribute("rx", "0"); // Rounded corners + bg.classList.add("tooltip-background"); + tooltip.appendChild(bg); + + // Create foreignObject for the content + const contentContainer = document.createElementNS( + "http://www.w3.org/2000/svg", + "foreignObject" + ); + contentContainer.setAttribute("x", tooltipX.toString()); + contentContainer.setAttribute("y", tooltipY.toString()); + contentContainer.setAttribute("width", tooltipWidth.toString()); + contentContainer.setAttribute("height", tooltipHeight.toString()); + + // Create a div to contain the content + const div = document.createElement("div"); + div.classList.add("tooltip-content"); + + // Add title if available + if (dot.title) { + const title = document.createElement("div"); + title.textContent = dot.title; + title.classList.add("tooltip-title"); + div.appendChild(title); + } + + // Add description if available + if (dot.description) { + const desc = document.createElement("div"); + desc.textContent = dot.description; + desc.classList.add("tooltip-description"); + div.appendChild(desc); + } + + // Add image if available + // Create a container div + const imageContainer = document.createElement("div"); + imageContainer.classList.add("image_container"); // Add image_container class + + // Define a variable for handling case with or without link + let imgWrapper: HTMLElement; + + // if (dot.imageUrl) { + if (dot.link) { + const link = document.createElement("a"); + link.href = dot.link; + link.target = "_self"; // Opens in the same window + + const imgElement = document.createElement("img"); + imgElement.src = dot.imageUrl; + imgElement.classList.add("tooltip-image"); + + // Append the image element to the link + link.appendChild(imgElement); + imgWrapper = link; // Use the link as the wrapper + + // Add the event listener to the link + link.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } else { + const img = document.createElement("img"); + img.src = dot.imageUrl; + img.classList.add("tooltip-image"); + imgWrapper = img; // Use the image directly as the wrapper + } + // } else { + // console.error("Dot has no image URL"); + // throw new Error("Dot has no image URL"); + // } + + // Append imageWrapper to the container + imageContainer.appendChild(imgWrapper); + + + // Append the image container to the main div + div.appendChild(imageContainer); + + const arrow = document.createElement("div"); + + arrow.classList.add("tooltip-arrow"); + + div.appendChild(arrow); // Append the arrow to the tooltip-content div + + contentContainer.appendChild(div); + tooltip.appendChild(contentContainer); + + return tooltip; + } + + private showTooltip(dot: DotConfig, x: number, y: number): void { + // Create tooltip + const tooltip = this.createTooltip(dot, x, y); + this.tooltipGroup.appendChild(tooltip); + this.activeTooltip = tooltip; + } + private hideTooltip(): void { + // This method is kept for compatibility but doesn't hide tooltips anymore + } + private drawCurve(): void { + const pathData = this.generateBezierPath(); + this.curvePath.setAttribute("d", pathData); + } + private calculateTooltipEdges(): TooltipEdges { + let leftmost = 0; + let rightmost = 0; + let firstTooltipFound = false; + // If no dots with tooltips, return default values + if (this.dots.length === 0) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + // Calculate the leftmost and rightmost edges of all tooltips + for (const dot of this.dots) { + // Skip dots without tooltip content + if (!dot.imageUrl && !dot.title && !dot.description) { + continue; + } + const x = this.getDotX(dot.x); + const tooltipWidth = this.config.tooltipWidth; + const tooltipX = x - tooltipWidth / 2; + if (!firstTooltipFound) { + leftmost = tooltipX; + rightmost = tooltipX + tooltipWidth; + firstTooltipFound = true; + } else { + // Update leftmost and rightmost values + leftmost = Math.min(leftmost, tooltipX); + rightmost = Math.max(rightmost, tooltipX + tooltipWidth); + } + } + // If no dots with tooltips were found, use default values + if (!firstTooltipFound) { + return { leftmost: 0, rightmost: this.config.totalWidth }; + } + return { leftmost, rightmost }; + } + private drawDots(): void { + // Clear previous dots + while (this.dotsGroup.firstChild) { + this.dotsGroup.removeChild(this.dotsGroup.firstChild); + } + // Clear previous tooltips + while (this.tooltipGroup.firstChild) { + this.tooltipGroup.removeChild(this.tooltipGroup.firstChild); + } + for (const dot of this.dots) { + const x = this.getDotX(dot.x); + const y = this.getDotY(dot.value); + const circle = document.createElementNS( + "http://www.w3.org/2000/svg", + "circle" + ); + circle.setAttribute("cx", x.toString()); + circle.setAttribute("cy", y.toString()); + circle.setAttribute("r", this.config.dotRadius.toString()); + circle.setAttribute("fill", "white"); + circle.setAttribute("data-dot-id", dot.id.toString()); + circle.classList.add("dot"); + // Always show tooltip if it has content + if (dot.imageUrl || dot.title || dot.description) { + this.showTooltip(dot, x, y); + } + // Click event for navigation + if (dot.link) { + circle.addEventListener("click", () => { + if (dot.link) { + window.location.href = dot.link; + } else { + console.error("Dot has no link"); + throw new Error("Dot has no link"); + } + }); + } + this.dotsGroup.appendChild(circle); + } + } + public render(): void { + this.drawGrid(); + this.drawCurve(); + this.drawDots(); + // Calculate tooltip edges and set SVG width + const { leftmost, rightmost } = this.calculateTooltipEdges(); + // Set the SVG width based on the rightmost tooltip edge + if (rightmost > 0) { + // Add some padding + const padding = 40; + this.config.totalWidth = rightmost + padding; + this.svg.setAttribute("width", `${this.config.totalWidth}`); + // Update grid width + this.drawGrid(); + } + } + // Public API methods for external use + public updateDots(newDots: DotConfig[]): void { + this.dots = newDots; + // Initial width calculation based on dot positions (for grid) + if (this.dots.length > 0) { + // Find the minimum and maximum x values + const minX = Math.min(...this.dots.map((dot) => dot.x)); + const maxX = Math.max(...this.dots.map((dot) => dot.x)); + // Calculate width based on the range of x values + // Add padding on both sides (3 units on each side) + this.config.totalWidth = (maxX - minX + 6) * this.config.xUnitSize; + } + // Render will calculate the tooltip edges and update the SVG width + this.render(); + } + public updateConfig(newConfig: Partial): void { + this.config = { ...this.config, ...newConfig }; + this.render(); + } + public resize(): void { + this.config.height = window.innerHeight; + this.svg.setAttribute("height", `${this.config.height}`); + this.render(); + } +} diff --git a/dot-line-system/src/main.ts b/dot-line-system/src/main.ts new file mode 100644 index 0000000..cac6f1b --- /dev/null +++ b/dot-line-system/src/main.ts @@ -0,0 +1,320 @@ +import { + ConnectedDotsVisualization, + type DotConfig, +} from "./ConnectedDotsVisualization"; + +import '../src/style.css'; + +/* + * If you are using a bundler like Vite, Webpack, or similar, you need to ensure that the `src/images` folder is included in your build output. + * + * For Vite: + * - Place your images in the `public/images` directory instead of `src/images`. + * - Reference them as `/images/filename.png` in your code. + * + * For Webpack: + * - Use `require` or `import` for images, or configure `copy-webpack-plugin` to copy the `src/images` folder to your output directory. + * + * For static hosting (e.g., GitHub Pages, Netlify): + * - Make sure the images are in the output directory (e.g., `dist/images`) after build. + * + * Example for Vite: + * Move images to `public/images` and update imageUrl paths to `/images/filename.png`. + */ + +// Sample dot configurations +const sampleDots: DotConfig[] = [ + { + id: 1, + value: -1.8, + x: -2, + imageUrl: + "/images/0_3.png", + title: "Beginn des neuen Abenteuers", + description: "01.10.2024", + link: "/page1", + }, + { + id: 2, + value: 1.2, + x: 0, + imageUrl: + "/images/0_2.png", + title: "Omas Annis Geburtstag", + description: "02.10.2024", + link: "/page2", + }, + { + id: 3, + value: -0.6, + x: 2, + imageUrl: + "/images/disco.png", + title: "Konzertbesuch mit Freunden", + description: "03.10.2024", + link: "/page3", + }, + { + id: 4, + value:3, + x: 4, + imageUrl: + "/images/pferd.png", + title: "Wanderreiten in den Bergen", + description: "04.10.2024", + link: "/page4", + }, + { + id: 5, + value: 1, + x: 6, + imageUrl: + "/images/gpt.png", + title: "Ruhiger Tag zu Hause", + description: "05.10.2024", + link: "/page5", + }, + { + id: 6, + value: -3, + x: 8, + imageUrl: + "/images/oma.png", + title: "Oma Erna verstorben", + description: "06.10.2024", + link: "/page6", + }, + { + id: 7, + value: 1.5, + x: 10, + imageUrl: + "/images/see.png", + title: "Erholungsausflug zum See", + description: "07.10.2024", + link: "/page7", + }, + { + id: 8, + value: 0, + x: 12, + imageUrl: + "/images/feier.png", + title: "Kleine Wochenendsfeier", + description: "08.10.2024", + link: "/page8", + }, + { + id: 9, + value: 3, + x: 14, + imageUrl: + "/images/hochzeit.png", + title: "Hochzeit von Cousine Tatjana", + description: "09.10.2024", + link: "/page9", + }, + { + id: 10, + value: 1, + x: 16, + imageUrl: + "/images/work.png", + title: "Erster Tag im neuen Job", + description: "10.10.2024", + link: "/page10", + }, + { + id: 11, + value: -1.2, + x: 18, + imageUrl: + "/images/klasse.png", + title: "Klassentreffen nach vielen Jahren", + description: "11.10.2024", + link: "/page11", + }, + { + id: 12, + value: -0.6, + x: 20, + imageUrl: + "/images/familie.png", + title: "Familienabendessen", + description: "12.10.2024", + link: "/page12", + }, + { + id: 13, + value: 2.7, + x: 22, + imageUrl: + "/images/kinobesuch.png", + title: "Kinobesuch mit der ganzen Familie", + description: "13.10.2024", + link: "/page13", + }, + { + id: 14, + value: 0, + x: 24, + imageUrl: + "/images/entspannung.png", + title: "Entspannung", + description: "14.10.2024", + link: "/page14", + }, + { + id: 15, + value: -2.9, + x: 26, + imageUrl: "/images/sonntag.png", + title: "Geruhsamer Sonntag", + description: "15.10.2024", + link: "/page15", + }, + { + id: 16, + value: 1.5, + x: 28, + imageUrl: + "/images/kindergeburtstag.png", + title: "Kindergeburtstag", + description: "16.10.2024", + link: "/page16", + }, + { + id: 17, + value: 0, + x: 30, + imageUrl: + "/images/familie2.png", + title: "Spaziergang mit der Familie", + description: "17.10.2024", + link: "/page17", + }, + { + id: 18, + value: 2.1, + x: 32, + imageUrl: + "/images/grosseltern.png", + title: "Familienfeier bei den Großeltern", + description: "18.10.2024", + link: "/page18", + }, +]; + +// Wait for DOM to be fully loaded +document.addEventListener("DOMContentLoaded", () => { + // Initialize the visualization with the sample dots + const visualization = new ConnectedDotsVisualization( + "scroll-container", + sampleDots, + { + // Optional custom configuration + dotRadius: 8, + // tooltipWidth: 100, + // tooltipHeight: 100, + } + ); + + // Handle window resize + window.addEventListener("resize", () => { + visualization.resize(); + }); + + // Example of updating dots dynamically (if needed) + /* + const updateButton = document.createElement('button'); + updateButton.textContent = 'Update Data'; + updateButton.classList.add('button'); + updateButton.style.marginTop = '10px'; + document.body.appendChild(updateButton); + + updateButton.addEventListener('click', () => { + // Generate some new random data with image tooltips + const newDots: DotConfig[] = Array.from({ length: 9 }, (_, i) => ({ + id: i + 1, + value: Math.random() * 6 - 3, // Random value between -3 and 3 + x: i - 3, + imageUrl: `https://picsum.photos/200/150?random=${i+10}`, + title: `Point ${i+1}`, + description: `This is data point ${i+1} with value ${(Math.random() * 6 - 3).toFixed(1)}` + })); + visualization.updateDots(newDots); + }); + */ + + const scrollContainer = document.querySelector(".scroll-container") as HTMLElement; + + let isDown = false; + let startX: number; + let scrollLeft: number; + + + // Mouse events + scrollContainer.addEventListener("mousedown", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + + // Remove smooth scrolling while dragging + scrollContainer.classList.remove("smooth-scroll"); + }); + + scrollContainer.addEventListener("mouseleave", () => { + if (!isDown) return; + isDown = false; + scrollContainer.classList.remove("active"); + + // Add smooth scrolling after dragging + scrollContainer.classList.add("smooth-scroll"); + }); + + scrollContainer.addEventListener("mouseup", () => { + if (!isDown) return; + isDown = false; + scrollContainer.classList.remove("active"); + + // Add smooth scrolling after dragging + scrollContainer.classList.add("smooth-scroll"); + }); + + scrollContainer.addEventListener("mousemove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; // Multiply by a number to speed up scrolling + scrollContainer.scrollLeft = scrollLeft - walk; + }); + + // Touch events + scrollContainer.addEventListener("touchstart", (e) => { + isDown = true; + scrollContainer.classList.add("active"); + startX = e.touches[0].pageX - scrollContainer.offsetLeft; + scrollLeft = scrollContainer.scrollLeft; + + // Remove smooth scrolling while dragging + scrollContainer.classList.remove("smooth-scroll"); + }); + + scrollContainer.addEventListener("touchend", () => { + if (!isDown) return; + isDown = false; + scrollContainer.classList.remove("active"); + + // Add smooth scrolling after dragging + scrollContainer.classList.add("smooth-scroll"); + }); + + scrollContainer.addEventListener("touchmove", (e) => { + if (!isDown) return; + e.preventDefault(); + const x = e.touches[0].pageX - scrollContainer.offsetLeft; + const walk = (x - startX) * 3; + scrollContainer.scrollLeft = scrollLeft - walk; + }); +}); diff --git a/dot-line-system/src/style.css b/dot-line-system/src/style.css new file mode 100644 index 0000000..9d13415 --- /dev/null +++ b/dot-line-system/src/style.css @@ -0,0 +1,203 @@ + body { + font-family: "Barlow Condensed", sans-serif; + font-optical-sizing: auto; + font-weight: 400; + font-style: normal; + font-size: 16px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + min-height: 100vh; + margin: 0; + padding: 0; + box-sizing: border-box; + } + + .controls { + display: flex; + justify-content: space-between; + width: 100%; + max-width: 500px; + margin-bottom: 10px; + } + + .button { + padding: 6px 12px; + background-color: #4f46e5; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + } + + .visualization-container { + position: absolute; + width: 100vw; + height: 100vh; + left: 0; + right: 0; + margin-left: calc(-50vw + 50%); + } + + .gradient-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100vh; + min-width: 100%; + z-index: -1; + background: linear-gradient(45deg, #8634f9, #ffab1a, #ff2fa2); + background-size: 200% 200%; + animation: gradientAnimation 20s ease infinite; + } + + @keyframes gradientAnimation { + 0% { + background-position: 0% 0%; + } + + 25% { + background-position: 100% 0%; + } + + 50% { + background-position: 100% 100%; + } + + 75% { + background-position: 0% 100%; + } + + 100% { + background-position: 0% 0%; + } + } + + .median { + position: fixed; + top: 61.5%; + left: 0; + height: 1px; + border-top: 1px dashed rgba(255, 255, 255, 0.2); + width: 100%; + z-index: -1; + /* background-color: rgba(255, 255, 255, 0.2); */ + } + + .scroll-container { + position: relative; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + scroll-behavior: smooth; + box-sizing: border-box; + } + + .scroll-container:active { + cursor: grabbing; + /* Change cursor when active */ + } + + .smooth-scroll { + transition: scroll-left 0.5s ease-out; /* Add easing on scroll-left */ +} + + .spacer { + height: 100vh; + } + + .dot-tooltip .tooltip-background { + fill: rgba(0, 0, 0, 0.0); + } + + .dot-tooltip .tooltip-content { + display: flex; + flex-direction: column; + justify-content: center; + /* Center vertically */ + align-items: center; + /* Center horizontally */ + width: 100%; + height: 100%; + color: white; + /* Text color */ + } + + .dot-tooltip .image_container { + margin-top: 8px; + /* box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); */ + box-shadow: 0 0 20px 0 rgba(255, 255, 255, 0.25); + transition: box-shadow 0.25s ease-in-out; + } + + .dot-tooltip .image_container:hover { + + box-shadow: 0 0 30px 0 rgba(255, 255, 255, 0.8); + /* box-shadow: 0 0 30px 0 rgba(0, 0, 0, 0.5); */ + transition: box-shadow 0.25s ease-in-out; + + } + + .dot-tooltip .tooltip-image { + width: 100%; + height: auto; + display: block; + pointer-events: auto; + + } + + .dot-tooltip .tooltip-title { + font-size: 14px; + font-weight: 400; + margin-bottom: 2px; + text-align: center; + text-wrap: balance; + hyphens: auto; + line-height: 1.1; + } + + .dot-tooltip .tooltip-description { + font-size: 12px; + font-weight: 300; + } + + .dot-tooltip .image_container { + width: 80px; + height: 80px; + overflow: hidden; + border-radius: 50%; + border: 2px solid white; + display: flex; + justify-content: center; + } + + .dot-tooltip .tooltip-arrow { + width: 1px; + height: 30px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.5), transparent); + } + + .dot { + transition: r 0.2s ease, fill 0.2s ease; + cursor: pointer; + } + + .dot:hover { + fill: rgba(255, 255, 255, 0.9); + filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8)); + } + + .dot-tooltip { + pointer-events: none; + opacity: 1; + /* Always visible */ + } + + .tooltip-img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 4px; + } \ No newline at end of file diff --git a/dot-line-system/src/typescript.svg b/dot-line-system/src/typescript.svg new file mode 100644 index 0000000..d91c910 --- /dev/null +++ b/dot-line-system/src/typescript.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/dot-line-system/src/vite-env.d.ts b/dot-line-system/src/vite-env.d.ts new file mode 100644 index 0000000..11f02fe --- /dev/null +++ b/dot-line-system/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/dot-line-system/tsconfig.json b/dot-line-system/tsconfig.json new file mode 100644 index 0000000..a4883f2 --- /dev/null +++ b/dot-line-system/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "isolatedModules": true, + "moduleDetection": "force", + "noEmit": true, + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedSideEffectImports": true + }, + "include": ["src"] +} diff --git a/frontend/README.md b/frontend/README.md index 1c77bf6..83105c4 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -10,6 +10,13 @@ yarn npm install ``` +## erste installation +npm i -g @quasar/cli +npm init quasar@latest + +## Now, do you want to be able to run Quasar CLI commands directly (eg. $ quasar dev/build) + npm i -g @quasar/cli + ### Start the app in development mode (hot-code reloading, error reporting, etc.) ```bash diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 3db3b25..801f1d6 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -628,19 +628,22 @@ "license": "MIT" }, "node_modules/@eslint/config-helpers": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.3.1.tgz", - "integrity": "sha512-xR93k9WhrDYpXHORXpxVL5oHj3Era7wo6k/Wd8/IsQNnZUTzkGS29lyn3nAT05v6ltUuTFVCCYDEGfy2Or/sPA==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.4.0.tgz", + "integrity": "sha512-WUFvV4WoIwW8Bv0KeKCIIEgdSiFOsulyN0xrMu+7z43q/hkOLXjvb5u7UC9jDxvRzcrbEmuZBX5yJZz1741jog==", "dev": true, "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^0.16.0" + }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, "node_modules/@eslint/core": { - "version": "0.15.2", - "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.15.2.tgz", - "integrity": "sha512-78Md3/Rrxh83gCxoUc0EiciuOHsIITzLy53m3d9UyiW8y9Dj2D29FeETqyKA+BRK76tnTp6RXWb3pCay8Oyomg==", + "version": "0.16.0", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.16.0.tgz", + "integrity": "sha512-nmC8/totwobIiFcGkDza3GIKfAw1+hLiYVrh3I1nIomQ8PEr5cxg34jnkmGawul/ep52wGRAcyeDCNtWKSOj4Q==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -713,9 +716,9 @@ "license": "MIT" }, "node_modules/@eslint/js": { - "version": "9.35.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.35.0.tgz", - "integrity": "sha512-30iXE9whjlILfWobBkNerJo+TXYsgVM5ERQwMcMKCHckHflCmf7wXDAHlARoWnh0s1U72WqlbeyE7iAcCzuCPw==", + "version": "9.37.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.37.0.tgz", + "integrity": "sha512-jaS+NJ+hximswBG6pjNX0uEJZkrT0zwpVi3BA3vX22aFGjJjmgSTSmPpZCRKmoBL5VY/M6p0xsSJx7rk7sy5gg==", "dev": true, "license": "MIT", "engines": { @@ -736,13 +739,13 @@ } }, "node_modules/@eslint/plugin-kit": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.3.5.tgz", - "integrity": "sha512-Z5kJ+wU3oA7MMIqVR9tyZRtjYPr4OC004Q4Rw7pgOKUOKkJfZ3O24nz3WYfGRpMDNmcOi3TwQOmgm7B7Tpii0w==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.4.0.tgz", + "integrity": "sha512-sB5uyeq+dwCWyPi31B2gQlVlo+j5brPlWx4yZBrEaRo/nhdDE8Xke1gsGgtiBdaBTxuTkceLVuVt/pclrasb0A==", "dev": true, "license": "Apache-2.0", "dependencies": { - "@eslint/core": "^0.15.2", + "@eslint/core": "^0.16.0", "levn": "^0.4.1" }, "engines": { @@ -1981,9 +1984,7 @@ "integrity": "sha512-+MaE752hU0wfPFJEUAIxqw18+20euHHdxVtMvbFcOEpjEyfqXH/5DCoTHiVJ0J29EhTJdoTkjEv5YBKU9dnoTw==", "dev": true, "license": "MIT", - "dependencies": { - "@rolldown/pluginutils": "1.0.0-beta.29" - }, + "peer": true, "engines": { "node": "^20.19.0 || >=22.12.0" }, @@ -2183,6 +2184,7 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -2569,6 +2571,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "baseline-browser-mapping": "^2.8.2", "caniuse-lite": "^1.0.30001741", @@ -3474,20 +3477,21 @@ } }, "node_modules/eslint": { - "version": "9.35.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.35.0.tgz", - "integrity": "sha512-QePbBFMJFjgmlE+cXAlbHZbHpdFVS2E/6vzCy7aKlebddvl1vadiC4JFV5u/wqTkNUwEV8WrQi257jf5f06hrg==", + "version": "9.37.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.37.0.tgz", + "integrity": "sha512-XyLmROnACWqSxiGYArdef1fItQd47weqB7iwtfr9JHwRrqIXZdcFMvvEcL9xHCmL0SNsOvF0c42lWyM1U5dgig==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", "@eslint/config-array": "^0.21.0", - "@eslint/config-helpers": "^0.3.1", - "@eslint/core": "^0.15.2", + "@eslint/config-helpers": "^0.4.0", + "@eslint/core": "^0.16.0", "@eslint/eslintrc": "^3.3.1", - "@eslint/js": "9.35.0", - "@eslint/plugin-kit": "^0.3.5", + "@eslint/js": "9.37.0", + "@eslint/plugin-kit": "^0.4.0", "@humanfs/node": "^0.16.6", "@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/retry": "^0.4.2", @@ -3540,6 +3544,7 @@ "integrity": "sha512-82GZUjRS0p/jganf6q1rEO25VSoHH0hKPCTrgillPjdI/3bgBhAE1QzHrHTizjpRvy6pGAvKjDJtk2pF9NDq8w==", "dev": true, "license": "MIT", + "peer": true, "bin": { "eslint-config-prettier": "bin/cli.js" }, @@ -5241,6 +5246,7 @@ "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "deep-is": "^0.1.3", "fast-levenshtein": "^2.0.6", @@ -5442,6 +5448,7 @@ "resolved": "https://registry.npmjs.org/pinia/-/pinia-3.0.3.tgz", "integrity": "sha512-ttXO/InUULUXkMHpTdp9Fj4hLpD/2AoJdmAbAeW2yu1iy1k+pkFekQXw5VpC0/5p51IOR/jDaDRfRWRnMMsGOA==", "license": "MIT", + "peer": true, "dependencies": { "@vue/devtools-api": "^7.7.2" }, @@ -5489,6 +5496,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "nanoid": "^3.3.11", "picocolors": "^1.1.1", @@ -5535,6 +5543,7 @@ "integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==", "dev": true, "license": "MIT", + "peer": true, "bin": { "prettier": "bin/prettier.cjs" }, @@ -5620,6 +5629,7 @@ "resolved": "https://registry.npmjs.org/quasar/-/quasar-2.18.2.tgz", "integrity": "sha512-SeSAamH4vgYH9alLTdVL2o1fTTwz7VZnS2+gvIwt6qsH3ndrn/tQW64sWE78VSvrHlWINYbXESVF/cvWEuTYxg==", "license": "MIT", + "peer": true, "engines": { "node": ">= 10.18.1", "npm": ">= 6.13.4", @@ -5817,6 +5827,7 @@ "integrity": "sha512-78E9voJHwnXQMiQdiqswVLZwJIzdBKJ1GdI5Zx6XwoFKUIk09/sSrr+05QFzvYb8q6Y9pPV45zzDuYa3907TZA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@types/estree": "1.0.8" }, @@ -6991,6 +7002,7 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, @@ -7206,18 +7218,19 @@ } }, "node_modules/vite": { - "version": "7.1.5", - "resolved": "https://registry.npmjs.org/vite/-/vite-7.1.5.tgz", - "integrity": "sha512-4cKBO9wR75r0BeIWWWId9XK9Lj6La5X846Zw9dFfzMRw38IlTk2iCcUt6hsyiDRcPidc55ZParFYDXi0nXOeLQ==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/vite/-/vite-6.4.0.tgz", + "integrity": "sha512-oLnWs9Hak/LOlKjeSpOwD6JMks8BeICEdYMJBf6P4Lac/pO9tKiv/XhXnAM7nNfSkZahjlCZu9sS50zL8fSnsw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "esbuild": "^0.25.0", - "fdir": "^6.5.0", - "picomatch": "^4.0.3", - "postcss": "^8.5.6", - "rollup": "^4.43.0", - "tinyglobby": "^0.2.15" + "fdir": "^6.4.4", + "picomatch": "^4.0.2", + "postcss": "^8.5.3", + "rollup": "^4.34.9", + "tinyglobby": "^0.2.13" }, "bin": { "vite": "bin/vite.js" @@ -7438,6 +7451,7 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, @@ -7457,6 +7471,7 @@ "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.21.tgz", "integrity": "sha512-xxf9rum9KtOdwdRkiApWL+9hZEMWE90FHh8yS1+KJAiWYh+iGWV1FquPjoO9VUHQ+VIhsCXNNyZ5Sf4++RVZBA==", "license": "MIT", + "peer": true, "dependencies": { "@vue/compiler-dom": "3.5.21", "@vue/compiler-sfc": "3.5.21", diff --git a/frontend/quasar.config.js b/frontend/quasar.config.js index b2a85eb..e26694a 100644 --- a/frontend/quasar.config.js +++ b/frontend/quasar.config.js @@ -72,7 +72,8 @@ export default defineConfig((/* ctx */) => { // Full list of options: https://v2.quasar.dev/quasar-cli-vite/quasar-config-file#devserver devServer: { // https: true, - open: true // opens browser window automatically + open: true, // opens browser window automatically + allowedHosts: ['app.thats-me.test'] }, // https://v2.quasar.dev/quasar-cli-vite/quasar-config-file#framework diff --git a/thats-me.test.code-workspace b/thats-me.test.code-workspace index 876a149..665b01c 100644 --- a/thats-me.test.code-workspace +++ b/thats-me.test.code-workspace @@ -1,8 +1,31 @@ { + "name": "Thats Me [Dev Container]", "folders": [ { + "name": "🚀 Backend (Laravel)", + "path": "./backend" + }, + { + "name": "⚡ Frontend (Quasar)", + "path": "./frontend" + }, + { + "name": "📦 Projekt Root", "path": "." } ], - "settings": {} + "settings": { + "files.associations": { + "*.blade.php": "blade" + } + }, + "extensions": { + "recommendations": [ + "bmewburn.vscode-intelephense-client", + "onecentlin.laravel-blade", + "bradlc.vscode-tailwindcss", + "dbaeumer.vscode-eslint", + "Vue.volar" + ] + } } \ No newline at end of file