npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

vue-graph-vis

v0.1.4

Published

A Vue component to render graph on canvas, based on Vis.js network[3~Nibrary.

Readme

Vue Graph Visualizer (Vis)

A Vue component to render graph on canvas, based on Vis.js network.

How to

Perform an npm installation of the package:

npm i vue-graph-vis

The default import is the Vue component, so you can import it in your project with a statement like this:

import VueGraphVis from 'vue-graph-vis';

and use it in you Vue template in this way (supposed you are using webpack):

<template>
    ...
        <GraphDiagram class="canvas" :graph="graph" :options="options" />
    ...
</template>

You could also import some classes, useful to build the diagram such as:

import { DefaultCommmandManager, Node, Edge, Graph, NodeType, Cluster, ClusterType } from 'vue-graph-vis';

The Vue component

The Vue Component props that are mandatory to be bound are:

  • A Graph object (graph)
  • A Options object (options)

An optional prop is 'commandManager'. By default a DummyCommandManager is assigned which doesn't manipulate the graph provided to the component.

The Graph Object

By default a graph contains:

  • nodes ( Node[] )
  • edges ( Edge[] )

For nodes and edges documentation see: http://visjs.org/docs/network/.

IMPORTANT: Do not use nodes groups. A more sophisticated group version has been implemented which uses NodeType.

  • Groups: do not use nodes groups. A more sophisticated group system has been implemented which uses NodeType.
  • HTML Nodes: you can now define a node with inner html, by putting your HTML code inside the _graphCanvas property of the node, as a string
  • Clusters: similarly to groups, a more sophisticated clustering system has been implemented which uses ClusterType.
  • resizable: node are now resizable, but you can decide to make them not resizable, giving this boolean a value of false

Example:

            _graphCanvas:
            {
                nodeType:     'start',
                clusterType : 'logic',
                resizable : false,

                html: `<table style='width: 100%;' border='1' cellspacing='0' cellpadding='5'> 
                            <tr>
                                <td>a</td>
                                <td>b</td>
                            </tr> 
                            <tr>
                                <td>c</td>
                                <td>d</td>
                            </tr> 
                        </table>`
            }

The Options Object

See http://visjs.org/docs/network/.

New options are available under the _graphCanvas property:

  • background: a background can be defined through a URL
  • NodeTypes: see the implementation details below
  • ClusterTypes: see the implementation details below
  • canAddEdges: allows to add edges to the graph, in addition to the initial one (if an appropriate CommandManager is provided)
  • saveNodesPosition: save the new nodes' positions on the model (if an appropriate CommandManager is provided)
  • allowMultiselect: enable or disable the multiple selection of nodes and edges
  • allowResizing: enable or disable the interactive resizing of nodes

Example:

var options = {
    ...
    _graphCanvas:
    {
        canAddEdges     : true,
        allowMultiselect: false,
        allowResizing   : false,
        nodeTypes: [...],
        background: ***random_url***,
        clusterTypes : [...]
    }
}

NodeType(s)

Example:


var nodeType = {
    linkIn: {
        max: 2, //default 0, means no limits
        allowedNodeTypes: ["nodeType1"] // default ["*"], means all nodeTypes allowed
    },
    linkOut: {
        max: 2, //default 0, means no limits
        allowedNodeTypes: ["nodeType1"] // default ["*"], means all nodeTypes allowed
    },
    options: {
        color : {
            background: blue,
            border: black
        }
    }
}

You can also use the Class constructor of the NodeType class, importing the class with:

import { NodeType } from 'vue-graph-vis';

In this case you can code:

var nodeType = new NodeType( 
    { 
        linkIn:  { allowedNodeTypes: [] }, 
        linkOut: { allowedNodeTypes: ["*"], max: 1 },
        options: 
        { 
            color: { background: "#99B898" },  
            shape: "circle",  
            margin: 1, 
            borderWidth: 3 
        }
});

ClusterType(s)

Example:

var x = {
    id: 'main',
    level: 1
}

You can also use the Class constructor of the ClusterType class, importing the class with:

import { ClusterType } from 'vue-graph-vis';

In this case you can code:

var clusterType =  new ClusterType( { id : 'world',  level : 0})

CommandManager

I strongly suggest you to use defaultCommandManager.

If you want to create you should at least implements the standard interface:

export default interface CommandManager
{
    updateNode  (payload : {node: Node; graph: Graph}) : any
    addEdge     (payload : {edge: Edge; graph: Graph}) : any             
}

which requires an updateNode method and an addEdge method.

Contributing

You can clone the GitHub repo from here.

Default commands are:

npm run serve
npm run build
npm run test:unit
npm run test:watch