Skip to content

Documentation: Layer example not working #146

@ni-m

Description

@ni-m

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/[email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ ├─┬ @vue/[email protected]
│ │ └─┬ @vue/[email protected]
│ │   └── [email protected] deduped
│ ├─┬ @vueuse/[email protected]
│ │ ├─┬ @vueuse/[email protected]
│ │ │ └─┬ [email protected]
│ │ │   └── [email protected] deduped
│ │ └─┬ [email protected]
│ │   └── [email protected] deduped
│ ├─┬ @vueuse/[email protected]
│ │ └─┬ [email protected]
│ │   └── [email protected] deduped
│ └── [email protected] deduped
└─┬ [email protected]
  └─┬ @vue/[email protected]
    └── [email protected] deduped

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions