0.3.17 • Published 11 months ago

react-knowledge-graph v0.3.17

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

React-Knowledge-Graph

English | 简体中文

CodeFactor GitHub Release Date npm package NPM downloads GitHub license code style: prettier

Introduction

a react component that can help you create a dynamic knowledge-graph built with Next.js.

Features

  • Customize node size/color/text color/text size
  • Canvas drag and drop support
  • Support asynchronous data acquisition / dynamic exploration to generate graphs
  • Support for highlighting nodes and their associated edges when Hovering nodes
  • Customize properties by node type
  • Option to hide edges when Hover edge is supported
  • Hide explored nodes and edges when explored nodes are clicked
  • Reset Canvas
  • Fullscreen
  • Right click to center the current entity
  • Support server-side rendering
  • Download the chart as a multi-format image (jpg, jpeg, png, bmp)
  • Support drag and drop nodes
  • Right-click entity menu adds only the current node i.e. its children/relationships
  • Right-click menu display all nodes
  • Dynamic configuration
  • Configuration flying line effect
  • Click the highlights of the same type of node highlight
  • Node Menu
  • display help memu
    • Display the current node information button: You can judge whether you need it according to the needs of your own project, such as: knowledge card function
    • Show the increase node to the physical button: you can determine whether it is required according to the needs of your own project, for example: the current node is added to the knowledge application
  • two way to optimize dragging performance: use react or use dom
  • and so on

Accepted data structures

Nodes

type NodeProps = {
  id: string;
  name: string; // 节点名称
  type: string; // 节点类型
  hasMore: boolean; // 是否有子节点
  direction: "root" | "inside" | "outside";
};

Edges

type EdgeProps = {
  id: string; // 边id
  fromId: string;
  toId: string;
  description: string;
};

Explore Function

Need to accept an asynchronous function, this library will return the parameter id - Node Id, node - current node Need to return inside in edge node, outside out edge node, edge array of edges

type explore = (id: React.Key) => Promise<{
  inside: Node.NodeProps[];
  outside: Node.NodeProps[];
  edge: Edge.EdgeProps[];
}>;

install

npm install react-knowledge-graph
# or
yarn add react-knowledge-graph

Usage

import style files in the top file:

import "react-knowledge-graph/KnowledgeGraph/index.css";

Next:

<KnowledgeGraph
  explore={explore}
  basicDistence={width}
  position={{ x: 100, y: 100 }}
  node={{
    id: "node-0",
    type: "根节点",
    hasMore: true,
    direction: "root",
    name: "根节点",
  }}
  onExploreEnd={() => {
    message.info("已经到尾节点了!");
  }}
  edgeConfig={{
    hoveredColor: "#e27272",
    stroke: "#DEDEDE",
    strokeWidth: 1,
  }}
  typeConfig={{
    根节点: {
      radius: 20,
      fill: "#747ba6",
      hoverStyle: {
        fill: "#3949a3",
      },
    },
    model: {
      radius: 15,
      fill: "#b4e5a2",
      typeSize: 8,
      nameSize: 8,
      hoverStyle: {
        fill: "#6be73e",
      },
    },
    data: {
      radius: 15,
      fill: "#ea52ea",
      typeSize: 8,
      nameSize: 8,
      hoverStyle: {
        fill: "#e5a2e5",
      },
    },
    test: {
      radius: 13,
      fill: "#89c4fb",
      typeSize: 8,
      nameSize: 8,
      hoverStyle: {
        fill: "#2f8fe8",
      },
    },
  }}
/>

Demo

click to show the Demo

0.3.17

11 months ago

0.3.16

11 months ago

0.3.15

11 months ago

0.3.14

1 year ago

0.3.13

1 year ago

0.3.9

2 years ago

0.3.12

2 years ago

0.3.11

2 years ago

0.3.10

2 years ago

0.3.8-fix5

2 years ago

0.3.8-fix4

2 years ago

0.3.8-fix3

3 years ago

0.3.8-fix2

3 years ago

0.3.8-fix1

3 years ago

0.3.8

3 years ago

0.3.7

3 years ago

0.3.6

3 years ago

0.3.5

3 years ago

0.3.4

3 years ago

0.3.3

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.41

3 years ago

0.1.40

3 years ago

0.1.39

3 years ago

0.1.38

3 years ago

0.1.37

3 years ago

0.1.36

3 years ago

0.1.35

3 years ago

0.1.34

3 years ago

0.1.33

3 years ago

0.1.32

3 years ago

0.1.31

3 years ago

0.1.30

3 years ago

0.1.29

3 years ago

0.1.28

3 years ago

0.1.27

3 years ago

0.1.26

3 years ago

0.1.25

3 years ago

0.1.24

3 years ago

0.1.22

3 years ago

0.1.21

3 years ago

0.1.20

3 years ago

0.1.19

3 years ago

0.1.18

3 years ago

0.1.17

3 years ago

0.1.16

3 years ago

0.1.15

3 years ago

0.1.14

3 years ago

0.1.13

3 years ago

0.1.12

3 years ago

0.1.11

3 years ago

0.1.10

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago