test: minimap and bundling

This commit is contained in:
Yanyan-Wang 2020-02-25 23:38:31 +08:00 committed by Yanyan Wang
parent d6b8b6c3d5
commit 6f7c6f188e
4 changed files with 66 additions and 7 deletions

View File

@ -41,6 +41,7 @@ export default {
y: clientY,
};
this.graph.translate(dx, dy);
this.graph.paint();
},
onMouseDown(e: IG6GraphEvent) {
const self = this as any;

View File

@ -609,11 +609,9 @@ export default class Graph extends EventEmitter implements IGraph {
} else {
mat3.scale(matrix, matrix, [ratio, ratio]);
}
if (minZoom && matrix[0] < minZoom) {
return;
}
if (maxZoom && matrix[0] > maxZoom) {
if ((minZoom && matrix[0] < minZoom) || (maxZoom && matrix[0] > maxZoom)) {
this.setAutoPaint(autoPaint);
return;
}

View File

@ -412,7 +412,6 @@ export default class MiniMap extends Base {
if (!isRefresh) {
return;
}
console.log('update canvas')
// 如果是视口变换,也不刷新视图,但是需要重置视口大小和位置
if (this.get('viewportChange')) {

View File

@ -1971,7 +1971,7 @@ describe.only('plugins', () => {
],
};
it('minimap', () => {
it.only('minimap', () => {
const minimap = new G6.Minimap();
const graph = new Graph({
container: div,
@ -1985,6 +1985,67 @@ describe.only('plugins', () => {
});
graph.data(data);
graph.render();
graph.destroy();
});
it.only('minimap delegate', () => {
const minimap = new G6.Minimap({
width: 100,
height: 80,
type: 'delegate'
});
const graph = new Graph({
container: div,
width: 500,
height: 500,
renderer: 'svg',
plugins: [minimap],
modes: {
default: ['drag-node', 'drag-canvas', 'zoom-canvas']
}
});
graph.data(data);
graph.render();
graph.destroy();
});
it.only('minimap keyShape', () => {
const minimap = new G6.Minimap({
width: 100,
height: 80,
type: 'keyShape'
});
const graph = new Graph({
container: div,
width: 500,
height: 500,
renderer: 'svg',
plugins: [minimap],
modes: {
default: ['drag-node', 'drag-canvas', 'zoom-canvas']
}
});
data.nodes.forEach((node: any, i) => {
node.label = `node-${i}`;
});
graph.data(data);
graph.render();
graph.destroy();
});
it.only('edge bundling', () => {
const bundling = new G6.Bundling();
const graph = new Graph({
container: div,
width: 500,
height: 500,
renderer: 'svg',
plugins: [bundling]
});
graph.data(data);
graph.render();
setTimeout(() => {
bundling.bundling(data);
}, 5000);
// graph.destroy();
});
});