Socket
Book a DemoInstallSign in
Socket

@rentmagic/vis-network

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rentmagic/vis-network

Vue2 wrapper for the Visjs Network library.

1.0.1-alpha.3
latest
Source
npmnpm
Version published
Weekly downloads
2
Maintainers
0
Weekly downloads
 
Created
Source

@vue2vis/network

Vue2 wrapper for the Visjs Network library.

Build Status Software License npm version Issues

Installation

npm install --save @vue2vis/network vis-data moment

or

yarn add @vue2vis/network vis-data moment

Usage

Declare the component

Vue.component("network", vue2vis.Network);

Add the component in the template.

<body>
  <div id="app">
    <network ref="network" :nodes="nodes" :edges="edges" :options="options">
    </network>
  </div>
</body>

Add groups, items and options in your observed data or computed.

new Vue({
  el: "#app",
  data() {
    return {
      nodes: [
        { id: 1, label: "Node 1" },
        { id: 2, label: "Node 2" },
        { id: 3, label: "Node 3" }
      ],
      items: [
        { id: 1, from: 1, to: 3 },
        { id: 2, from: 1, to: 2 }
      ],
      options: {
        nodes: {
          shape: "circle"
        }
      }
    };
  }
});

Additional info can be found on Visjs Network documentation

Here is a basic working demo with item generation: JS Fiddle Basic Demo

You can also create items or group labels as Vue Components: JS Fiddle Item Vue Component Demo

Events

Component Events

By default all Vis events are emitted by your component. You can subscribe to a subset by passing an array in the prop events Visjs event.

<body>
  <div id="app">
    <network
      ref="network"
      :nodes="nodes"
      :edges="edges"
      :options="options"
      :events="['click', 'changed']"
      @click="myClickCallback"
      @stabilized="myStabilizedCallback"
    >
    </network>
  </div>
</body>

Data Events

When you pass an Array of data object, it is converted internally as a DataSet. An event with the DataSet object will be fired at mounted. It's name will be prepend with the prop name (Ex: nodes-mounted, edges-mounted). You could use it to interact with the DataSet.

All the Visjs DataSet event will be prepened the same fashion (nodes-add, nodes-remove, nodes-update). For example, pushing a new object to the nodes prop will fire a nodes-add event with the following payload:

{
  event: 'add',
  properties: {
    nodes: [7],
  },
  senderId: null,
}

Advanced

You can also manage your own data bindings by passing your own DataSet or DataView instead of an Array.

import { DataSet } from "vis-data";

new Vue({
  el: "#app",
  data() {
    return {
      edges: new DataSet([
        { id: 0, from: 1, to: 2 },
      ]),
      nodes: new DataSet([
        {
          id: 0,
          label: "Node 1"
        }
        {
          id: 1,
          label: "Node 2"
        }
      ]),
      options: {
        nodes: {
          shape: "circle"
        }
      }
    };
  }
});

Visjs documentation

Full reference of Item and Group formats, options properties and events:

Change log

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Run demo locally

# Run demo at localhost:8080
yarn install
yarn lerna bootstrap
yarn serve:network

Go to http://localhost:8080/ to see running examples

NOTE: If you make changes to the library you should run yarn prepare again in the root folder. The dev server should detect modification and reload the demo

Security

If you discover any security related issues, please email infocontact.alex@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

FAQs

Package last updated on 12 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.