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

layer-visualization

v0.3.0

Published

A library which renders d3 svg diagrams

Readme

A module for d3 visualization of layered dependencies

Terms

Component: A Component represents some entity which can be somewhere along the axis of low level to high level abstraction.

Layer: A Layer is a group of Components at the same abstraction layer. A group of high level components or a group of low level components. The layer has a type indicator which classifies all the Components in the layer.

Stack: A Stack represents a set of abstraction Layers that need to interface together to produce one part of a multiple part solution.

Solution: A System is a set of stacks that together provide a solution to multiple users.

Components dependencies: In a layer Components may have dependencies on other Components.

InterLayer dependencies : Components across layers may have dependency relationships

Cross stack relationships : Components in stacks can link through to components in equivalent layers in other stacks to establish cross stack services.

Extension: Nodes from the stacks can extend to a common interconnect in order to form a connected graph.

Provisioning: This relates to the action of selecting components from layers either by the user or by the business logic.

alt text

How to use

To create a visualization you need to pass in a solution factory function and provide options

const visualization = vis.createVisualization(solutionFactory,options);

The solution factory function needs to return an array of Stacks.

let modelFactory = function(){
  return [stack1,stack2];
}

Each Stack should contain a stack number, name and array of layers.

var stack1 = {
  stackNumber: 0,
  stackName: "Test",
  layers: [ usersLayer, servicesLayer ],
}

Each Layer should have a name, type and array of Component nodes and transform metadata

var usersLayer = {
    name: "user",
    type: "User",
    data:  [userCat1,user1],
    transform: { name: "userCustomer",cx: 1, cy:1,anchor: "middle", style: "user", fixed: true } };

Component nodes must have an id,name and parent.

var userCat1={ "id": "userCategory", name: "usersCategory", parent: "null"};
var user1 = { "id": "user1", name: "aCustomer", parent: "userCategory"};

Components are managed in Data Nodes that represent the position of the component and additional metadata

var extensionId = "network"
var extensionComponent = { "id": extensionId, name="Extension" };
var extensionData = {
  data: extensionComponent,
  fx: width/2, //fixed x
  fy: height, //fixed y
  fixed: true  //The node is a fixed position
}

Layers can also have a set of dependencies

var servicesLayer ={
  name: "services",
  type: "Service",
  components: [servicecat1,service1 ,service2],
  transform: ...,
  dependencies: [ service1_dependsupon_service2 ]}

Each Dependency describes a Dependency from source Component to target Component.

var service1_dependsupon_service2 = { "source": "service1", "target": "service2", "type": "Dependency" };

Define an extension factory


function extensionFactory(node/*a single node*/,nodeHash/*a map of node id to node*/){
    if(<logic>){
      return extensionData;
    }
  return null;
}

Define an inter layer link factory which returns links between components in different layers.

function interLayerLinkFactory(node1,node2){
  return {
    source: <source component id>,
    target: <target component id>
  }
}

Processing

After a component is selected dependencies from all selected nodes are determined and those components are Provisioned.

Within each Stack the set of Provisioned nodes is then iterated and the inter layer link factory is invoked to provide links between layers.

Finally pairs of provisioned components between stacks and in identical layers are iterated and the cross stack link factory function is invoked to provide links between stacks.

Visualization

Options can be passed when creating the visualization but default to the following

var defaultOptions = {
  domId: "layered-visualization",//TOOD
  width:1200,
  height:800,
  nodesize: 20
}

Layer Transforms

Data Nodes are initially rendered to the UI according to the transform defined in the layer.

The transform cx,cy properties define the center of the layer components in the view. The transform style properties define a css style that can be used to style the components in that layer. The transform fixed property can specify a components doesnt float around the view. The transform anchor property determines the position of the text anchor for the component name.

{
  name: "userCustomer",
  cx: 8*nodesize,
  cy:8*nodesize,
  anchor: "middle",
  style: "serviceUser",
  fixed: true
}