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

@verticesandedges/graph-element

v1.2.5

Published

A 3D Graph Visualization Web Component

Readme

graph-element

This is a 3D force directed graph visualization web component written in three.js. It is not complete. It could benefit from the dynamic matching integration mentioned in Veldhuizen (2007), and I am currently working on getting the single level logic ported to gpu shader language. This means I'm learning gpu shader language.

But back to this library. To create the graph-element, you can use either HTML or Javascript:

<link rel="stylesheet" href="graph-element.[hash].css">
<script type="module" src="dist/index.js"></script>
<div class="container">
  <graph-el></graph-el>
</div>

You can also include initial vertex and edge elements.

<style>
  graph-el {
    width: 500px;
    height: 350px;
    border: 1px solid black;
  }
</style>

<!-- include the graph-el web component definition -->
<script type="module" src="dist/index.js"></script>

<!-- graph-element -->
<graph-el>
  <!-- vertices -->
  <vertex-el id="a"></vertex-el>
  <vertex-el id="b"></vertex-el>
  <vertex-el id="c"></vertex-el>
  <vertex-el id="d"></vertex-el>
  
  <!-- edges -->
  <edge-el source="#a" target="#b"></edge-el>
  <edge-el source="#b" target="#c"></edge-el>
  <edge-el source="#c" target="#a"></edge-el>
  <edge-el source="#d" target="#a"></edge-el>
  <edge-el source="#d" target="#b"></edge-el>
  <edge-el source="#d" target="#c"></edge-el>
</graph-el>

Here's some examples:

Usage

To use the library, get an instance of a GraphElement (aka <graph-el>), and call addVertex(), addEdge(sel/vertex, sel/vertex), removeVertex(sel/vertex), and removeEdge(sel/edge), where sel stands for selector, ie id or className or similar.

Vertices

To create a vertex, you call addVertex() from your graph variable.

const graph = document.querySelector('graph-el');
const vertex = graph.addVertex()

This will give you a vertex on a screen. By passing in options, you can change the appearance of the vertex created.

You can specify an object of vertex options with

const vertex = graph.addVertex({
  id: css-selector-valid string,
  color: css color string,
  selectionColor: css color string,
  size: number,
  texture: image path,
  label: string,
  visible: boolean
  selected: boolean
});

// or
vertex.setAttribute('color', 'green');

Or via HTML attributes:

<vertex-el id="ref" color="green" size="3.0"></vertex-el>

Mix and match attributes as you see fit!

Edges

To create an edge, you pass two vertices, or their ids to graph.addEdge():

const graph = document.querySelector('graph-el');
const va = graph.addVertex();
const vb = graph.addVertex();

const edge = graph.addEdge(va, vb);
// or
const edge = graph.addEdge(va.id, vb.id);

Again, you can pass options to addEdge:

const edge = graph.addEdge(va, vb, {
  id: string,
  color: css color string,
  arrow: boolean,
  width: number,
  label: string,
  strength: number,
  visible: number,
  spline: boolean
});

// or 

edge.setAttribute('color', 'black');

or in HTML:

<edge-el source="#a" target=".b" color="green"></edge-el>

Development

I am quite proud of this library already. Although it is still missing some features, I am proud of the direction this is going.

Getting Started

Run

# Do these at least once
git clone [email protected]:verticesandedges/graph-element.git
cd graph-element
npm install
npm run build:all

# Then you can run 
npm run start:test # or:
npm run start:demo

Scripts

There are several scripts defined in package.json:

watch commands

  • watch:lib
  • watch:demo
  • watch:test

build commands

  • build:lib
  • build:demo
  • build:test
  • build

start commands

  • start:demo
  • start:test

You should be safe running

npm run build

which builds the tests, the demo, and the library itself.