From 5611f79ea8d065bcde91d2c141a9a0792311f9b6 Mon Sep 17 00:00:00 2001 From: Braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Fri, 22 Oct 2021 09:53:18 +0200 Subject: [PATCH] update(examples): Add stress example --- examples/Stress/StressExample.vue | 61 +++++++++++++++++++++++++++++++ examples/Stress/utils.ts | 30 +++++++++++++++ examples/router.ts | 4 ++ 3 files changed, 95 insertions(+) create mode 100644 examples/Stress/StressExample.vue create mode 100644 examples/Stress/utils.ts diff --git a/examples/Stress/StressExample.vue b/examples/Stress/StressExample.vue new file mode 100644 index 00000000..4c5b2a5b --- /dev/null +++ b/examples/Stress/StressExample.vue @@ -0,0 +1,61 @@ + + + + + + + + + change pos + update elements + + + diff --git a/examples/Stress/utils.ts b/examples/Stress/utils.ts new file mode 100644 index 00000000..8429f4ef --- /dev/null +++ b/examples/Stress/utils.ts @@ -0,0 +1,30 @@ +import { Elements } from '~/index' + +export function getElements(xElements = 10, yElements = 10): Elements { + const initialElements = [] + let nodeId = 1 + let recentNodeId = null + + for (let y = 0; y < yElements; y++) { + for (let x = 0; x < xElements; x++) { + const position = { x: x * 100, y: y * 50 } + const data = { label: `Node ${nodeId}` } + const node = { + id: nodeId.toString(), + style: { width: 50, fontSize: 11 }, + data, + position, + } + initialElements.push(node) + + if (recentNodeId && nodeId <= xElements * yElements) { + initialElements.push({ id: `${x}-${y}`, source: recentNodeId.toString(), target: nodeId.toString() }) + } + + recentNodeId = nodeId + nodeId++ + } + } + + return initialElements as Elements +} diff --git a/examples/router.ts b/examples/router.ts index bb60ab57..b79eaf4c 100644 --- a/examples/router.ts +++ b/examples/router.ts @@ -73,6 +73,10 @@ export const routes: RouterOptions['routes'] = [ path: '/save-restore', component: () => import('./SaveRestore/SaveRestoreExample.vue'), }, + { + path: '/stress', + component: () => import('./Stress/StressExample.vue'), + }, ] export const router = createRouter({