Giter Club home page Giter Club logo

Comments (4)

dashavoo avatar dashavoo commented on June 15, 2024 1

That has solved the issue!
Thank you for the fast help and the really useful library!

from v-network-graph.

dash14 avatar dash14 commented on June 15, 2024

Hi @dashavoo,

Thank you for your detailed report.
The minimal code to reproduce the problem you provided, helped me to quickly identify the issue point.
Thank you very much!

I've made a fix, please try a newer version. (v0.3.17).

from v-network-graph.

dashavoo avatar dashavoo commented on June 15, 2024

Thank you @dash14, you reacted really quickly to the bug report.
ForceLayout (with non-default settings) isn't working after the fix, but everything else works fine.

If you modify my previous example slightly to this:

<script setup lang="ts">
import { reactive, computed } from "vue"
import { ForceLayout } from "v-network-graph/lib/force-layout";

const whatsits = reactive([{id: "blah", name: "hi there"}])
const edges = reactive({});
const addNode = function () {
  whatsits.push({id: "secondNode", name: "this works?"});
}

const configs = {
  view: {
    layoutHandler: new ForceLayout({
      positionFixedByDrag: true,
      positionFixedByClickWithAltKey: false,
      // * The following are the default parameters for the simulation.
      // * You can customize it by uncommenting below.
      createSimulation: (d3, nodes, edges) => {
        return d3.forceSimulation(nodes)
      },
    }),
  },
}

const nodes = computed(() => Object.fromEntries(whatsits.map(e => [e.id, { name: e.name }])));
</script>

<template>
  <button type="button" @click="addNode">Add node</button>
  <ul>
    <li v-for="n in whatsits" :key="n.id">{{ n.name }} is {{ nodes[n.id] ? "in" : "not in" }} "nodes"</li>
  </ul>
  <v-network-graph :nodes="nodes" :edges="edges" :configs="configs" />
</template>

and press the add button, you will see an error:

force.ts:119 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'links')
    at watch.deep (force.ts:119:20)
    at callWithErrorHandling (runtime-core.esm-bundler.js:155:22)
    at callWithAsyncErrorHandling (runtime-core.esm-bundler.js:164:21)
    at Array.job (runtime-core.esm-bundler.js:1779:17)
    at flushPreFlushCbs (runtime-core.esm-bundler.js:328:31)
    at updateComponentPreRender (runtime-core.esm-bundler.js:5168:9)
    at ReactiveEffect.componentUpdateFn [as fn] (runtime-core.esm-bundler.js:5080:21)
    at ReactiveEffect.run (reactivity.esm-bundler.js:160:29)
    at updateComponent (runtime-core.esm-bundler.js:4968:26)
    at processComponent (runtime-core.esm-bundler.js:4901:13)

However, if you comment out the customisation (lines 18, 19, 20) it works fine with the defaults.

from v-network-graph.

dash14 avatar dash14 commented on June 15, 2024

Hi @dashavoo,
Thank you for reporting the error.
Oops, the code inside the library assumed that force("edge", ...) is specified....
I have fixed so that it will work without this configuration.
Please use the new version (v0.3.18).

from v-network-graph.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.