Skip to content

Commit 061db9d

Browse files
[fix]知识图谱抖动效果处理
1 parent 6228d7e commit 061db9d

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import G6 from '@antv/g6';
22
import insertCss from 'insert-css';
3+
import throttle from 'lodash.throttle';
34
/**
45
* @private
56
* @class G6Render
@@ -132,10 +133,8 @@ export class G6Render {
132133
_getGraphConfig(config) {
133134
const animateConfig = {
134135
speed: 120,
135-
maxIteration: 83,
136-
tick: () => {
137-
this.refreshPositions();
138-
}
136+
maxIteration: 120,
137+
tick: throttle(this.refreshPositions.bind(this), 120)
139138
};
140139
const defaultLayout = {
141140
type: 'fruchterman',

src/common/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"lodash.topairs": "4.3.0",
2828
"lodash.uniqby": "^4.7.0",
2929
"lodash.clonedeep": "^4.5.0",
30+
"lodash.throttle": "^4.1.1",
3031
"mapv": "2.0.62",
3132
"node-forge": "^1.3.1",
3233
"rbush": "^2.0.2",

test/common/overlay/KnowledgeGraphSpec.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,18 @@ 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();
543+
done();
544+
});
545+
it('nodeLabelMaxWidth animate true', (done) => {
546+
var graph = new KnowledgeGraph({ animate: true });
547+
expect(graph).not.toBeNull();
548+
expect(graph.data).not.toBeNull();
549+
expect(graph.config.layout.tick).not.toBeUndefined();
550+
expect(graph.config.layout.maxIteration).not.toBeUndefined();
551+
expect(graph.config.layout.speed).not.toBeUndefined();
540552
done();
541553
});
542554
it('expand collpase hidden Nodes', (done) => {

0 commit comments

Comments
 (0)