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

@origintrail-official/dkg-graph-viz

v0.0.1-dev.1773614346.8bc4e9c

Published

RDF Knowledge Graph Visualizer — force-directed graph rendering with hexagonal nodes, declarative view configs, RDF-native data loading, and SPARQL-driven views

Readme

@origintrail-official/dkg-graph-viz

RDF Knowledge Graph Visualizer for the OriginTrail Decentralized Knowledge Graph (DKG). Renders knowledge graphs with hexagonal nodes, force-directed layout, native RDF data loading, and declarative view configuration.

Features

Core Visualization

  • RDF native: Load N-Triples, N-Quads, Turtle, or JSON-LD directly
  • Force-directed layout: Physics-based graph layout via d3-force
  • Hexagonal nodes: Distinctive hexagonal rendering with type-based coloring
  • Interactive: Click nodes for details, zoom, pan, drag
  • Focus filtering: Auto-focuses on high-degree nodes for large graphs
  • Reification collapsing: Collapses RDF statement metadata for cleaner views
  • React support: Optional React component wrapper

Declarative View Configuration

  • ViewConfig JSON: Declaratively control focal entities, node types, highlights, tooltips, and sizing from a single JSON file
  • Highlight rules: Mark nodes based on any RDF property (self or linked), with continuous size scaling and optional invert mode
  • Size-by rules: Scale node size by any numeric property using linear or logarithmic scaling
  • Configurable tooltips: Define title properties, subtitle templates with tokens, and custom metric fields
  • Platform icons: Map entities to SVG icons with URL-based fallback matching

Color Palette System

  • Built-in themes: Dark, Midnight, Cyberpunk, Light
  • CSS custom properties: Palettes inject --gv-* variables for consistent theming
  • Custom palettes: Supply your own ColorPalette object or override individual colors

Graph Animations

  • Link particles: Animated particles flowing along edges
  • Drift: Subtle continuous movement
  • Risk pulse: Breathing/pulsating animation on flagged nodes
  • Hover trace: Animated particles on edges connected to the hovered node
  • Fade-in: Smooth opacity transition on load

Data Sources

  • OxigraphSource: In-browser WASM-based SPARQL engine (Oxigraph)
  • RemoteSparqlSource: Connect to any SPARQL endpoint (GraphDB, Fuseki, etc.)
  • SPARQL-driven views: Load and switch graph views via CONSTRUCT queries

Quick Start

pnpm install
pnpm --filter @origintrail-official/dkg-graph-viz demo

Open http://localhost:4321 to see the Moltbook social graph demo.

Usage (Vanilla JS)

import { RdfGraphViz, OxigraphSource } from '@origintrail-official/dkg-graph-viz';

const container = document.getElementById('graph');
const viz = new RdfGraphViz(container, {
  labelMode: 'humanized',
  focus: { maxNodes: 5000 },
});

// Load via SPARQL source
const kg = new OxigraphSource();
await kg.init();
await kg.loadNTriples(ntriplesText);
await viz.loadFromSource(kg, 'CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o }');

// Apply a declarative view config
const viewConfig = await fetch('/views/my-view.json').then(r => r.json());
viz.applyView(viewConfig);

View Config Example

{
  "name": "Social Graph",
  "nodeTypes": {
    "https://schema.org/Person": {
      "label": "Person",
      "color": "#9b59b6",
      "shape": "hexagon",
      "sizeMultiplier": 1.8
    },
    "https://schema.org/SocialMediaPosting": {
      "label": "Post",
      "color": "#3498db",
      "shape": "hexagon",
      "sizeMultiplier": 1.2
    }
  },
  "palette": "midnight",
  "animation": {
    "drift": true,
    "hoverTrace": true,
    "fadeIn": true
  },
  "tooltip": {
    "titleProperties": ["name", "headline"],
    "subtitleTemplate": "{type} · {author} · {date}",
    "fields": [
      { "label": "Score", "property": "score", "format": "number" }
    ]
  }
}

Usage (React)

import { RdfGraph } from '@origintrail-official/dkg-graph-viz/react';

function App() {
  return (
    <RdfGraph
      data={ntriplesString}
      format="ntriples"
      options={{ labelMode: 'humanized' }}
      onNodeClick={(node) => console.log(node)}
    />
  );
}

Supported RDF Formats

| Format | Method | Extension | |--------|--------|-----------| | N-Triples | loadNTriples(text) | .nt | | N-Quads | loadNQuads(text) | .nq | | Turtle | loadTurtle(text) | .ttl | | JSON-LD | loadJsonLd(obj) | .jsonld |

Architecture

src/
├── core/
│   ├── rdf-graph-viz.ts        # Main facade class
│   ├── graph-model.ts          # In-memory graph (nodes, edges, properties)
│   ├── view-config.ts          # Declarative ViewConfig application
│   ├── palette.ts              # Color palette system (4 built-in themes)
│   ├── style-engine.ts         # Node/edge coloring with palette integration
│   ├── hexagon-painter.ts      # 2D hexagonal node renderer
│   ├── renderer.ts             # Canvas2D renderer backend (force-graph)
│   ├── renderer-3d.ts          # WebGL 3D renderer backend (3d-force-graph)
│   ├── renderer-backend.ts     # Renderer interface
│   ├── provenance-resolver.ts  # DKG provenance metadata extraction
│   ├── label-resolver.ts       # URI → human-readable label
│   ├── prefix-manager.ts       # RDF namespace prefix handling
│   ├── focus-filter.ts         # Large-graph node filtering
│   ├── reification-collapser.ts # RDF reification collapsing
│   ├── metadata-extractor.ts   # Metadata predicate extraction
│   ├── events.ts               # Event emitter (node:click, node:hover, etc.)
│   └── types.ts                # TypeScript type definitions
├── data-sources/
│   ├── oxigraph-source.ts      # In-browser WASM SPARQL engine
│   ├── remote-sparql-source.ts # Remote SPARQL endpoint client
│   └── types.ts                # Data source interfaces
├── react/                      # React component wrapper
└── parsers/                    # RDF format parsers

Building

pnpm --filter @origintrail-official/dkg-graph-viz build       # Build for distribution (ESM + CJS + DTS)
pnpm --filter @origintrail-official/dkg-graph-viz dev         # Watch mode
pnpm --filter @origintrail-official/dkg-graph-viz demo        # Start Vite dev server for demos
pnpm --filter @origintrail-official/dkg-graph-viz test        # Run tests

License

MIT