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

translator-graph-view

v0.1.0

Published

React Typescript library for displaying knowledge graphs using ReactFlow and ELKjs.

Readme

translator-graph-view

A React TypeScript component for interactive knowledge graph visualization, designed for use with the NIH's Biomedical Data Translator. Built on ReactFlow and ELKjs.

Renders Biolink Model knowledge graphs with automatic layout, type-based color coding, and interactive selection.

Features

  • Interactive graph visualization with pan, zoom, and selection
  • Four automatic layout algorithms: hierarchical, force-directed, and grid
  • Nodes color-coded by Biolink type
  • Controlled and uncontrolled selection modes
  • MiniMap and zoom controls
  • Full TypeScript type definitions
  • ESM and CommonJS support

Installation

npm install translator-graph-view

React 18+ is required as a peer dependency.

Usage

import { GraphView } from 'translator-graph-view';
import 'translator-graph-view/styles.css';

const data = {
  nodes: {
    'n1': { id: 'n1', names: ['Aspirin'], types: ['biolink:Drug'] },
    'n2': { id: 'n2', names: ['Headache'], types: ['biolink:Disease'] },
  },
  edges: {
    'e1': { id: 'e1', subject: 'n1', object: 'n2', predicate: 'biolink:treats' },
  },
};

function App() {
  return (
    <div style={{ width: '100%', height: '600px' }}>
      <GraphView
        data={data}
        layout="hierarchical"
        onNodeClick={(node) => console.log('Clicked:', node)}
        onSelectionChange={(selection) => console.log('Selected:', selection)}
      />
    </div>
  );
}

The GraphView container must have a defined width and height.

API

<GraphView />

| Prop | Type | Default | Description | |------|------|---------|-------------| | data | GraphData | required | Graph nodes and edges | | layout | LayoutType | 'hierarchical' | Layout algorithm | | onSelectionChange | (selection: Selection) => void | - | Fires when selection changes | | onNodeClick | (node: GraphNode) => void | - | Fires when a node is clicked | | onEdgeClick | (edge: GraphEdge) => void | - | Fires when an edge is clicked | | selectedIds | string[] | - | Controlled selection by node/edge ID | | className | string | - | Additional CSS class for the container |

Layout types

  • 'hierarchical' - Layered top-to-bottom (default)
  • 'hierarchicalLR' - Layered left-to-right
  • 'force' - Force-directed
  • 'grid' - Box/grid

Data format

interface GraphData {
  nodes: Record<string, GraphNode>;
  edges: Record<string, GraphEdge>;
}

interface GraphNode {
  id: string;
  names: string[];
  types: string[];       // e.g. ['biolink:Drug']
  curies?: string[];
}

interface GraphEdge {
  id: string;
  subject: string;       // source node ID
  object: string;        // target node ID
  predicate: string;     // e.g. 'biolink:treats'
}

Hooks

  • useGraphLayout({ nodes, edges, layout }) - Computes ELK layout positions for ReactFlow nodes/edges
  • useSelection({ data, onSelectionChange }) - Manages node/edge selection state

Utilities

  • transformNodesToFlow(data) / transformEdgesToFlow(data) - Convert GraphData to ReactFlow format
  • getColorForType(type) - Get a consistent color for a Biolink type string
  • simplifyTypeName(type) - Extract a readable name from a Biolink URI
  • getNodesById(data, ids) / getEdgesById(data, ids) - Look up nodes/edges by ID

Development

npm install
npm run dev        # Start dev server with example app
npm run build      # Build the library
npm run typecheck  # Type-check without emitting

License

MIT