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.map.documents

v0.1.2

Published

Document map renderer — places documents as icon + label at given coordinates

Readme

@yanqirenshi/d3.map.documents

ドキュメントをアイコン + ラベルで地図状に配置して SVG で描画する React コンポーネントです。

まだ簡易な実装です(v0.0.1 相当の機能範囲)。 入力はフラットな配列で、各ドキュメントを座標・アイコン・ラベルで表します。 入れ子や結線はありません。

インストール

npm install @yanqirenshi/d3.map.documents

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

使い方

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

import React from 'react';
import D3MapDocuments, { Rectum } from '@yanqirenshi/d3.map.documents';

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

  React.useEffect(() => {
    setRectum(new Rectum({ transform: { k: 0.8, x: 150, y: 120 } }));   // 初期のズーム / パン
  }, []);

  React.useEffect(() => {
    if (rectum) rectum.data(data);
  }, [rectum, data]);

  if (!rectum) return null;

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

入力データ

連想配列ではなく、ドキュメントの配列をそのまま渡します。

[
  {
    id: 1,
    url: 'https://example.com/doc-a',
    position: { x: 0, y: 0 },
    icon: { type: 'document', url: '<画像 URL または data URI>', size: { w: 40, h: 40 } },
    label: { text: 'Document A' },
    font: { size: '40px' },
  },
]

ラベルは url へのリンクになります(アイコンの右横に置かれます)。

入力の正規化は行いません。 ペインタが d.icon.size / d.position / d.label.text / d.font.size を直接読むため、icon / position / label / font は省略できません (省略すると描画時に例外になります)。

フィールドの詳細はショーケースの d3.map.documents のページ(「データ」タブ)を参照してください。 サンプルの実データは showcase/src/demos/data/mapdocuments-sample.js です (アイコンは外部 URL に依存しないインライン SVG を data URI で渡しています)。

開発

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

Author

Satoshi Iwasaki ([email protected])

Copyright

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

License

Licensed under the MIT License.