Skip to content

Commit 934661e

Browse files
Yanyan-Wangfxiangyixiangyifeng
authored
perf: Annotation min-width and input width; (#3947)
* perf: Annotation min-width and input width; * Fix build issue (#3934) * fix: there is no dir named mobile * fix: path-util is not marked as dependency of plugin, but actually it is Co-authored-by: xiangyifeng <[email protected]> Co-authored-by: fxiangyi <[email protected]> Co-authored-by: xiangyifeng <[email protected]>
1 parent c0f6161 commit 934661e

File tree

15 files changed

+70
-61
lines changed

15 files changed

+70
-61
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# ChangeLog
22

3+
### 4.7.4
4+
5+
- perf: Annotation min-width and input width;
6+
37
### 4.7.3
48

59
- feat: beforechangedata and afterchagnedata for graph changeData;

package.json

+2-6
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,20 @@
55
"packages/*"
66
],
77
"scripts": {
8-
"analysis:mobile": "cd ./packages/mobile && npm run analysis",
98
"build:demos": "cd ./packages/pc && npm run demos",
10-
"build:demos-mobile": "cd ./packages/mobile && npm run demos",
119
"build:site": "cd ./packages/site && npm run start",
1210
"build:core": "cd ./packages/core && npm run build",
1311
"build:element": "cd ./packages/element && npm run build",
1412
"build:plugin": "cd ./packages/plugin && npm run build",
1513
"build:pc": "cd ./packages/pc && npm run build",
1614
"build:g6": "cd ./packages/g6 && npm run build",
1715
"build:react-node": "cd ./packages/react-node && npm run build",
18-
"build:mobile": "cd ./packages/mobile && npm run build",
19-
"build:all": "npm run build:core && npm run build:element && npm run build:plugin && npm run build:pc && npm run build:g6 && npm run build:mobile",
16+
"build:all": "npm run build:core && npm run build:element && npm run build:plugin && npm run build:pc && npm run build:g6",
2017
"lint:core": "cd ./packages/core && npm run lint",
2118
"lint:element": "cd ./packages/element && npm run lint",
2219
"lint:plugin": "cd ./packages/plugin && npm run lint",
2320
"lint:pc": "cd ./packages/pc && npm run lint",
2421
"lint:g6": "cd ./packages/g6 && npm run lint",
25-
"lint:mobile": "cd ./packages/mobile && npm run lint",
2622
"lint:all": "npm run lint:core && npm run lint:element && npm run lint:plugin && npm run lint:pc && npm run lint:g6",
2723
"build": "lerna run build --include-dependencies --stream",
2824
"lint": "npm run lint:all",
@@ -91,4 +87,4 @@
9187
"normalize-url": "^4.1.0",
9288
"sharp": "^0.30.4"
9389
}
94-
}
90+
}

