Skip to content

Commit dada6d5

Browse files
[fix]知识图谱抖动效果处理
1 parent 628af31 commit dada6d5

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@
148148
"lodash.clonedeep": "^4.5.0",
149149
"lodash.difference": "^4.5.0",
150150
"lodash.remove": "^4.7.0",
151+
"lodash.throttle": "^4.1.1",
151152
"lodash.topairs": "4.3.0",
152153
"lodash.uniqby": "^4.7.0",
153154
"mapbox-gl": "1.13.2",

src/common/overlay/knowledge-graph/G6Render.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import G6 from '@antv/g6';
22
import insertCss from 'insert-css';
3+
import throttle from 'lodash.throttle';
4+
35
/**
46
* @private
57
* @class G6Render
@@ -112,11 +114,9 @@ export class G6Render {
112114

113115
_getGraphConfig(config) {
114116
const animateConfig = {
115-
speed: 120,
116-
maxIteration: 83,
117-
tick: () => {
118-
this.refreshPositions()
119-
}
117+
speed: 150,
118+
maxIteration: 30,
119+
tick: throttle(this.refreshPositions.bind(this), 150)
120120
};
121121
const defaultLayout = {
122122
type: 'fruchterman',

src/common/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"lodash.topairs": "4.3.0",
2323
"lodash.uniqby": "^4.7.0",
2424
"lodash.clonedeep": "^4.5.0",
25+
"lodash.throttle": "^4.1.1",
2526
"mapv": "2.0.62",
2627
"flatgeobuf": "3.31.1",
2728
"rbush": "^2.0.2",

test/common/overlay/KnowledgeGraphSpec.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,22 @@ describe('KnowledgeGraph', () => {
381381
var graph = new KnowledgeGraph({ nodeLabelMaxWidth: 100, animate: false });
382382
expect(graph).not.toBeNull();
383383
expect(graph.data).not.toBeNull();
384+
expect(graph.config.layout.tick).toBeUndefined();
385+
expect(graph.config.layout.maxIteration).toBeUndefined();
386+
expect(graph.config.layout.speed).toBeUndefined();
384387
done();
385388
});
389+
390+
it('nodeLabelMaxWidth animate true', (done) => {
391+
var graph = new KnowledgeGraph({ animate: true });
392+
expect(graph).not.toBeNull();
393+
expect(graph.data).not.toBeNull();
394+
expect(graph.config.layout.tick).not.toBeUndefined();
395+
expect(graph.config.layout.maxIteration).not.toBeUndefined();
396+
expect(graph.config.layout.speed).not.toBeUndefined();
397+
done();
398+
});
399+
386400
it('expand collpase hidden Nodes', (done) => {
387401
var graph = new KnowledgeGraph();
388402
graph.setData(data);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy