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 🙏

© 2024 – Pkg Stats / Ryan Hefner

zim-graphviz

v0.1.2

Published

React component for generalized generation of graphs (e.g. directed or not). Tries to harmonize types according to all zim components via Typescript at compile time.

Downloads

4

Readme

zim-graphviz

Short Description

React component for generalized generation of graphs (e.g. directed or not). Tries to harmonize types according to all zim components via Typescript at compile time.

Files from src/lib are compiled to lib folder on root lvl (which is then published to npm)

Uses create-react-app setup for display demo application

Demos and Examples

Network Graph - KONDE Weißbuch konde-graph on zimlab

take a look at src/demo/index.tsx: via npm run start you may start the dev setup from create-react-app (but there need to be two changes made to the tsconfig.json) react-scripts will print necessary adaptions to console. (change baseUrl + noEmit to true)

Acknowledgement(s)

  • using wonderful react-d3-graph library (https://www.npmjs.com/package/react-d3-graph)
  • d3.js

Quickstart

  • minimal configuration

// example return in React Functional Component
return (
  <ZIMGraphViz.Comp 
    id="demo-id01" 
    // provide data here
    data={{
    nodes: [
      {id: "1", label: "Peter", value: "https://wikipedia.org"},
      {id: "2", label: "Max", value: "https://google.com"},
      {id: "3", label: "Frida", value: "https://google.com"},
      {id: "4", label: "Thomas", value: "https://google.com"}
    ],
    links: [
      {source:"1",target:"2"},    
      {source:"1",target:"3"},    
      {source:"1",target:"4"},    
      {source:"2",target:"4"},    
      {source:"3",target:"1"},
    ]
  }}
    
    // **optional from here **
    // allows to get analysis data like calculated coordinates
    // false by default
    curatorMode={true}   
    // graphConfiguration see advanced section
  />
  )

Advanced

  • provide custom graph configuration according to this official api doc
  <ZIMGraphViz.Comp
    id="demo-id02" 
    data={demoData.small}
    // pro
    graphConfiguration={{
      // example for maybe most important configuration params
      directed:false,
      height: 300,
      width: 300,
      staticGraph: false,    // will stop after first render (needs x and y variables on node lvl)
      initialZoom: .5,
      // ... 
      // Global node config
      nodeHighlightBehavior: true,
      node: {
        color: "blue",
        highlightColor: "lightgreen",
        size: 500,
        // decides which prop of node should be used for rendering the label
        labelProperty: "value",
        fontSize: 12,
        highlightFontSize: 12
      },
      // Global link config
      // linkHighlightBehavior: true,
      link: {
        color: "lightblue",
        labelProperty: "target",
        strokeWidth: 4
      },
      // d3 property to manipualte graph rendering
      d3: {
        gravity: -100,  // force between nodes
        linkLength: 100 // fore between links
        // ...
      }
    }}
  />

Extract calculated data to static graph

  • useful to pre-calculate performance intense operations (like link strenth etc.) and then to statically create the graph.
  • using the curatorMode prop.
    1. if set to true: allows to extract the original data with additional calculation information from the graph
    2. statically save the data and apply to your component via the graphConfiguration prop. (node / link)

Contribute

Useful Resources

  • https://medium.com/@jchiam/publishing-a-typescript-react-component-to-npm-d3cc15b8d0a2
  • https://itnext.io/step-by-step-building-and-publishing-an-npm-typescript-package-44fe7164964c

Create react app and useful stuff

  • https://github.com/wmonk/create-react-app-typescript/blob/master/template/README.md#publishing-components-to-npm

Important Scripts


# locally build publishable lib folder
# this folder will be published by npm publish later on
npm run npm:build

# login to npm before
npm login

# apply new version
npm version x.y.z

# then publish to npmjs 
npm publish