Graphin

A React toolkit for graph visualization based on G6

README

Graphin


A React toolkit for graph analysis based on G6
Version NPM downloads
Latest commit

English | [简体中文](./README.zh-CN.md)

🌾 New Products!


2022.06.06, this day coincides with the 4th anniversary of the open source of G6, which is also the traditional Chinese solar term: "Grain in Ear", GraphInsight, a new product in the direction of graph analysis. Users can complete the visualization, exploration and analysis tasks of relational data online without code development. You can also export the SDK with one click and integrate it into the business system to help developers improve R&D efficiency.

The SDK exported by GraphInsight is encapsulated based on Graphin. If you want to understand the capabilities of Graphin, you can take a look at the product GraphInsight

✨ Features


🎨 Good-looking elements, standardized style configuration


Graphin standardizes the visual mapping of graph elements. A Graphin's built-in node contains 5 parts: keyshape, label, halo, icon, and badges, each part can be driven by data. The built-in edges include three parts: keyshape, label, and halo. There are also corresponding style configurations for commonly used features, such as label backgrounds, self-loops, polygons, and dashed lines, etc. Try it online

node-style
edge-style

📦 Automatic layout, easy to handle complex scenarios


Graphin has 10 built-in network graph layouts and 4 tree graph layouts to meet your needs of layout for different data types and different analysis scenarios. For features in complex business scenarios, such as layout switching, dynamic layouts, sub-graph layouts, etc., can be easily realized through data-driven layout. Try it online

node-expand
layout-switch

📝 Thoughtful interactions, easy to customize


Graphin provides 13 interactive components, including canvas zooming, panning, brush selection, lasso select , automatic resize, and also element dragging, selection, hovering, highlighting, expanding and collapsing, etc., to meet your interactive needs for different analysis scenarios Try it online

behaviors

🚀 Rich components, derived from precipitation of business development


Currently Graphin provides 7 analysis components: ContextMenu, Tooltip, MiniMap, Toolbar, FishEye, Hull, and Legend. 17+ analysis components will be provided in the future. Try it online
components

⚙️ Comfortable development experience, in line with React users' cognition


typescript

🖥 Browser support


- Graphin icons use Proxy, the font icon may not be displayed correctly on some browsers that do not support Proxy syntax
- The Graphin rendering engine of Graphin is G6, which relies on the browser API and does not support SSR

[[[[
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
IE11,lastlastlast

📦 Installation


If you are using React, then you can use Graphin as a normal React component.

It uses yarn to install dependencies in this article, while npm is also fine. The following commands install Graphin's core components @antv/graphin and analysis components @antv/graphin-components, and Graphin's official icon library @antv/graphin-icons

  1. ``` sh
  2. yarn add @antv/graphin@latest --save
  3. yarn add @antv/graphin-components@latest --save
  4. yarn add @antv/graphin-icons --save
  5. ```

🔨 Usage


Use Graphin Core Component


  1. ```tsx | pure
  2. import React from 'react';
  3. import Graphin from '@antv/graphin';
  4. // mock data
  5. const data = Utils.mock(10).circle().graphin();
  6. export default () => {
  7.   return <Graphin data={data} />;
  8. };
  9. ```

Use Graphin Analysis Components


  1. ```tsx | pure
  2. import React from 'react';
  3. import Graphin from '@antv/graphin';
  4. import { MiniMap } from '@antv/graphin-components';
  5. // mock data
  6. const data = Utils.mock(10).circle().graphin();
  7. export default () => {
  8.   return (
  9.     <Graphin data={data}>
  10.       <MiniMap />
  11.     </Graphin>
  12.   );
  13. };
  14. ```

Use Graphin font icon


  1. ```tsx | pure
  2. import React from 'react';
  3. import Graphin from '@antv/graphin';
  4. import { MiniMap } from '@antv/graphin-components';
  5. // Import icon resource files
  6. import iconLoader from '@antv/graphin-icons';
  7. import '@antv/graphin-icons/dist/index.css';
  8. // mock data
  9. const data = Utils.mock(10).circle().graphin();
  10. // Register in Graphin
  11. const { fontFamily, glyphs } = iconLoader();
  12. const icons = Graphin.registerFontFamily(iconLoader);
  13. // Use icons
  14. data.nodes.forEach(node => {
  15.   node.style = {
  16.     icon: {
  17.       type: 'font', // Specify the icon to be Font type
  18.       fontFamily: fontFamily, // Specify FontFamily
  19.       value: icons.home, // Specify the value of the icon
  20.     },
  21.   };
  22. });
  23. export default () => {
  24.   return (
  25.     <Graphin data={data}>
  26.       <MiniMap />
  27.     </Graphin>
  28.   );
  29. };
  30. ```

👨‍💻 Upgrade Guide


If you are a user from Graphin1.x, this Upgrade Guide may help you. If you encounter upgrade problems, you can go to github issue section, and feel free to create issues if it's not already there.

⌨️ Development Guide


If you want to run Graphin locally, you may wish to read this Contribution Guide. We hope more contributors can join our team to make Graphin better together.

More Info



DingTalk


You can scan the QR code to join graphin's group chat

DingTalk
  1. ```