New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

react-directed-graph-visualizer

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-directed-graph-visualizer

A React component for interactive, customizable, and theme-friendly directed graph visualization based on D3.js. Supports node focus, keyboard navigation.

Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
8
-20%
Maintainers
1
Weekly downloads
 
Created
Source

react-directed-graph-visualizer

NPM version NPM downloads install size

Test CI status Deploy CI Coverage

contributors forks stargazers issues

docs by dumi Build With father

简介

基于 D3.js 的 React 有向图可视化组件,支持节点高亮、键盘导航、主题自定义,适用于交互式数据可视化场景。

功能特性

  • 支持节点/边高亮、出入边模式
  • 键盘 Shift/Control 辅助高亮出入边
  • 支持自定义主题和样式
  • 支持节点拖拽、缩放、平移
  • 适合大规模有向图的交互分析

快速上手

安装

推荐使用 pnpm 安装

pnpm i react-directed-graph-visualizer -S

使用示例

import { DirectedGraphVisualizer } from 'react-directed-graph-visualizer';

const nodes = [
  { id: '1', label: '节点1' },
  { id: '2', label: '节点2' },
];
const edges = [{ source: '1', target: '2' }];

export default () => (
  <DirectedGraphVisualizer
    nodes={nodes}
    edges={edges}
    width={800}
    height={600}
    onSelectNode={(id) => console.log('选中节点', id)}
  />
);

API

属性说明类型默认值版本
nodes节点数据Node[]必填-
edges边数据Edge[]必填-
selectedNodeId当前高亮节点 idstring--
defaultSelectedNodeId默认高亮节点 idstring--
onSelectNode节点点击回调(id: string) => void--
width画布宽度number800-
height画布高度number600-
filterOrphan过滤孤立节点booleanfalse1.1.0
graphSettings主题与样式配置GraphSettings见下表-

GraphSettings 可配置项

属性说明类型默认值
bg背景色stringwhite
focusColor选中节点色stringorange
nodeColor普通节点色stringmediumseagreen
linkColor普通边色stringslategray
grayColor非高亮色stringlightgray
hoverColor悬浮高亮色stringcrimson
fontSize字体大小number16
hoverFontSize悬浮字体大小number24
graphOutColor出边高亮色stringroyalblue
graphInColor入边高亮色stringgoldenrod

迭代记录

详情:CHANGELOG

License

Copyright © 2025 - present Wxh16144.
This project is MIT licensed.

Keywords

d3

FAQs

Package last updated on 19 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts