• Stars
    star
    540
  • Rank 79,016 (Top 2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 2 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

React component for building interactive diagrams.

XFlow: Professional graph editing application-level solution

English | 简体中文

npm package npm downloads Percentage of issues still open

What is XFlow?

XFlow is a graph editing application-level solution for users of the React technology stack based on the X6 graph editing engine under AntV. It aims to make the development of complex graph editing applications simple and efficient. XFlow originated from the data intelligence team of the Ant Experience Technology Department. It has been deeply polished and verified in the Ant Big Data Department and artificial intelligence middle-end business scenarios. It is trustworthy!

Features

  • 🌱   Extremely easy to customize: Supports developing node/wire styles using React components.
  • 🚀   Out of the box: 1 quick start + 3 solutions built-in, built-in several React interactive components, such as minimap, snap line, right-click menu, etc.
  • 💯   Available for production: It comes from the data intelligence team of the Ant Experience Technology Department, and is deeply polished and verified in the Ant Big Data Department and AI middle-end business scenarios.
  • 🧲   Everything is extensible: Built-in unified extension mode, you can expand the graph interaction according to your own business needs, and all components are extensible.

🔨 Applications

Simple example

Flowchart Solutions

DAG Solution

ER Diagram Solutions

Installation Instructions

Using npm or yarn

#npm
$ npm install @antv/xflow --save

#yarn
$ yarn add @antv/xflow

Using CDN

Using a script tag, you can use either of the following two CDN's to load XFlow library; these CDN's default to returning the latest version of XFlow

<script src="https://unpkg.com/@antv/xflow/dist/index.umd.js"></script>

For production environments, we recommend using an explicit version number to avoid unpredictable damage caused by new version upgrades:

Getting Started Example

Step1: Create a worksapce

First, we need to build an XFlow workspace, in which the XFlowCanvas canvas component, CanvasScaleToolbar toolbar, CanvasMiniMap minimap, CanvasSnapline alignment line and other interactive components are all content in the XFlow workspace. It is important to emphasize that in XFlow, everything is a React component

import { XFlow, XFlowCanvas } from '@antv/xflow'
import { CanvasScaleToolbar, CanvasMiniMap, CanvasSnapline } from '@antv/xflow-extension'
import { useGraphConfig } from './config-graph'

return (
  <XFlow
    className="xflow-uer-container"
    graphData={graphData}
    graphLayout={{
      layoutType: 'dagre',
      layoutOptions: {
        type: 'dagre',
        rankdir: 'TB',
        nodesep: 60,
        ranksep: 40,
      }
    }}
    onLoad={onLoad}
    isAutoCenter={true}
  >
    <XFlowCanvas config={useGraphConfig()}>
      <CanvasScaleToolbar />
      <CanvasMiniMap minimapOptions={{ width: 200, height: 120 }} />
      <CanvasSnapline color="#1890ff" />
    </XFlowCanvas>
  </XFlow>
)

Step2 设置相关配置

Then, we need to set the canvas global configuration item graphConfig, which determines how the content on the canvas is rendered. For example, whether the canvas needs a grid, the zoom level of the canvas, whether the canvas supports scroll wheel zooming, etc., and what type of React nodes/connections need to be rendered on the canvas.

import { createGraphConfig } from '@antv/xflow'
import Node1 from './react-node/node1'
import Edge1 from './react-edge/edge1'

export const useGraphConfig = createGraphConfig(config => {
  /** Setting the canvas configuration item will override the XFlow default canvas configuration item */
  config.setX6Config({
    grid: true,
    scaling: { min: 0.2, max: 3 },
    mousewheel: { enabled: true, zoomAtMousePosition: true },
  })

  /** Set the React node that the canvas needs to render, and the React content on the connection */
  config.setNodeRender('NODE1', props => <Node1 {...props} />)
  config.setEdgeRender('EDGE1', props => <Edge1 {...props} />)
})

Step3 画布渲染等逻辑操作

设置相关配置后, 我们就可以在 onLoad 方法里进行一些必要的业务逻辑操作,比如从服务端获取数据、执行布局算法、渲染画布内容、监听画布相关事件等。

/** Callback after XFlow initialization is complete*/
const onLoad: IAppLoad = async app => {
  /** Here we assume that the data has been fetched from the server */
  const nodes: NsGraph.INodeConfig[] = [
    { id: 'root1', width: 150, height: 40, renderKey: 'NODE1', info: { text: 'root1' } },
    { id: 'down1', width: 150, height: 40, renderKey: 'NODE2', info: { text: 'down1' } },
    { id: 'down2', width: 150, height: 40, renderKey: 'NODE2', info: { text: 'down2' } },
    { id: 'down3', width: 150, height: 40, renderKey: 'NODE2', info: { text: 'down3' } },
  ]
  const edges: NsGraph.IEdgeConfig[] = [
    {
      id: 'root1-down1',
      source: 'root1',
      target: 'down1',
      renderKey: 'EDGE1',
      info: { line: 'root1-down1' },
    },
    {
      id: 'root1-down2',
      source: 'root1',
      target: 'down2',
      renderKey: 'EDGE2',
      info: { line: 'root1-down2' },
    },
    {
      id: 'root1-down3',
      source: 'root1',
      target: 'down3',
      label: '1:N(纯文本)',
      info: { line: 'root1-down3' },
    },
  ]
  const graphData = { nodes, edges }
  setGraphData(graphData)

  /** Listen to canvas events */
  const graph = await app.getGraphInstance()
  graph.on('node:click', ({ e, x, y, node, view }) => {
    const nodeData: NsGraph.INodeConfig = node.getData()
    message.success(`${nodeData.id}节点被点击了`)
  })
  graph.on('edge:click', ({ e, x, y, edge, view }) => {
    edge.toFront()
    const edgeData: NsGraph.IEdgeConfig = edge.getData()
    message.success(`${edgeData.id}连线被点击了`)
  })
}

At this point, a simple graphics application has a prototype. But the charm of XFlow is much more than that! If your application also needs various interactive components, XFlow has built-in several interactive components for you, such as CanvasScaleToolbar, CanvasMinimap minimap, CanvasSnapline snap line used above.

In addition, the real power of XFlow lies in:

  • The linkage mechanism between canvas components and interactive components.
  • The extension mechanism provided by XFlow allows customization of interactive components required by any business. You can learn more about it in a later tutorial.

Working with documentation

XFlow usage documentation

How to communicate

If you encounter problems during use, you can go through issues to see if there are any similar bugs or suggestions. Welcome to issues for communication, or you can use DingTalk to scan the QR code below to join* *XFlow chat group**.

It should be noted that when asking questions, please add the reproduction code of CodeSandbox, which is convenient for quickly locating and solving problems.

X6/XFlow diagram visualization communication group 1

How to Develop

We use pnpm to manage the project, the directory structure is as follows:

├── packages
│   ├── xflow-docs            # XFlow 使用文档, 包含 1个快速开始 + 3个解决方案
│   ├── xflow                 # 所有 XFlow 相关的引用都从 xflow 库导出
│   ├── xflow-core            # XFlow 对于 X6 画布的封装 graphProvider, 提供若干内置命令Command, 提供全局ModelService等
│   ├── xflow-extension       # XFlow 内置的若干交互组件, 包括小地图、对齐线、右键菜单等
│   └── xflow-hook            # XFlow 内置的 hook 机制, 允许自定义若干默认行为
  1. Before starting you need to install the necessary global dependencies and initialization:
# Install pnpm globally
$ npm install pnpm -g

# Install project dependencies and initialize the build
$ pnpm install

  1. start dev server

Create a new terminal to monitor the file changes of xflow-core, and execute the next command after waiting for the watch service to start successfully.

yarn run dev:core

Create a new terminal to monitor the file changes of xflow-extension, and execute the next command after waiting for the watch service to start successfully.

yarn run dev:ext

Create a new terminal to monitor the file changes of xflow, and execute the next command after waiting for the watch service to start successfully.

yarn run dev:main
  1. Start the documentation website, debug the code according to the example
yarn run dev:docs

How to contribute

If you encounter problems during use, you can go through issues to see if there are any similar bugs or suggestions.

To submit code, please follow our Contribution Guidelines. We will collect contributors' Github avatars to the list of contributors below.

Contributors

More Repositories

1

G2

📊 The concise and progressive visualization grammar.
TypeScript
11,919
star
2

G6

♾ A Graph Visualization Framework in JavaScript
TypeScript
10,572
star
3

F2

📱📈An elegant, interactive and flexible charting library for mobile.
JavaScript
7,847
star
4

X6

🚀 JavaScript diagramming library that uses SVG and HTML for rendering.
TypeScript
5,333
star
5

L7

🌎 Large-scale WebGL-powered Geospatial Data Visualization analysis engine
TypeScript
3,403
star
6

G2Plot

🍡 An interactive and responsive charting library.
TypeScript
2,501
star
7

S2

⚡️ A practical visualization library for tabular analysis.
TypeScript
1,396
star
8

AVA

🤖 A framework for automated visual analytics.
TypeScript
1,306
star
9

wx-f2

F2 的微信小程序
JavaScript
1,267
star
10

G

💥 A flexible rendering engine for visualization.
TypeScript
988
star
11

Graphin

A React toolkit for graph visualization based on G6
TypeScript
973
star
12

G6VP

G6VP is an online visual analysis tool for graphs and a low-code platform for building graph applications.
TypeScript
710
star
13

g6-editor

JavaScript
529
star
14

antvis.github.io

🔜 AntV 新站点!
TypeScript
377
star
15

g2-react

This repo is being deprecated, check Ant Design Charts https://github.com/ant-design/ant-design-charts
JavaScript
362
star
16

gatsby-theme-antv

⚛️ Polished Gatsby theme for documentation site
TypeScript
340
star
17

data-set

state driven all in one data process for data visualization.
TypeScript
240
star
18

hierarchy

Layout algorithms for visualizing hierarchical data.
JavaScript
219
star
19

F2Native

📱📈An elegant, interactive and flexible native charting library for mobile.
C++
210
star
20

layout

Layout algorithms for graphs.
TypeScript
171
star
21

L7VP

L7VP is an geospatial intelligent visual analysis and application development tools.
TypeScript
148
star
22

my-f2

F2 的支付宝小程序版本
JavaScript
144
star
23

g-webgl-compute

A GPGPU implementation based on WebGL.
TypeScript
142
star
24

F6

F6 is a graph visualization engine which provides quick and smooth operations on mobile devices.
JavaScript
127
star
25

f2-canvas

微信小程序 F2 自定义图表组件
JavaScript
118
star
26

algorithm

常用的图算法 JS 实现,提供给 G6 及 Graphin 用于图分析场景使用。
TypeScript
96
star
27

china-geojson

This repo is being deprecated.
96
star
28

SAMJS

TypeScript
81
star
29

L7Plot

🌍 Geospatial Visualization Chart Library
TypeScript
79
star
30

util

utility library for AntV products.
TypeScript
76
star
31

mini-program-f2-demos

支付宝小程序小程序端的 F2 图表 demo
JavaScript
69
star
32

LarkMap

A React toolkit for geospatial visualization based on L7.
TypeScript
61
star
33

scale

📦 Toolkit for mapping abstract data into visual representation.
TypeScript
55
star
34

component

🍱 AntV UI component based on G render engine.
TypeScript
55
star
35

awesome-f2-charts

F2 图表可视化方案精选
HTML
47
star
36

vis-dashboard

🎨 Awesome dashboards, built with G2 and G2Plot.
TypeScript
40
star
37

L7Draw

L7 绘制控件
TypeScript
39
star
38

GUI

UI components for G. Merge to @antvis/component.
TypeScript
39
star
39

coord

Toolkit for apply point transformations for vector.
TypeScript
38
star
40

gatsby-starter-theme-antv

⚛️ Gatsby's starter of 👉
TypeScript
35
star
41

theme-set

💄 Customize theme for G2, G2Plot of AntV(孵化中)
TypeScript
35
star
42

FEngine

TypeScript
30
star
43

Dipper

下一代位置可视分析研发框架
TypeScript
28
star
44

g2-brush

Select a one-, two-dimensional or irregular region using the mouse.
JavaScript
24
star
45

smart-color

A JavaScript library for color computation.
TypeScript
24
star
46

L7Editor

Geographic data editing tool based on L7
TypeScript
24
star
47

L7-react

L7 React 版
TypeScript
23
star
48

g2-plugin-slider

A datazoom slider plugin for G2.
JavaScript
20
star
49

f2-context

F2针对多端的context适配
TypeScript
20
star
50

L7-Leaflet

L7 leaflet 插件
TypeScript
19
star
51

event-emitter

Simple event emitter for @antvis
TypeScript
19
star
52

dumi-theme-antv

AntV website theme based on dumi2.
TypeScript
19
star
53

DipperMap

A tool supporting geo data visualization
TypeScript
16
star
54

L7-boundary

行政区划围栏可视化方案
TypeScript
15
star
55

vis-predict-engine

可视化预测引擎,目前只用于预测图可视化布局.布局预测的模型由本引擎内置,支持force/radial/concentric/circular的四布局分类
TypeScript
13
star
56

attr

Attribute mapping module for @antvis.
TypeScript
12
star
57

graphlib

A lib containing multible usages for graph structure, graph algorithm, and other graph ops.
TypeScript
12
star
58

antv-spec

A declarative grammar that supports various technology stacks of AntV.
TypeScript
12
star
59

geo-coord

地理坐标系
TypeScript
11
star
60

my-f2-pc

淘宝PC小程序
JavaScript
8
star
61

L7Gallery

L7 demo 案例集锦
TypeScript
8
star
62

stat

常用统计函数的实现
TypeScript
8
star
63

interaction

interaction bindings for G2 and F2
TypeScript
7
star
64

L7-CustomLayer-Template

TypeScript
5
star
65

adjust

Adjust module for @antvis.
TypeScript
5
star
66

g-device-api

A Device API references WebGPU implementations
TypeScript
5
star
67

graphin-studio-site

Github Page Repo for Graphin Studio
HTML
5
star
68

A8

A music visualizer
TypeScript
5
star
69

g2plot-schema

Schemas of configs(options) of G2Plot chart types.
TypeScript
4
star
70

template

📃 Template repository for @antvis.
JavaScript
4
star
71

old-site

AntV 旧版本站点
HTML
4
star
72

vis-steg

Visualization Steganography: conceal information within visualization images.
TypeScript
4
star
73

AVAPy

Python Library for Automatic Visual Analytics
Python
4
star
74

g-gesture

WIP: Gesture module for @antv/g.
TypeScript
4
star
75

insight-component

Components for GI&LI
TypeScript
3
star
76

antvis-sites-data

🔢 Headless CMS data for https://antv.vision
3
star
77

g2-next-site

JavaScript
3
star
78

chart-node-g6

the Toolkit for G6 chart type nodes
TypeScript
3
star
79

autochart-config-panel

GUI config panel for the autoChart feature of AntV/AVA.
TypeScript
3
star
80

g-perf

Performance monitor for G.
TypeScript
3
star
81

data-samples

Open data set collection for AntV products
TypeScript
3
star
82

color-schema

A JSON schema used to regulate semantic color assets or palettes.
TypeScript
3
star
83

F7

L7小程序版本,支持支付宝、微信等多端小程序。
TypeScript
2
star
84

g2-3.x-site

The site of G2 3.x version
HTML
2
star
85

async-hook

the control flow for l7
TypeScript
2
star
86

create-antv-demo

A simple CV-dashboard framework for practicing how to use AntV.
JavaScript
2
star
87

g2-extensions

The one-stop shop for official @antv/g2 extensions.
TypeScript
2
star
88

thumbnails

Thumbnail images for different chart types from Chart Knowledge Base.
TypeScript
2
star
89

g6-3.2.x-site

The site for G6 3.2.x
HTML
2
star
90

gi-export

TypeScript
2
star
91

g2plot-1.x-site

The site of G2Plot 1.x version.
HTML
1
star
92

storytelling

Telling story by data visualization.
TypeScript
1
star
93

translator

A translator based on Google Translate.
JavaScript
1
star