@antv/g6 5.0.31 → 5.0.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/README.md +33 -34
  2. package/README.zh-CN.md +117 -0
  3. package/dist/g6.min.js +29 -29
  4. package/dist/lib/behaviors/collapse-expand.d.ts +6 -0
  5. package/dist/lib/behaviors/drag-element.d.ts +1 -1
  6. package/dist/lib/elements/nodes/html.d.ts +4 -0
  7. package/dist/lib/exports.d.ts +1 -0
  8. package/dist/lib/plugins/snapline/index.d.ts +1 -1
  9. package/dist/lib/runtime/data.d.ts +1 -1
  10. package/dist/lib/runtime/element.d.ts +29 -2
  11. package/dist/lib/runtime/graph.d.ts +11 -9
  12. package/dist/lib/runtime/viewport.d.ts +22 -2
  13. package/dist/lib/spec/data.d.ts +2 -2
  14. package/dist/lib/utils/event/events.d.ts +4 -4
  15. package/dist/lib/utils/id.d.ts +1 -1
  16. package/dist/lib/utils/visibility.d.ts +1 -2
  17. package/dist/lib/version.d.ts +1 -1
  18. package/esm/behaviors/collapse-expand.d.ts +6 -0
  19. package/esm/behaviors/collapse-expand.js +4 -3
  20. package/esm/behaviors/collapse-expand.js.map +1 -1
  21. package/esm/behaviors/drag-element.d.ts +1 -1
  22. package/esm/behaviors/optimize-viewport-transform.js +1 -1
  23. package/esm/behaviors/optimize-viewport-transform.js.map +1 -1
  24. package/esm/elements/nodes/html.d.ts +4 -0
  25. package/esm/elements/nodes/html.js +7 -0
  26. package/esm/elements/nodes/html.js.map +1 -1
  27. package/esm/elements/shapes/base-shape.js +1 -1
  28. package/esm/elements/shapes/base-shape.js.map +1 -1
  29. package/esm/exports.d.ts +1 -0
  30. package/esm/plugins/background/index.js +0 -1
  31. package/esm/plugins/background/index.js.map +1 -1
  32. package/esm/plugins/grid-line.js +1 -3
  33. package/esm/plugins/grid-line.js.map +1 -1
  34. package/esm/plugins/hull/util.js +6 -1
  35. package/esm/plugins/hull/util.js.map +1 -1
  36. package/esm/plugins/snapline/index.d.ts +1 -1
  37. package/esm/plugins/utils/dom.js +2 -0
  38. package/esm/plugins/utils/dom.js.map +1 -1
  39. package/esm/preset.js +0 -2
  40. package/esm/preset.js.map +1 -1
  41. package/esm/runtime/data.d.ts +1 -1
  42. package/esm/runtime/data.js +8 -3
  43. package/esm/runtime/data.js.map +1 -1
  44. package/esm/runtime/element.d.ts +29 -2
  45. package/esm/runtime/element.js +34 -4
  46. package/esm/runtime/element.js.map +1 -1
  47. package/esm/runtime/graph.d.ts +11 -9
  48. package/esm/runtime/graph.js +20 -15
  49. package/esm/runtime/graph.js.map +1 -1
  50. package/esm/runtime/viewport.d.ts +22 -2
  51. package/esm/runtime/viewport.js +12 -11
  52. package/esm/runtime/viewport.js.map +1 -1
  53. package/esm/spec/data.d.ts +2 -2
  54. package/esm/transforms/place-radial-labels.js +6 -1
  55. package/esm/transforms/place-radial-labels.js.map +1 -1
  56. package/esm/utils/event/events.d.ts +4 -4
  57. package/esm/utils/id.d.ts +1 -1
  58. package/esm/utils/visibility.d.ts +1 -2
  59. package/esm/utils/visibility.js +8 -34
  60. package/esm/utils/visibility.js.map +1 -1
  61. package/esm/version.d.ts +1 -1
  62. package/esm/version.js +1 -1
  63. package/lib/behaviors/collapse-expand.d.ts +6 -0
  64. package/lib/behaviors/collapse-expand.js +4 -3
  65. package/lib/behaviors/collapse-expand.js.map +1 -1
  66. package/lib/behaviors/drag-element.d.ts +1 -1
  67. package/lib/behaviors/optimize-viewport-transform.js +1 -1
  68. package/lib/behaviors/optimize-viewport-transform.js.map +1 -1
  69. package/lib/elements/edges/base-edge.js +17 -7
  70. package/lib/elements/edges/base-edge.js.map +1 -1
  71. package/lib/elements/nodes/html.d.ts +4 -0
  72. package/lib/elements/nodes/html.js +7 -0
  73. package/lib/elements/nodes/html.js.map +1 -1
  74. package/lib/elements/shapes/base-shape.js +1 -1
  75. package/lib/elements/shapes/base-shape.js.map +1 -1
  76. package/lib/exports.d.ts +1 -0
  77. package/lib/plugins/background/index.js +0 -1
  78. package/lib/plugins/background/index.js.map +1 -1
  79. package/lib/plugins/grid-line.js +1 -3
  80. package/lib/plugins/grid-line.js.map +1 -1
  81. package/lib/plugins/hull/util.js +5 -0
  82. package/lib/plugins/hull/util.js.map +1 -1
  83. package/lib/plugins/snapline/index.d.ts +1 -1
  84. package/lib/plugins/utils/dom.js +2 -0
  85. package/lib/plugins/utils/dom.js.map +1 -1
  86. package/lib/preset.js +0 -2
  87. package/lib/preset.js.map +1 -1
  88. package/lib/runtime/data.d.ts +1 -1
  89. package/lib/runtime/data.js +7 -2
  90. package/lib/runtime/data.js.map +1 -1
  91. package/lib/runtime/element.d.ts +29 -2
  92. package/lib/runtime/element.js +34 -4
  93. package/lib/runtime/element.js.map +1 -1
  94. package/lib/runtime/graph.d.ts +11 -9
  95. package/lib/runtime/graph.js +20 -15
  96. package/lib/runtime/graph.js.map +1 -1
  97. package/lib/runtime/viewport.d.ts +22 -2
  98. package/lib/runtime/viewport.js +12 -11
  99. package/lib/runtime/viewport.js.map +1 -1
  100. package/lib/spec/data.d.ts +2 -2
  101. package/lib/transforms/place-radial-labels.js +6 -1
  102. package/lib/transforms/place-radial-labels.js.map +1 -1
  103. package/lib/utils/event/events.d.ts +4 -4
  104. package/lib/utils/id.d.ts +1 -1
  105. package/lib/utils/visibility.d.ts +1 -2
  106. package/lib/utils/visibility.js +8 -34
  107. package/lib/utils/visibility.js.map +1 -1
  108. package/lib/version.d.ts +1 -1
  109. package/lib/version.js +1 -1
  110. package/package.json +8 -8
  111. package/src/behaviors/collapse-expand.ts +10 -3
  112. package/src/behaviors/optimize-viewport-transform.ts +1 -1
  113. package/src/elements/nodes/html.ts +9 -0
  114. package/src/elements/shapes/base-shape.ts +1 -1
  115. package/src/exports.ts +1 -0
  116. package/src/plugins/background/index.ts +0 -1
  117. package/src/plugins/grid-line.ts +1 -3
  118. package/src/plugins/hull/util.ts +7 -1
  119. package/src/plugins/utils/dom.ts +2 -0
  120. package/src/preset.ts +0 -3
  121. package/src/runtime/data.ts +11 -4
  122. package/src/runtime/element.ts +51 -4
  123. package/src/runtime/graph.ts +21 -17
  124. package/src/runtime/viewport.ts +36 -10
  125. package/src/spec/data.ts +2 -2
  126. package/src/transforms/place-radial-labels.ts +5 -1
  127. package/src/utils/visibility.ts +6 -35
  128. package/src/version.ts +1 -1
  129. package/README.en-US.md +0 -118
