@antv/g6 5.0.32 → 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.
- package/README.md +33 -34
- package/README.zh-CN.md +117 -0
- package/dist/g6.min.js +29 -29
- package/dist/lib/behaviors/collapse-expand.d.ts +6 -0
- package/dist/lib/behaviors/drag-element.d.ts +1 -1
- package/dist/lib/elements/nodes/html.d.ts +4 -0
- package/dist/lib/exports.d.ts +1 -0
- package/dist/lib/plugins/snapline/index.d.ts +1 -1
- package/dist/lib/runtime/data.d.ts +1 -1
- package/dist/lib/runtime/element.d.ts +29 -2
- package/dist/lib/runtime/graph.d.ts +11 -9
- package/dist/lib/runtime/viewport.d.ts +22 -2
- package/dist/lib/spec/data.d.ts +2 -2
- package/dist/lib/utils/event/events.d.ts +4 -4
- package/dist/lib/utils/id.d.ts +1 -1
- package/dist/lib/utils/visibility.d.ts +1 -2
- package/dist/lib/version.d.ts +1 -1
- package/esm/behaviors/collapse-expand.d.ts +6 -0
- package/esm/behaviors/collapse-expand.js +4 -3
- package/esm/behaviors/collapse-expand.js.map +1 -1
- package/esm/behaviors/drag-element.d.ts +1 -1
- package/esm/behaviors/optimize-viewport-transform.js +1 -1
- package/esm/behaviors/optimize-viewport-transform.js.map +1 -1
- package/esm/elements/nodes/html.d.ts +4 -0
- package/esm/elements/nodes/html.js +7 -0
- package/esm/elements/nodes/html.js.map +1 -1
- package/esm/elements/shapes/base-shape.js +1 -1
- package/esm/elements/shapes/base-shape.js.map +1 -1
- package/esm/exports.d.ts +1 -0
- package/esm/plugins/hull/util.js +6 -1
- package/esm/plugins/hull/util.js.map +1 -1
- package/esm/plugins/snapline/index.d.ts +1 -1
- package/esm/preset.js +0 -2
- package/esm/preset.js.map +1 -1
- package/esm/runtime/data.d.ts +1 -1
- package/esm/runtime/data.js +8 -3
- package/esm/runtime/data.js.map +1 -1
- package/esm/runtime/element.d.ts +29 -2
- package/esm/runtime/element.js +34 -4
- package/esm/runtime/element.js.map +1 -1
- package/esm/runtime/graph.d.ts +11 -9
- package/esm/runtime/graph.js +20 -15
- package/esm/runtime/graph.js.map +1 -1
- package/esm/runtime/viewport.d.ts +22 -2
- package/esm/runtime/viewport.js +12 -11
- package/esm/runtime/viewport.js.map +1 -1
- package/esm/spec/data.d.ts +2 -2
- package/esm/transforms/place-radial-labels.js +6 -1
- package/esm/transforms/place-radial-labels.js.map +1 -1
- package/esm/utils/event/events.d.ts +4 -4
- package/esm/utils/id.d.ts +1 -1
- package/esm/utils/visibility.d.ts +1 -2
- package/esm/utils/visibility.js +8 -34
- package/esm/utils/visibility.js.map +1 -1
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/lib/behaviors/collapse-expand.d.ts +6 -0
- package/lib/behaviors/collapse-expand.js +4 -3
- package/lib/behaviors/collapse-expand.js.map +1 -1
- package/lib/behaviors/drag-element.d.ts +1 -1
- package/lib/behaviors/optimize-viewport-transform.js +1 -1
- package/lib/behaviors/optimize-viewport-transform.js.map +1 -1
- package/lib/elements/edges/base-edge.js +17 -7
- package/lib/elements/edges/base-edge.js.map +1 -1
- package/lib/elements/nodes/html.d.ts +4 -0
- package/lib/elements/nodes/html.js +7 -0
- package/lib/elements/nodes/html.js.map +1 -1
- package/lib/elements/shapes/base-shape.js +1 -1
- package/lib/elements/shapes/base-shape.js.map +1 -1
- package/lib/exports.d.ts +1 -0
- package/lib/plugins/hull/util.js +5 -0
- package/lib/plugins/hull/util.js.map +1 -1
- package/lib/plugins/snapline/index.d.ts +1 -1
- package/lib/preset.js +0 -2
- package/lib/preset.js.map +1 -1
- package/lib/runtime/data.d.ts +1 -1
- package/lib/runtime/data.js +7 -2
- package/lib/runtime/data.js.map +1 -1
- package/lib/runtime/element.d.ts +29 -2
- package/lib/runtime/element.js +34 -4
- package/lib/runtime/element.js.map +1 -1
- package/lib/runtime/graph.d.ts +11 -9
- package/lib/runtime/graph.js +20 -15
- package/lib/runtime/graph.js.map +1 -1
- package/lib/runtime/viewport.d.ts +22 -2
- package/lib/runtime/viewport.js +12 -11
- package/lib/runtime/viewport.js.map +1 -1
- package/lib/spec/data.d.ts +2 -2
- package/lib/transforms/place-radial-labels.js +6 -1
- package/lib/transforms/place-radial-labels.js.map +1 -1
- package/lib/utils/event/events.d.ts +4 -4
- package/lib/utils/id.d.ts +1 -1
- package/lib/utils/visibility.d.ts +1 -2
- package/lib/utils/visibility.js +8 -34
- package/lib/utils/visibility.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +8 -8
- package/src/behaviors/collapse-expand.ts +10 -3
- package/src/behaviors/optimize-viewport-transform.ts +1 -1
- package/src/elements/nodes/html.ts +9 -0
- package/src/elements/shapes/base-shape.ts +1 -1
- package/src/exports.ts +1 -0
- package/src/plugins/hull/util.ts +7 -1
- package/src/preset.ts +0 -3
- package/src/runtime/data.ts +11 -4
- package/src/runtime/element.ts +51 -4
- package/src/runtime/graph.ts +21 -17
- package/src/runtime/viewport.ts +36 -10
- package/src/spec/data.ts +2 -2
- package/src/transforms/place-radial-labels.ts +5 -1
- package/src/utils/visibility.ts +6 -35
- package/src/version.ts +1 -1
- package/README.en-US.md +0 -118
package/src/utils/visibility.ts
CHANGED
|
@@ -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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
-

|
|
8
|
-
|
|
9
|
-
[](https://www.npmjs.com/package/@antv/g6)
|
|
10
|
-
[](https://github.com/antvis/g6/actions)
|
|
11
|
-
[](https://coveralls.io/github/antvis/G6)
|
|
12
|
-
[](https://www.npmjs.com/package/@antv/g6)
|
|
13
|
-

|
|
14
|
-
[](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).
|