packages/core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g6-core",
3-
"version": "0.7.3",
3+
"version": "0.7.4",
44
"description": "A Graph Visualization Framework in JavaScript",
55
"keywords": [
66
"antv",

packages/core/src/global.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const colorSet = {
6464
};
6565

6666
export default {
67-
version: '0.7.3',
67+
version: '0.7.4',
6868
rootContainerClassName: 'root-container',
6969
nodeContainerClassName: 'node-container',
7070
edgeContainerClassName: 'edge-container',

packages/element/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g6-element",
3-
"version": "0.7.3",
3+
"version": "0.7.4",
44
"description": "A Graph Visualization Framework in JavaScript",
55
"keywords": [
66
"antv",
@@ -61,7 +61,7 @@
6161
},
6262
"dependencies": {
6363
"@antv/g-base": "^0.5.1",
64-
"@antv/g6-core": "0.7.3",
64+
"@antv/g6-core": "0.7.4",
6565
"@antv/util": "~2.0.5"
6666
},
6767
"devDependencies": {

packages/g6/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g6",
3-
"version": "4.7.3",
3+
"version": "4.7.4",
44
"description": "A Graph Visualization Framework in JavaScript",
55
"keywords": [
66
"antv",
@@ -66,7 +66,7 @@
6666
]
6767
},
6868
"dependencies": {
69-
"@antv/g6-pc": "0.7.3"
69+
"@antv/g6-pc": "0.7.4"
7070
},
7171
"devDependencies": {
7272
"@babel/core": "^7.7.7",

packages/g6/src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import G6 from '@antv/g6-pc';
22

3-
G6.version = '4.7.3';
3+
G6.version = '4.7.4';
44

55
export * from '@antv/g6-pc';
66
export default G6;
7-
export const version = '4.7.3';
7+
export const version = '4.7.4';

packages/pc/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g6-pc",
3-
"version": "0.7.3",
3+
"version": "0.7.4",
44
"description": "A Graph Visualization Framework in JavaScript",
55
"keywords": [
66
"antv",
@@ -75,9 +75,9 @@
7575
"@antv/g-canvas": "^0.5.2",
7676
"@antv/g-math": "^0.1.1",
7777
"@antv/g-svg": "^0.5.1",
78-
"@antv/g6-core": "0.7.3",
79-
"@antv/g6-element": "0.7.3",
80-
"@antv/g6-plugin": "0.7.3",
78+
"@antv/g6-core": "0.7.4",
79+
"@antv/g6-element": "0.7.4",
80+
"@antv/g6-plugin": "0.7.4",
8181
"@antv/hierarchy": "^0.6.7",
8282
"@antv/layout": "^0.3.0",
8383
"@antv/matrix-util": "^3.1.0-beta.3",

packages/pc/src/global.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const textColor = 'rgb(0, 0, 0)';
77
const colorSet = getColorsWithSubjectColor(subjectColor, backColor);
88

99
export default {
10-
version: '0.7.3',
10+
version: '0.7.4',
1111
rootContainerClassName: 'root-container',
1212
nodeContainerClassName: 'node-container',
1313
edgeContainerClassName: 'edge-container',

packages/plugin/package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/g6-plugin",
3-
"version": "0.7.3",
3+
"version": "0.7.4",
44
"description": "G6 Plugin",
55
"main": "lib/index.js",
66
"module": "es/index.js",
@@ -22,11 +22,12 @@
2222
"@antv/g-base": "^0.5.1",
2323
"@antv/g-canvas": "^0.5.2",
2424
"@antv/g-svg": "^0.5.2",
25-
"@antv/g6-core": "0.7.3",
26-
"@antv/g6-element": "0.7.3",
25+
"@antv/g6-core": "0.7.4",
26+
"@antv/g6-element": "0.7.4",
2727
"@antv/matrix-util": "^3.1.0-beta.3",
2828
"@antv/scale": "^0.3.4",
2929
"@antv/util": "^2.0.9",
30+
"@antv/path-util": "^2.0.3",
3031
"insert-css": "^2.0.0"
3132
},
3233
"sideEffects": false,
@@ -60,4 +61,4 @@
6061
"ts-jest": "^26.4.4",
6162
"@antv/g6": "4.5.1"
6263
}
63-
}
64+
}

packages/plugin/src/annotation/index.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ typeof document !== 'undefined' &&
2626
.g6-annotation-title {
2727
margin: 4px 40px 4px 8px;
2828
cursor: text;
29+
min-width: 32px;
2930
}
3031
.g6-annotation-collapse {
3132
margin: 4px;
@@ -44,6 +45,7 @@ typeof document !== 'undefined' &&
4445
width: fit-content;
4546
cursor: text;
4647
word-break: break-all;
48+
min-width: 32px;
4749
}
4850
.g6-annotation-title-input-wrapper {
4951
margin: 4px 40px 4px 8px;
@@ -181,7 +183,7 @@ export default class Annotation extends Base {
181183
const closeDOM = `<p class='g6-annotation-close'>x</p>`
182184
const borderRadius = collapsed ? `${r}px` : `${r}px ${r}px 0 0`;
183185

184-
return `<div class="g6-annotation-wrapper" style="border-radius: ${r}px; maxWidth: ${maxWidth}px">
186+
return `<div class="g6-annotation-wrapper" style="border-radius: ${r}px; max-width: ${maxWidth}px">
185187
<div
186188
class="g6-annotation-header-wapper"
187189
style="border-radius: ${borderRadius};"
@@ -709,11 +711,11 @@ export default class Annotation extends Base {
709711
const target = e.target;
710712
const targetClass = target.className;
711713
if (targetClass !== 'g6-annotation-title' && targetClass !== 'g6-annotation-content') return;
712-
const { width, height } = target.getBoundingClientRect();
714+
const { width, height } = targetClass === 'g6-annotation-title' ? target.getBoundingClientRect() : target.parentNode.getBoundingClientRect();
713715
const computeStyle = getComputedStyle(target);
714716
const inputTag = targetClass === 'g6-annotation-title' ? 'input' : 'textarea';
715-
const input = createDom(`<${inputTag} class="${targetClass}-input" type="textarea" style="width:${width}px; height: ${height}px"/>`);
716-
const inputWrapper = createDom(`<div class="${targetClass}-input-wrapper" style="width: ${width}px; height: ${height}px margin-right: ${computeStyle['marginRight']}" />`);
717+
const input = createDom(`<${inputTag} class="${targetClass}-input" type="textarea" style="width:${width}px; height: ${height}px; min-width: 16px;"/>`);
718+
const inputWrapper = createDom(`<div class="${targetClass}-input-wrapper" style="width: ${width}px; height: ${height}px; min-width: 16px; margin-right: ${computeStyle['marginRight']}" />`);
717719
inputWrapper.appendChild(input);
718720
target.parentNode.replaceChild(inputWrapper, target);
719721
if (targetClass === 'g6-annotation-title') {

packages/site/docs/manual/middle/states/defaultBehavior.en.md

+4
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,10 @@ const graph = new G6.Graph({
277277
- `type: 'click-select'`;
278278
- `multiple`: Whether to allow multiple selection. `true` by default. `false` means multiple selection is not allowed, and the `trigger` will not take effect.
279279
- `trigger`: Specify which trigger for multiple selection. `shift` by default, which means multiple selection is activated when the shift button is pressed. Options: `'shift'`, `'ctrl'`, `'alt'`, and so on;
280+
- `selectedState`: The state name for an item which is selected by this behaivor, `'selected'` by default;
281+
- `selectNode`: Whether allow selecting node by this behavior, `true` by default;
282+
- `selectEdge`: Whether allow selecting edge by this behavior, `false` by default;
283+
- `selectCombo`: Whether allow selecting combo by this behaivor, `true` by default;
280284
- `shouldBegin(e)`: Whether allow the behavior happen on the current item (e.item), see the example below;
281285
- `shouldUpdate(e)`: Whether allow the behavior changes the state and state style of the on the current item (e.item), see the example below.
282286
- Related timing events:

packages/site/docs/manual/middle/states/defaultBehavior.zh.md

+4
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,10 @@ const graph = new G6.Graph({
281281
- `type: 'click-select'`
282282
- `multiple`:是否允许多选,默认为 `true`,当设置为 `false`,表示不允许多选,此时 `trigger` 参数无效;
283283
- `trigger`:指定按住哪个键进行多选,默认为 shift,按住 Shift 键多选,用户可配置 shift、ctrl、alt;
284+
- `selectedState`:被点击选择后设置元素的状态名,默认为 `'selected'`
285+
- `selectNode`:是否允许节点被该交互选中,默认为 `true`
286+
- `selectEdge`:是否允许边被该交互选中,默认为 `false`
287+
- `selectCombo`:是否允许 Combo 被该交互选中,默认为 `true`
284288
- `shouldBegin(e)`:是否允许该 behavior 发生,参考下面示例;
285289
- `shouldUpdate(e)`:是否允许对该 behavior 发生状态响应,参考下面示例。
286290
- 相关时机事件:

packages/site/examples/case/graphDemos/demo/largeGraph.js

+16-17
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ const processNodesEdges = (
722722
// let maxCount = 0;
723723
edges.forEach((edge) => {
724724
// to avoid the dulplicated id to nodes
725-
if (!edge.id) edge.id = `edge-${uniqueId()}`;
725+
if (!edge.id) edge.id = uniqueId('edge');
726726
else if (edge.id.split('-')[0] !== 'edge') edge.id = `edge-${edge.id}`;
727727
// TODO: delete the following line after the queried data is correct
728728
if (!currentNodeMap[edge.source] || !currentNodeMap[edge.target]) {
@@ -785,9 +785,8 @@ const processNodesEdges = (
785785
const arrowWidth = Math.max(size / 2 + 2, 3);
786786
const arrowLength = 10;
787787
const arrowBeging = targetNode.size + arrowLength;
788-
let arrowPath = `M ${arrowBeging},0 L ${arrowBeging + arrowLength},-${arrowWidth} L ${
789-
arrowBeging + arrowLength
790-
},${arrowWidth} Z`;
788+
let arrowPath = `M ${arrowBeging},0 L ${arrowBeging + arrowLength},-${arrowWidth} L ${arrowBeging + arrowLength
789+
},${arrowWidth} Z`;
791790
let d = targetNode.size / 2 + arrowLength;
792791
if (edge.source === edge.target) {
793792
edge.type = 'loop';
@@ -811,11 +810,11 @@ const processNodesEdges = (
811810
lineDash,
812811
endArrow: arrowPath
813812
? {
814-
path: arrowPath,
815-
d,
816-
fill: stroke,
817-
strokeOpacity: 0,
818-
}
813+
path: arrowPath,
814+
d,
815+
fill: stroke,
816+
strokeOpacity: 0,
817+
}
819818
: false,
820819
};
821820
edge.labelCfg = {
@@ -1084,7 +1083,7 @@ const getMixedGraph = (
10841083
const vedge = {
10851084
source: edge.source,
10861085
target: targetClusterId,
1087-
id: `edge-${uniqueId()}`,
1086+
id: uniqueId('edge'),
10881087
label: '',
10891088
};
10901089
edges.push(vedge);
@@ -1093,7 +1092,7 @@ const getMixedGraph = (
10931092
const vedge = {
10941093
target: edge.target,
10951094
source: sourceClusterId,
1096-
id: `edge-${uniqueId()}`,
1095+
id: uniqueId('edge'),
10971096
label: '',
10981097
};
10991098
edges.push(vedge);
@@ -1152,7 +1151,7 @@ const generateNeighbors = (centerNodeModel, step, maxNeighborNumPerNode = 5) =>
11521151
const neighborNum = Math.ceil(Math.random() * maxNeighborNumPerNode);
11531152
for (let i = 0; i < neighborNum; i++) {
11541153
const neighborNode = {
1155-
id: uniqueId(),
1154+
id: uniqueId('node'),
11561155
clusterId,
11571156
level: 0,
11581157
colorSet: centerNodeModel.colorSet,
@@ -1162,7 +1161,7 @@ const generateNeighbors = (centerNodeModel, step, maxNeighborNumPerNode = 5) =>
11621161
const source = dire ? centerId : neighborNode.id;
11631162
const target = dire ? neighborNode.id : centerId;
11641163
const neighborEdge = {
1165-
id: uniqueId(),
1164+
id: uniqueId('edge'),
11661165
source,
11671166
target,
11681167
label: `${source}-${target}`,
@@ -1198,7 +1197,7 @@ const getExtractNodeMixedGraph = (
11981197
if (!aggregatedNodeMap[targetClusterId].expanded) {
11991198
// did not expand, create an virtual edge fromt he extract node to the cluster
12001199
currentUnproccessedData.edges.push({
1201-
id: uniqueId(),
1200+
id: uniqueId('edge'),
12021201
source: extractNodeId,
12031202
target: targetClusterId,
12041203
});
@@ -1211,7 +1210,7 @@ const getExtractNodeMixedGraph = (
12111210
if (!aggregatedNodeMap[sourceClusterId].expanded) {
12121211
// did not expand, create an virtual edge fromt he extract node to the cluster
12131212
currentUnproccessedData.edges.push({
1214-
id: uniqueId(),
1213+
id: uniqueId('edge'),
12151214
target: extractNodeId,
12161215
source: sourceClusterId,
12171216
});
@@ -1473,7 +1472,7 @@ fetch('https://gw.alipayobjects.com/os/antvdemo/assets/data/relations.json')
14731472
...clusterEdge,
14741473
size: Math.log(clusterEdge.count),
14751474
label: '',
1476-
id: `edge-${uniqueId()}`,
1475+
id: uniqueId('edge'),
14771476
};
14781477
if (cedge.source === cedge.target) {
14791478
cedge.type = 'loop';
@@ -1486,7 +1485,7 @@ fetch('https://gw.alipayobjects.com/os/antvdemo/assets/data/relations.json')
14861485

14871486
data.edges.forEach((edge) => {
14881487
edge.label = `${edge.source}-${edge.target}`;
1489-
edge.id = `edge-${uniqueId()}`;
1488+
edge.id = uniqueId('edge');
14901489
});
14911490

14921491
currentUnproccessedData = aggregatedData;

0 commit comments

Comments
 (0)