@@ -53,6 +53,7 @@ import { BehaviorController } from './behavior';
53
53
  import type { DataURLOptions } from './canvas';
54
54
  import { Canvas } from './canvas';
55
55
  import { DataController } from './data';
56
+ import type { CollapseExpandNodeOptions } from './element';
56
57
  import { ElementController } from './element';
57
58
  import { LayoutController } from './layout';
58
59
  import { PluginController } from './plugin';
@@ -424,7 +425,7 @@ export class Graph extends EventEmitter {
424
425
  * <zh/> 获取插件实例
425
426
  *
426
427
  * <en/> Get plugin instance
427
- * @param key - <zh/> 插件 key | <en/> plugin key
428
+ * @param key - <zh/> 插件 key(在配置 plugin 时需要手动传入指定) | <en/> plugin key(need to be specified manually when configuring plugin)
428
429
  * @returns <zh/> 插件实例 | <en/> plugin instance
429
430
  * @remarks
430
431
  * <zh/> 一些插件提供了 API 方法可供调用,例如全屏插件可以调用 `request` 和 `exit` 方法来请求和退出全屏
@@ -1286,7 +1287,7 @@ export class Graph extends EventEmitter {
1286
1287
  * @apiCategory viewport
1287
1288
  */
1288
1289
  public async fitCenter(animation?: ViewportAnimationEffectTiming): Promise<void> {
1289
- await this.context.viewport?.fitCenter(animation);
1290
+ await this.context.viewport?.fitCenter({ animation });
1290
1291
  }
1291
1292
 
1292
1293
  private async autoFit(): Promise<void> {
@@ -1316,7 +1317,7 @@ export class Graph extends EventEmitter {
1316
1317
  * @apiCategory viewport
1317
1318
  */
1318
1319
  public async focusElement(id: ID | ID[], animation?: ViewportAnimationEffectTiming): Promise<void> {
1319
- await this.context.viewport?.focusElements(Array.isArray(id) ? id : [id], animation);
1320
+ await this.context.viewport?.focusElements(Array.isArray(id) ? id : [id], { animation });
1320
1321
  }
1321
1322
 
1322
1323
  /**
@@ -1782,50 +1783,53 @@ export class Graph extends EventEmitter {
1782
1783
  private isCollapsingExpanding = false;
1783
1784
 
1784
1785
  /**
1785
- * <zh/> 收起组合
1786
+ * <zh/> 收起元素
1786
1787
  *
1787
- * <en/> Collapse Combo
1788
+ * <en/> Collapse element
1788
1789
  * @param id - <zh/> 元素 ID | <en/> element ID
1789
- * @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
1790
+ * @param options - <zh/> 是否启用动画或者配置收起节点的配置项 | <en/> whether to enable animation or the options of collapsing node
1790
1791
  * @apiCategory element
1791
1792
  */
1792
- public async collapseElement(id: ID, animation: boolean = true): Promise<void> {
1793
+ public async collapseElement(id: ID, options: boolean | CollapseExpandNodeOptions = true): Promise<void> {
1793
1794
  const { model, element } = this.context;
1794
1795
  if (isCollapsed(model.getNodeLikeData([id])[0])) return;
1795
-
1796
1796
  if (this.isCollapsingExpanding) return;
1797
1797
 
1798
+ if (typeof options === 'boolean') options = { animation: options, align: true };
1799
+
1798
1800
  const elementType = model.getElementType(id);
1799
1801
 
1800
1802
  await this.frontElement(id);
1801
1803
  this.isCollapsingExpanding = true;
1802
1804
  this.setElementCollapsibility(id, true);
1803
- if (elementType === 'node') await element!.collapseNode(id, animation);
1804
- else if (elementType === 'combo') await element!.collapseCombo(id, animation);
1805
+ if (elementType === 'node') await element!.collapseNode(id, options);
1806
+ else if (elementType === 'combo') await element!.collapseCombo(id, !!options.animation);
1805
1807
 
1806
1808
  this.isCollapsingExpanding = false;
1807
1809
  }
1808
1810
 
1809
1811
  /**
1810
- * <zh/> 展开组合
1812
+ * <zh/> 展开元素
1811
1813
  *
1812
- * <en/> Expand Combo
1814
+ * <en/> Expand Element
1813
1815
  * @param id - <zh/> 元素 ID | <en/> element ID
1814
- * @param animation - <zh/> 是否启用动画 | <en/> whether to enable animation
1816
+ * @param animation - <zh/> 是否启用动画或者配置收起节点的配置项 | <en/> whether to enable animation or the options of collapsing node
1817
+ * @param options
1815
1818
  * @apiCategory element
1816
1819
  */
1817
- public async expandElement(id: ID, animation: boolean = true): Promise<void> {
1820
+ public async expandElement(id: ID, options: boolean | CollapseExpandNodeOptions = true): Promise<void> {
1818
1821
  const { model, element } = this.context;
1819
1822
  if (!isCollapsed(model.getNodeLikeData([id])[0])) return;
1820
-
1821
1823
  if (this.isCollapsingExpanding) return;
1822
1824
 
1825
+ if (typeof options === 'boolean') options = { animation: options, align: true };
1826
+
1823
1827
  const elementType = model.getElementType(id);
1824
1828
 
1825
1829
  this.isCollapsingExpanding = true;
1826
1830
  this.setElementCollapsibility(id, false);
1827
- if (elementType === 'node') await element!.expandNode(id, animation);
1828
- else if (elementType === 'combo') await element!.expandCombo(id, animation);
1831
+ if (elementType === 'node') await element!.expandNode(id, options);
1832
+ else if (elementType === 'combo') await element!.expandCombo(id, !!options.animation);
1829
1833
 
1830
1834
  this.isCollapsingExpanding = false;
1831
1835
  }
@@ -2,6 +2,7 @@ import { AABB, ICamera } from '@antv/g';
2
2
  import { clamp, isNumber, pick } from '@antv/util';
3
3
  import { AnimationType, GraphEvent } from '../constants';
4
4
  import type { FitViewOptions, ID, Point, TransformOptions, Vector2, ViewportAnimationEffectTiming } from '../types';
5
+ import type { Element } from '../types/element';
5
6
  import { getAnimationOptions } from '../utils/animation';
6
7
  import { getBBoxSize, getCombinedBBox, getExpandedBBox, isBBoxInside, isPointInBBox } from '../utils/bbox';
7
8
  import { AnimateEvent, ViewportEvent, emit } from '../utils/event';
@@ -217,7 +218,7 @@ export class ViewportController {
217
218
  (direction === 'y' && contentHeight >= innerHeight) ||
218
219
  (direction === 'both' && contentWidth >= innerWidth && contentHeight >= innerHeight);
219
220
 
220
- if (when === 'overflow' && !isOverflow) return await this.fitCenter(animation);
221
+ if (when === 'overflow' && !isOverflow) return await this.fitCenter({ animation });
221
222
 
222
223
  const scaleX = innerWidth / contentWidth;
223
224
  const scaleY = innerHeight / contentHeight;
@@ -237,23 +238,27 @@ export class ViewportController {
237
238
  );
238
239
  }
239
240
 
240
- public async fitCenter(animation?: ViewportAnimationEffectTiming): Promise<void> {
241
+ public async fitCenter(options: FocusOptions): Promise<void> {
241
242
  const canvasBounds = this.context.canvas.getBounds();
242
- await this.focus(canvasBounds, animation);
243
+ await this.focus(canvasBounds, options);
243
244
  }
244
245
 
245
- public async focusElements(ids: ID[], animation?: ViewportAnimationEffectTiming): Promise<void> {
246
+ public async focusElements(ids: ID[], options: FocusOptions = {}): Promise<void> {
246
247
  const { element } = this.context;
247
248
  if (!element) return;
248
- const elementsBounds = getCombinedBBox(ids.map((id) => element.getElement(id)!.getRenderBounds()));
249
- await this.focus(elementsBounds, animation);
249
+
250
+ const getBoundsOf = (el: Element) =>
251
+ options.shapes ? el.getShape(options.shapes).getRenderBounds() : el.getRenderBounds();
252
+
253
+ const elementsBounds = getCombinedBBox(ids.map((id) => getBoundsOf(element.getElement(id)!)));
254
+ await this.focus(elementsBounds, options);
250
255
  }
251
256
 
252
- private async focus(bbox: AABB, animation?: ViewportAnimationEffectTiming) {
257
+ private async focus(bbox: AABB, options: FocusOptions) {
253
258
  const center = this.context.graph.getViewportByCanvas(bbox.center);
254
- const canvasCenter = this.getCanvasCenter();
255
- const delta = subtract(canvasCenter, center);
256
- await this.transform({ mode: 'relative', translate: add(delta, this.paddingOffset) }, animation);
259
+ const position = options.position || this.getCanvasCenter();
260
+ const delta = subtract(position, center);
261
+ await this.transform({ mode: 'relative', translate: add(delta, this.paddingOffset) }, options.animation);
257
262
  }
258
263
 
259
264
  /**
@@ -312,3 +317,24 @@ export class ViewportController {
312
317
  this.transformResolver?.();
313
318
  }
314
319
  }
320
+
321
+ export interface FocusOptions {
322
+ /**
323
+ * <zh/> 动画配置
324
+ *
325
+ * <en/> Animation configuration
326
+ */
327
+ animation?: ViewportAnimationEffectTiming;
328
+ /**
329
+ * <zh/> 使用子图形计算包围盒
330
+ *
331
+ * <en/> Calculate the bounding box by using sub-shapes
332
+ */
333
+ shapes?: string;
334
+ /**
335
+ * <zh/> 对齐位置,默认为画布中心
336
+ *
337
+ * <en/> Alignment position, default is the center of the canvas
338
+ */
339
+ position?: Point;
340
+ }
package/src/spec/data.ts CHANGED
@@ -92,7 +92,7 @@ export interface NodeData {
92
92
  *
93
93
  * <en/> ID of the combo to which the node belongs
94
94
  */
95
- combo?: ID;
95
+ combo?: ID | null;
96
96
  /**
97
97
  * <zh/> 子节点 ID
98
98
  *
@@ -161,7 +161,7 @@ export interface ComboData {
161
161
  *
162
162
  * <en/> ID of the combo to which the combo belongs
163
163
  */
164
- combo?: ID;
164
+ combo?: ID | null;
165
165
  [key: string]: unknown;
166
166
  }
167
167
 
@@ -54,7 +54,11 @@ export class PlaceRadialLabels extends BaseTransform<PlaceRadialLabelsOptions> {
54
54
  const isLeft = Math.abs(radian) > Math.PI / 2;
55
55
 
56
56
  const isLeaf = !datum.children || datum.children.length === 0;
57
- const nodeHalfWidth = parseSize(graph.getElementRenderStyle(idOf(datum)).size)[0] / 2;
57
+ const nodeId = idOf(datum);
58
+ const node = this.context.element?.getElement(nodeId);
59
+ if (!node || !node.isVisible()) return;
60
+
61
+ const nodeHalfWidth = parseSize(graph.getElementRenderStyle(nodeId).size)[0] / 2;
58
62
  const offset = (isLeaf ? 1 : -1) * (nodeHalfWidth + this.options.offset);
59
63
 
60
64
  const labelTransform: TransformArray = [
@@ -1,14 +1,11 @@
1
1
  import type { BaseStyleProps, DisplayObject } from '@antv/g';
2
2
 
3
- const ORIGINAL_MAP = new WeakMap<DisplayObject, BaseStyleProps['visibility']>();
4
-
5
3
  /**
6
4
  * <zh/> 设置图形实例的可见性
7
5
  *
8
6
  * <en/> Set the visibility of the shape instance
9
7
  * @param shape - <zh/> 图形实例 | <en/> shape instance
10
8
  * @param value - <zh/> 可见性 | <en/> visibility
11
- * @param inherited - <zh/> 是否是来自继承样式 | <en/> Whether it is from inherited styles
12
9
  * @param filter - <zh/> 筛选出需要设置可见性的图形 | <en/> Filter out the shapes that need to set visibility
13
10
  * @remarks
14
11
  * <zh/> 在设置 enableCSSParsing 为 false 的情况下,复合图形无法继承父属性,因此需要对所有子图形应用相同的可见性
@@ -18,40 +15,14 @@ const ORIGINAL_MAP = new WeakMap<DisplayObject, BaseStyleProps['visibility']>();
18
15
  export function setVisibility(
19
16
  shape: DisplayObject,
20
17
  value: BaseStyleProps['visibility'],
21
- inherited = false,
22
18
  filter?: (shape: DisplayObject) => boolean,
23
19
  ) {
24
- if (value === undefined) return;
25
-
26
- const traverse = (current: DisplayObject, scope = value): void => {
27
- const walk = (val = scope): void => (current.childNodes as DisplayObject[]).forEach((node) => traverse(node, val));
28
-
29
- if (filter && !filter(current)) return walk();
30
-
31
- if (!inherited && current === shape) {
32
- shape.style.visibility = value;
33
- ORIGINAL_MAP.delete(shape);
34
- walk(value);
35
- } else {
36
- if (!ORIGINAL_MAP.has(current)) ORIGINAL_MAP.set(current, current.style.visibility);
37
-
38
- const computedValue = scope === 'hidden' || getOriginalValue(current) === 'hidden' ? 'hidden' : 'visible';
39
- current.style.visibility = computedValue;
40
- walk(computedValue);
41
- }
20
+ const callback = (node: DisplayObject) => {
21
+ if (filter && !filter(node)) return;
22
+ node.style.visibility = value;
42
23
  };
43
24
 
44
- traverse(shape);
45
- }
46
-
47
- /**
48
- * <zh/> 获取图形原本的可见性
49
- *
50
- * <en/> Get the original visibility of the shape
51
- * @param shape - <zh/> 图形实例 | <en/> shape instance
52
- * @returns <zh/> 可见性 | <en/> visibility
53
- */
54
- function getOriginalValue(shape: DisplayObject) {
55
- if (ORIGINAL_MAP.has(shape)) return ORIGINAL_MAP.get(shape);
56
- return shape.style.visibility;
25
+ shape.forEach((node) => {
26
+ callback(node as DisplayObject);
27
+ });
57
28
  }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '5.0.31';
1
+ export const version = '5.0.33';
package/README.en-US.md DELETED
@@ -1,118 +0,0 @@
1
- <img src="https://gw.alipayobjects.com/zos/antfincdn/R8sN%24GNdh6/language.svg" width="18"> English | [简体中文](./README.md)
2
-
3
- <h1 align="center">
4
- <b>G6: A Graph Visualization Framework in TypeScript</b>
5
- </h1>
6
-
7
- ![](https://user-images.githubusercontent.com/6113694/45008751-ea465300-b036-11e8-8e2a-166cbb338ce2.png)
8
-
9
- [![npm Version](https://img.shields.io/npm/v/@antv/g6.svg)](https://www.npmjs.com/package/@antv/g6)
10
- [![Build Status](https://github.com/antvis/g6/workflows/build/badge.svg?branch=v5)](https://github.com/antvis/g6/actions)
11
- [![Coverage Status](https://coveralls.io/repos/github/antvis/G6/badge.svg)](https://coveralls.io/github/antvis/G6)
12
- [![npm Download](https://img.shields.io/npm/dm/@antv/g6.svg)](https://www.npmjs.com/package/@antv/g6)
13
- ![typescript](https://img.shields.io/badge/language-typescript-blue.svg)
14
- [![npm License](https://img.shields.io/npm/l/@antv/g6.svg)](https://www.npmjs.com/package/@antv/g6)
15
-
16
- <p align="center">
17
- <a href="https://g6.antv.antgroup.com/">Introduction</a> •
18
- <a href="https://g6.antv.antgroup.com/examples">Examples</a> •
19
- <a href="https://g6.antv.antgroup.com/">Tutorial</a> •
20
- <a href="https://g6.antv.antgroup.com/">API</a>
21
- </p>
22
-
23
- [G6](https://github.com/antvis/g6) is a graph visualization engine. It provides basic capabilities for graph visualization and analysis such as drawing, layout, analysis, interaction, animation, themes, and plugins. With G6, users can quickly build their own graph visualization and analysis applications, making relational data simple, transparent, and meaningful.
24
-
25
- <img src='https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*_PJ5SZELwq0AAAAAAAAAAAAADmJ7AQ/original' width=550 alt='' />
26
-
27
- <img src='https://gw.alipayobjects.com/mdn/rms_f8c6a0/afts/img/A*zTjwQaXokeQAAAAAAAAAAABkARQnAQ' width=550 alt='' />
28
-
29
- <img src='https://gw.alipayobjects.com/mdn/rms_f8c6a0/afts/img/A*zau8QJcVpDQAAAAAAAAAAABkARQnAQ' height=200 alt='' /><img src='https://gw.alipayobjects.com/mdn/rms_f8c6a0/afts/img/A*RIlETY_S6IoAAAAAAAAAAABkARQnAQ' height=200 alt='' />
30
-
31
- <img src='https://gw.alipayobjects.com/mdn/rms_f8c6a0/afts/img/A*cDzXR4jIWr8AAAAAAAAAAABkARQnAQ' height=150 alt='' /><img src='https://gw.alipayobjects.com/mdn/rms_f8c6a0/afts/img/A*HTasSJGC4koAAAAAAAAAAABkARQnAQ' height=150 alt='' />
32
-
33
- <img src="https://user-images.githubusercontent.com/6113694/44995293-02858600-afd5-11e8-840c-349e4730d63d.gif" height=150 alt='' /><img src="https://gw.alipayobjects.com/mdn/rms_f8c6a0/afts/img/A*I9OdTbXJIi0AAAAAAAAAAABkARQnAQ" height=150 alt='' /><img src="https://gw.alipayobjects.com/mdn/rms_f8c6a0/afts/img/A*xoufSYcjK2AAAAAAAAAAAABkARQnAQ" height=150 alt='' />
34
-
35
- ## ✨ Features
36
-
37
- G6, as a professional graph visualization engine, boasts the following features:
38
-
39
- - **Rich Elements**: It comes with a variety of built-in node, edge, and Combo UI elements with extensive style configurations, supports data callbacks, and has a flexible mechanism for extending custom elements.
40
- - **Controllable Interactions**: It includes more than 10 built-in interaction behaviors and offers a rich array of events, facilitating the expansion of custom interactive behaviors.
41
- - **High-Performance Layout**: The engine features more than 10 common graph layouts, some of which leverage GPU and Rust parallel computing for enhanced performance, and it supports custom layout development.
42
- - **Convenient Plugins**: Optimized built-in plugin functionality and performance, with flexible extensibility, making it easier to implement customized business capabilities.
43
- - **Multiple Theme and Palettes**: Provides two sets of built-in themes, light and dark, that integrate over 20 popular community color palettes based on the AntV new color scheme.
44
- - **Multi-Environment Rendering**: Harnessing the power of [G](https://github.com/antvis/g), it supports rendering in Canvas, SVG, and WebGL, as well as server-side rendering with Node.js; it also offers plugin packages that provide powerful 3D rendering and spatial interactions based on WebGL.
45
- - **React Ecosystem**: By utilizing the React front-end ecosystem, it supports React nodes, significantly enriching the presentational styles of G6 nodes.
46
-
47
- ## 🔨 Getting Started
48
-
49
- G6 is usually installed via a package manager such as npm or Yarn.
50
-
51
- ```bash
52
- $ npm install @antv/g6
53
- ```
54
-
55
- The `Graph` object then can be imported from G6.
56
-
57
- ```html
58
- <div id="container"></div>
59
- ```
60
-
61
- ```ts
62
- import { Graph } from '@antv/g6';
63
-
64
- // Get the Data.
65
- const data = {
66
- nodes: [
67
- /* your nodes data */
68
- ],
69
- edges: [
70
- /* your edges data */
71
- ],
72
- };
73
-
74
- // Create the Graph instance.
75
- const graph = new Graph({
76
- container: 'container',
77
- data,
78
- node: {
79
- palette: {
80
- type: 'group',
81
- field: 'cluster',
82
- },
83
- },
84
- layout: {
85
- type: 'force',
86
- },
87
- behaviors: ['drag-canvas', 'drag-node'],
88
- });
89
-
90
- // Render the Graph.
91
- graph.render();
92
- ```
93
-
94
- All goes well, you can get the following lovely graph!
95
-
96
- <img src="https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*ue4iTYurc6sAAAAAAAAAAAAADmJ7AQ/fmt.webp" height="300" />
97
-
98
- ## 🌍 Ecosystem
99
-
100
- - **Ant Design Charts**: A React chart library based on G2, G6, X6, L7.
101
- - **Graphin**: A simple React wrapper based on G6, as well as an SDK for developing graph visualization applications.
102
-
103
- For more ecosystem open-source projects, contributions are welcome. Please feel free to submit a PR for inclusion.
104
-
105
- ## 📮 Contributing
106
-
107
- - **Issue Reporting**: If you encounter any issues with G6 during use, please feel free to submit an issue, along with the minimal sample code that can reproduce the problem.
108
- - **Contribution Guide**: Information on how to get involved in the [development and contribution](https://g6.antv.antgroup.com/en/manual/contribute) to G6.
109
- - **Ideas Discussion**: Discuss your ideas on GitHub Discussions or in the DingTalk group.
110
-
111
- <div align="center">
112
- <img src="https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*CQoGSoFBzaUAAAAAAAAAAAAADmJ7AQ/fmt.webp" height="256" />
113
- <img src="https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*yXJGSY8RC68AAAAAAAAAAAAADmJ7AQ/fmt.webp" height="256" />
114
- </div>
115
-
116
- ## 📄 License
117
-
118
- [MIT](./LICENSE).