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 🙏

© 2026 – Pkg Stats / Ryan Hefner

vue-network-d3

v0.1.2

Published

D3 Force-Directed Graph as Vue Component.

Readme

vue-network-d3

D3 Force-Directed Graph as Vue Component.

Demo

Install

npm install vue-network-d3 --save

Quick Start

<template>
  <div id="app">
    <network :nodeList="nodes" :linkList="links"></network>
  </div>
</template>

<script>
import Network from "vue-network-d3";

export default {
  name: "app",
  components: {
    Network
  },
  data() {
    return {
      nodes: [
      	{"id": "Myriel", "group": 1},
      	{"id": "Napoleon", "group": 1},
        {"id": "Labarre", "group": 2},
        {"id": "Valjean", "group": 2}
      ],
      links: [
        {"source": "Napoleon", "target": "Myriel", "value": 1},
        {"source": "Valjean", "target": "Labarre", "value": 1},
        {"source": "Napoleon", "target": "Valjean", "value": 2},
      ]
    };
  },
};
</script>

<style>
body {
  margin: 0;
}
</style>

Props

Overview

props: {
    nodeList: Array,
    linkList: Array,
    // node related:
    nodeSize: {
      type: Number,
      default: 14
    },
    nodeTextKey: {
      type: String,
      default: "id"
    },
    nodeTypeKey: {
      type: String,
      default: "group"
    },
    nodeTextFontSize: {
      type: Number,
      default: 14
    },
    bodyStrength: {
      type: Number,
      default: -150
    },
    // link related:
    linkWidth: {
      type: Number,
      default: 2
    },
    showLinkText: {
      type: Boolean,
      default: false
    },
    linkTextKey: {
      type: String,
      default: "value"
    },
    linkTypeKey: {
      type: String,
      default: "type"
    },
    linkTextFrontSize: {
      type: Number,
      default: 10
    },
    linkDistance: {
      type: Number,
      default: 50
    },
    // svg raleted:
    svgSize: {
      type: Object,
      default: () => {
        return {
          width: window.innerWidth,
          height: window.innerHeight
        };
      }
    },
    svgTheme: {
      type: String,
      default: "light" // dark or light
    },
    // others:
    highlightNodes: {
      type: Array,
      default: () => {
        return [];
      }
    }
}

Detailed Design

「:star:」​ means necessary

  • :star: ​nodeList: Array of Node Object which has

    • :star: id: Number or String. Node id and also node name (can be changed by nodeTextKey)
    • group: Number or String. like node type (can be changed by nodeTypeKey)
  • :star: linkList: Array of Link Object which has

    • :star: source: Number or String. Id of source node.
    • :star: target: Number or String. Id of target node.
    • value: Number or String. Link name (can be changed by linkTextKey)
  • nodeSize: Number.

  • nodeTextKey: String. Key of node text/name. The default value is 'id', you need to set it to 'name' if your node object is like:

    {
      id: 1010,
      name: 'Myriel'
    }
  • nodeTypeKey: String. Key of node type. The default value is 'group', you need to set it to 'type' if your node object is like:

    {
      id: 'Myriel',
      type: 1
    }
  • nodeTextFontSize: Number.

  • linkWidth: Number.

  • showLinkText: Boolean. Show link text or not. Suggest keeping it false, link text will show when you hover on the link.

  • linkTextKey: String. Key of link text/name. The default value is 'value', you need to set it to 'name' If your link object is like:

    {
      source: 'Napoleon',
      target: "Myriel", 
      name: 'friend'
    }
  • linkTypeKey: String. Key of link type. The default value is 'type'.

  • linkTextFrontSize: Number.

  • linkDistance: Number.

  • svgSize: Object which has

    • width: Number.
    • height: Number
  • svgTheme: String. 'light' or 'dark', 'light' is default.

  • bodyStrength: Number. A positive value causes nodes to attract each other, similar to gravity, while a negative value causes nodes to repel each other, similar to electrostatic charge.

  • highlightNodes: Array of node id. Stroke of nodes turn yellow.

Events

  • clickNode: emits (event, node-object)
  • clickLink: emits (event, link-object)
  • hoverNode: emits (event, node-object)
  • hoverLink: emits (event, link-object)

Classes

  • .element: all nodes and links
  • .node: all nodes
  • .link: all links
  • .[type]: nodes where node[nodeTypeKey] == type, links where link[linkTypeKey] == type
  • .selected: selected nodes (clicked node with its first layer nodes)

Reference

Repo

TODO

  • [x] Docs: props and events
  • [ ] Learn Vue-CLI more
  • [x] Fix: node's style when hover
  • [ ] CI