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

@yanqirenshi/d3.deployment

v0.9.1

Published

Deployment diagram renderer (nestable nodes / edges / ports) — dragging a parent moves its whole subtree

Readme

@yanqirenshi/d3.deployment

デプロイメント図(ノード・エッジ・ポート)を SVG で描画する React コンポーネントです。

  • ノードは children で入れ子にできます。宣言サイズより子が大きい場合は親が自動で広がります。
  • ノードはドラッグで移動でき、親を動かすとサブツリーごと追従します。
  • エッジの取り付け位置はポートの角度で指定します(0=真下・時計回り。90=左 / 180=真上 / 270=右)。
  • このライブラリは描画のみを行います。 クリックはコールバックで通知するだけで、 編集 UI は利用側が用意します(ショーケースではインスペクタ @yanqirenshi/colonoscope を繋いでいます)。

インストール

npm install @yanqirenshi/d3.deployment

React 18 / 19 に対応しています(peerDependencies)。

使い方

描画の管理オブジェクト Rectum を作って React コンポーネント D3Deployment に渡し、 data() でデータを流し込みます。

import React from 'react';
import D3Deployment, { Rectum } from '@yanqirenshi/d3.deployment';

export default function Graph({ data }) {
  const [rectum, setRectum] = React.useState(null);

  React.useEffect(() => {
    const r = new Rectum({
      transform: { k: 0.6, x: 120, y: 120 },   // 初期のズーム / パン
      callbacks: {
        // 描画は行わず通知のみ。core は入力データそのもの
        node: { click: (core, node) => {} },
        edge: { click: (core, edge) => {} },
      },
    });
    r.data(data);
    setRectum(r);
  }, [data]);

  if (!rectum) return null;

  return (
    <div style={{ width: '100%', height: '100%' }}>
      <D3Deployment rectum={rectum} />
    </div>
  );
}

描画後にポートの角度を変える

rectum.setEdgePorts(edge_id, { from: 0, to: 180 });   // 省略した側は変更しない

入力データ側(_core)の角度を書き換えてから再フィットするので、 以後の再描画やコンポーネントの remount でも維持されます。

入力データ

{ nodes, edges } の連想配列です。

{
  nodes: [
    {
      type: 'NODE', id: 1,
      label: { text: 'NODE 01', position: { x: 20, y: 20 }, font: { size: 16, color: '#333333' } },
      description: 'ホバー時のツールチップに出る(任意)',
      link: { url: 'https://example.com/' },   // 任意。ボックス左下に表示
      padding: 40,                             // 任意。数値・全辺共通
      size: { w: 150, h: 150 }, position: { x: 0, y: 0 },
      children: [ /* 入れ子のノード */ ],
    },
  ],
  edges: [
    { id: 100, from: { id: 1, position: 0 }, to: { id: 2, position: 180 } },
  ],
}

edges[].from.id / to.id は nodes[].id を参照します(入れ子の内側のノードも指定できます)。

フィールドの詳細はショーケースの d3.deployment のページ(「データ」タブ)を参照してください。 サンプルの実データは showcase/src/demos/data/deployment-sample.js です。

開発

npm run transpile -w @yanqirenshi/d3.deployment   # src -> dist(dist はコミット対象)
npm test -w @yanqirenshi/d3.deployment            # jest

Author

Satoshi Iwasaki ([email protected])

Copyright

Copyright (c) 2018-2026 Satoshi Iwasaki ([email protected])

License

Licensed under the MIT License.