dash14 / v-network-graph

An interactive network graph visualization component for Vue 3
https://dash14.github.io/v-network-graph/
MIT License
480 stars 44 forks source link

Documentation: Layer example not working #146

Open ni-m opened 3 months ago

ni-m commented 3 months ago

Expected behaviour

Using the example from Layers to display a custom background behind the network-graph.

Actual behaviour

The site refuses to load and throws the following error: Uncaught SyntaxError: Identifier '\__vite__injectQuery' has already been declared (at ${mod.id}:55007:1)

Possible solution

By replacing the :href="withBase('/worldmap.svg')" with :href="'./worldmap.svg'" the side loads as expected and the custom svg is displayed in the background.

I'm not certain what caused the error but with the above adjustments the example works fine.

Example code

<script setup lang="ts">
import { ref } from "vue"
import * as vNG from "v-network-graph"
import { withBase } from "vitepress"
import data from "./data"

// additional layers definition
const layers = {
  // {layername}: {position}
  worldmap: "base",
}

// ref="graph"
const graph = ref<vNG.Instance>()

function onLoadImage() {
  graph.value?.fitToContents()
}
</script>

<template>
  <v-network-graph
    ref="graph"
    :nodes="data.nodes"
    :edges="data.edges"
    :layouts="data.layouts"
    :configs="data.configs"
    :layers="layers"
  >
    <!-- Additional layer -->
    <template #worldmap>
      <image
        :href="withBase('/worldmap.svg')"
        x="0"
        y="0"
        width="1000px"
        @load="onLoadImage"
      />
    </template>
  </v-network-graph>
</template>

Vue version

├─┬ @vitejs/plugin-vue@5.0.4
│ └── vue@3.4.21 deduped
├─┬ v-network-graph@0.9.15
│ └── vue@3.4.21 deduped
├─┬ vitepress@1.0.1
│ ├─┬ @vue/devtools-api@7.0.23
│ │ └─┬ @vue/devtools-kit@7.0.23
│ │   └── vue@3.4.21 deduped
│ ├─┬ @vueuse/core@10.9.0
│ │ ├─┬ @vueuse/shared@10.9.0
│ │ │ └─┬ vue-demi@0.14.7
│ │ │   └── vue@3.4.21 deduped
│ │ └─┬ vue-demi@0.14.7
│ │   └── vue@3.4.21 deduped
│ ├─┬ @vueuse/integrations@10.9.0
│ │ └─┬ vue-demi@0.14.7
│ │   └── vue@3.4.21 deduped
│ └── vue@3.4.21 deduped
└─┬ vue@3.4.21
  └─┬ @vue/server-renderer@3.4.21
    └── vue@3.4.21 deduped