Skip to content

Commit 50c6349

Browse files
[fix]知识图谱抖动效果处理
1 parent 7e6bf44 commit 50c6349

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
@@ -157,6 +157,7 @@
157157
"lodash.debounce": "^4.0.8",
158158
"lodash.difference": "^4.5.0",
159159
"lodash.remove": "^4.7.0",
160+
"lodash.throttle": "^4.1.1",
160161
"lodash.topairs": "4.3.0",
161162
"lodash.uniqby": "^4.7.0",
162163
"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
@@ -131,11 +133,9 @@ export class G6Render {
131133

132134
_getGraphConfig(config) {
133135
const animateConfig = {
134-
speed: 120,
135-
maxIteration: 83,
136-
tick: () => {
137-
this.refreshPositions();
138-
}
136+
speed: 150,
137+
maxIteration: 30,
138+
tick: throttle(this.refreshPositions.bind(this), 150)
139139
};
140140
const defaultLayout = {
141141
type: 'fruchterman',

src/common/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"lodash.topairs": "4.3.0",
2525
"lodash.uniqby": "^4.7.0",
2626
"lodash.clonedeep": "^4.5.0",
27+
"lodash.throttle": "^4.1.1",
2728
"mapv": "2.0.62",
2829
"node-forge": "^1.3.1",
2930
"rbush": "^2.0.2",

test/common/overlay/KnowledgeGraphSpec.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,22 @@ describe('KnowledgeGraph', () => {
537537
var graph = new KnowledgeGraph({ nodeLabelMaxWidth: 100, animate: false });
538538
expect(graph).not.toBeNull();
539539
expect(graph.data).not.toBeNull();
540+
expect(graph.config.layout.tick).toBeUndefined();
541+
expect(graph.config.layout.maxIteration).toBeUndefined();
542+
expect(graph.config.layout.speed).toBeUndefined();
540543
done();
541544
});
545+
546+
it('nodeLabelMaxWidth animate true', (done) => {
547+
var graph = new KnowledgeGraph({ animate: true });
548+
expect(graph).not.toBeNull();
549+
expect(graph.data).not.toBeNull();
550+
expect(graph.config.layout.tick).not.toBeUndefined();
551+
expect(graph.config.layout.maxIteration).not.toBeUndefined();
552+
expect(graph.config.layout.speed).not.toBeUndefined();
553+
done();
554+
});
555+
542556
it('expand collpase hidden Nodes', (done) => {
543557
var graph = new KnowledgeGraph();
544558
graph.setData(data);

0 commit comments

Comments
 (0)