Skip to content

Commit

Permalink
doku code
Browse files Browse the repository at this point in the history
  • Loading branch information
ogerly committed Aug 15, 2024
1 parent f3e86d6 commit ce74a28
Showing 1 changed file with 55 additions and 3 deletions.
58 changes: 55 additions & 3 deletions frontend/src/components/ClusterGalaxy/ClusterGalaxyVisualizer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@ export default defineComponent({
const spaceWidth = ref(0);
const spaceHeight = ref(0);
// Computed Property, das die Cluster anhand der Suchanfrage filtert
const filteredClusters = computed(() => {
return clusters.value.filter((cluster) =>
cluster.name.toLowerCase().includes(searchQuery.value.toLowerCase())
);
});
// Funktion, um das Canvas zu initialisieren und Event-Listener hinzuzufügen
const initCanvas = () => {
if (canvas.value) {
ctx.value = canvas.value.getContext('2d');

Check failure on line 71 in frontend/src/components/ClusterGalaxy/ClusterGalaxyVisualizer.vue

View workflow job for this annotation

GitHub Actions / Unit - Frontend

src/layouts/DefaultLayout.test.ts > DefaultLayout > renders

TypeError: canvas.value.getContext is not a function ❯ initCanvas src/components/ClusterGalaxy/ClusterGalaxyVisualizer.vue:71:34 ❯ src/components/ClusterGalaxy/ClusterGalaxyVisualizer.vue:328:7 ❯ node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:1546:40 ❯ callWithErrorHandling node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:203:19 ❯ callWithAsyncErrorHandling node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:210:17 ❯ hook.__weh.hook.__weh node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:1526:19 ❯ flushPostFlushCbs node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:385:32 ❯ render node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5616:7 ❯ mount node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:2644:13 ❯ app.mount node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.js:1463:19

Check failure on line 71 in frontend/src/components/ClusterGalaxy/ClusterGalaxyVisualizer.vue

View workflow job for this annotation

GitHub Actions / Unit - Frontend

src/layouts/DefaultLayout.test.ts > DefaultLayout > new table button > enter table > apollo with success > calls the api

TypeError: canvas.value.getContext is not a function ❯ initCanvas src/components/ClusterGalaxy/ClusterGalaxyVisualizer.vue:71:34 ❯ src/components/ClusterGalaxy/ClusterGalaxyVisualizer.vue:328:7 ❯ node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:1546:40 ❯ callWithErrorHandling node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:203:19 ❯ callWithAsyncErrorHandling node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:210:17 ❯ hook.__weh.hook.__weh node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:1526:19 ❯ flushPostFlushCbs node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:385:32 ❯ render node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5616:7 ❯ mount node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:2644:13 ❯ app.mount node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.js:1463:19

Check failure on line 71 in frontend/src/components/ClusterGalaxy/ClusterGalaxyVisualizer.vue

View workflow job for this annotation

GitHub Actions / Unit - Frontend

src/layouts/DefaultLayout.test.ts > DefaultLayout > new table button > enter table > apollo with success > navigates to table page

TypeError: canvas.value.getContext is not a function ❯ initCanvas src/components/ClusterGalaxy/ClusterGalaxyVisualizer.vue:71:34 ❯ src/components/ClusterGalaxy/ClusterGalaxyVisualizer.vue:328:7 ❯ node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:1546:40 ❯ callWithErrorHandling node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:203:19 ❯ callWithAsyncErrorHandling node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:210:17 ❯ hook.__weh.hook.__weh node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:1526:19 ❯ flushPostFlushCbs node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:385:32 ❯ render node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5616:7 ❯ mount node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:2644:13 ❯ app.mount node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.js:1463:19

Check failure on line 71 in frontend/src/components/ClusterGalaxy/ClusterGalaxyVisualizer.vue

View workflow job for this annotation

GitHub Actions / Unit - Frontend

src/layouts/DefaultLayout.test.ts > DefaultLayout > new table button > enter table > apollo with no data > calls the api

TypeError: canvas.value.getContext is not a function ❯ initCanvas src/components/ClusterGalaxy/ClusterGalaxyVisualizer.vue:71:34 ❯ src/components/ClusterGalaxy/ClusterGalaxyVisualizer.vue:328:7 ❯ node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:1546:40 ❯ callWithErrorHandling node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:203:19 ❯ callWithAsyncErrorHandling node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:210:17 ❯ hook.__weh.hook.__weh node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:1526:19 ❯ flushPostFlushCbs node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:385:32 ❯ render node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5616:7 ❯ mount node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:2644:13 ❯ app.mount node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.js:1463:19

Check failure on line 71 in frontend/src/components/ClusterGalaxy/ClusterGalaxyVisualizer.vue

View workflow job for this annotation

GitHub Actions / Unit - Frontend

src/layouts/DefaultLayout.test.ts > DefaultLayout > new table button > enter table > apollo with no data > does not call navigate

TypeError: canvas.value.getContext is not a function ❯ initCanvas src/components/ClusterGalaxy/ClusterGalaxyVisualizer.vue:71:34 ❯ src/components/ClusterGalaxy/ClusterGalaxyVisualizer.vue:328:7 ❯ node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:1546:40 ❯ callWithErrorHandling node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:203:19 ❯ callWithAsyncErrorHandling node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:210:17 ❯ hook.__weh.hook.__weh node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:1526:19 ❯ flushPostFlushCbs node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:385:32 ❯ render node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5616:7 ❯ mount node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:2644:13 ❯ app.mount node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.js:1463:19
Expand All @@ -74,6 +76,7 @@ export default defineComponent({
}
};
// Funktion, um das Canvas und den Raum für die Cluster-Größe anzupassen
const resizeCanvas = () => {
if (canvas.value) {
const container = canvas.value.parentElement;
Expand All @@ -87,10 +90,14 @@ export default defineComponent({
}
};
/**
* Funktion zur Generierung der Cluster.
* Die Cluster werden in einem Rastermuster angeordnet, wobei jeder Cluster eine Anzahl von Punkten enthält.
*/
const generateClusters = () => {
const clusterCount = 1;
const clusterCount = 100;
const baseSizeScale = 30;
const clusterSpacing = 300;
const clusterSpacing = 500;
const clusterNames = generateClusterNames(clusterCount);
clusters.value = [];
Expand Down Expand Up @@ -122,6 +129,9 @@ export default defineComponent({
}
};
/**
* Generiert Namen für die Cluster basierend auf ihrer Anzahl.
*/
const generateClusterNames = (count: number) => {
const names = [];
for (let i = 1; i <= count; i++) {
Expand All @@ -130,6 +140,10 @@ export default defineComponent({
return names;
};
/**
* Zeichnet die Cluster und ihre Punkte auf das Canvas.
* Die Cluster werden entsprechend der aktuellen Skalierung und des Offsets gerendert.
*/
const drawClusters = () => {
if (!ctx.value || !canvas.value) {
console.log("Canvas oder Context nicht initialisiert");
Expand Down Expand Up @@ -171,6 +185,10 @@ export default defineComponent({
console.log("Zeichnen abgeschlossen");
};
/**
* Funktion, um die Zoom-Aktion auf dem Canvas zu handhaben.
* Die Skalierung des Canvas wird basierend auf dem Mausrad-Event angepasst.
*/
const onZoom = (event: WheelEvent) => {
event.preventDefault();
event.stopPropagation();
Expand All @@ -182,20 +200,33 @@ export default defineComponent({
drawClusters();
};
/**
* Handhabt das Panning (Verschieben) des Canvas, wenn die Maus gezogen wird.
*/
const onPan = (event: MouseEvent) => {
offsetX.value += event.movementX;
offsetY.value += event.movementY;
drawClusters();
};
/**
* Hinzufügen des Pan-Events beim Drücken der Maustaste.
*/
const onMouseDown = (event: MouseEvent) => {
canvas.value?.addEventListener('mousemove', onPan);
};
/**
* Entfernen des Pan-Events, wenn die Maustaste losgelassen wird.
*/
const onMouseUp = (event: MouseEvent) => {
canvas.value?.removeEventListener('mousemove', onPan);
};
/**
* Handhabt den Klick auf einen Punkt oder Cluster auf dem Canvas.
* Bestimmt, welcher Punkt oder Cluster angeklickt wurde und zeigt entsprechende Details an.
*/
const onClick = (event: MouseEvent) => {
const rect = canvas.value?.getBoundingClientRect();
if (!rect) return;
Expand Down Expand Up @@ -234,6 +265,10 @@ export default defineComponent({
}
};
/**
* Überprüft, ob der Mauszeiger innerhalb eines Clusters ist.
* Nützlich, um festzustellen, ob ein Cluster angeklickt wurde.
*/
const isInsideCluster = (x: number, y: number, cluster: any) => {
for (const point of cluster.points) {
const distance = Math.sqrt(Math.pow(point.x - x, 2) + Math.pow(point.y - y, 2));
Expand All @@ -244,13 +279,21 @@ export default defineComponent({
return false;
};
/**
* Zeigt die Details eines angeklickten Punktes an.
* Diese Details umfassen den Cluster-Namen und die Punktkoordinaten.
*/
const showPointDetails = (point: any, cluster: any) => {
selectedInfo.value = [
{ text: `Cluster: ${cluster.name}` },
{ text: `Punkt: (${Math.round(point.x)}, ${Math.round(point.y)})` },
];
};
/**
* Zeigt die Details eines angeklickten Clusters an.
* Diese Details umfassen den Cluster-Namen und die Koordinaten aller aktiven Punkte im Cluster.
*/
const showClusterDetails = (cluster: any) => {
selectedInfo.value = [{ text: `Cluster: ${cluster.name}` }];
cluster.points.forEach((point: any, index: number) => {
Expand All @@ -262,8 +305,16 @@ export default defineComponent({
});
};
/**
* Placeholder-Funktion für das Such-Input-Feld.
* Aktuell wird die Filterung über das `filteredClusters` Computed Property gesteuert.
*/
const onSearchInput = () => {};
/**
* Zoomt auf den spezifischen Cluster, wenn dieser ausgewählt wird.
* Die Ansicht wird so zentriert, dass der ausgewählte Cluster im Fokus steht.
*/
const zoomToCluster = (cluster: any) => {
scale.value = 2;
offsetX.value = canvas.value!.width / 2 - cluster.centerX * scale.value;
Expand All @@ -272,6 +323,7 @@ export default defineComponent({
searchQuery.value = '';
};
// Mount Lifecycle-Hook: Initialisiert das Canvas, generiert Cluster und fügt Event-Listener hinzu
onMounted(() => {
initCanvas();
resizeCanvas();
Expand Down

0 comments on commit ce74a28

Please sign in to comment.