Giter Club home page Giter Club logo

Comments (2)

happylilem avatar happylilem commented on June 15, 2024 1

It works, thank you very much! :)

from v-network-graph.

dash14 avatar dash14 commented on June 15, 2024

Hi @happylilem,

Thanks for taking a look!
In v-network-graph, as long as the format of the object is the same as the type declaration, you can import and specify the JSON file directly.
Here is a snippet:

App.vue

<script setup lang="ts">
import data from "./test-data.json";
</script>

<template>
  <div class="graph">
    <v-network-graph
      :nodes="data.nodes"
      :edges="data.edges"
      :layouts="data.layouts"
      :configs="data.configs"
    />
  </div>
</template>

<style>
.graph {
  border: 1px solid #888;
  width: 600px;
  height: 400px;
  margin: 0 auto;
}
</style>

test-data.json

{
  "nodes": {
    "node1": { "name": "Node 1" },
    "node2": { "name": "Node 2" },
    "node3": { "name": "Node 3" },
    "node4": { "name": "Node 4" }
  },
  "edges": {
    "edge1": { "source": "node1", "target": "node2" },
    "edge2": { "source": "node2", "target": "node3" },
    "edge3": { "source": "node3", "target": "node4" }
  },
  "layouts": {
    "nodes": {
      "node1": { "x": 0, "y": 0 },
      "node2": { "x": 70, "y": 70 },
      "node3": { "x": 140, "y": 0 },
      "node4": { "x": 210, "y": 70 }
    }
  },
  "configs": {
    "node": {
      "normal": {
        "radius": 20
      }
    }
  }
}

I hope this will help.
Kind Regards,

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.