fix:修复一些bug
This commit is contained in:
parent
ad9333bd3b
commit
66a084ba12
2
dist/sv.js
vendored
2
dist/sv.js
vendored
File diff suppressed because one or more lines are too long
@ -57,11 +57,10 @@ export class ModelConstructor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const options: LayoutGroupOptions = optionsTable[layouterName],
|
const options: LayoutGroupOptions = optionsTable[layouterName],
|
||||||
|
sourceData = layouter.sourcesPreprocess(sourceGroup.data),
|
||||||
elementOptions = options.element || { },
|
elementOptions = options.element || { },
|
||||||
pointerOptions = options.pointer || { };
|
pointerOptions = options.pointer || { };
|
||||||
|
|
||||||
const sourceData = layouter.sourcesPreprocess? layouter.sourcesPreprocess(sourceGroup.data): sourceGroup.data;
|
|
||||||
|
|
||||||
elementList = this.constructElements(elementOptions, name, sourceData, layouterName);
|
elementList = this.constructElements(elementOptions, name, sourceData, layouterName);
|
||||||
pointerList = this.constructPointers(pointerOptions, elementList);
|
pointerList = this.constructPointers(pointerOptions, elementList);
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,9 @@ import twoCellNode from "./RegisteredShape/twoCellNode";
|
|||||||
import { Vector } from "./Common/vector";
|
import { Vector } from "./Common/vector";
|
||||||
import indexedNode from "./RegisteredShape/indexedNode";
|
import indexedNode from "./RegisteredShape/indexedNode";
|
||||||
import { EngineOptions, Layouter } from "./options";
|
import { EngineOptions, Layouter } from "./options";
|
||||||
|
import { LayoutGroup } from "./Model/modelConstructor";
|
||||||
|
import { SourceElement } from "./sources";
|
||||||
|
import { Element } from "./Model/modelData";
|
||||||
|
|
||||||
|
|
||||||
export interface StructV {
|
export interface StructV {
|
||||||
@ -54,7 +57,24 @@ SV.registeredShape = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
SV.registerShape = G6.registerNode;
|
SV.registerShape = G6.registerNode;
|
||||||
SV.registerLayouter = function(name: string, layouter) {
|
SV.registerLayouter = function(name: string, layouter: Layouter) {
|
||||||
|
|
||||||
|
if(typeof layouter.sourcesPreprocess !== 'function') {
|
||||||
|
layouter.sourcesPreprocess = function(data: SourceElement[]): SourceElement[] {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(typeof layouter.defineLeakRule !== 'function') {
|
||||||
|
layouter.defineLeakRule = function(elements: Element[]): Element[] {
|
||||||
|
return elements;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(typeof layouter.defineOptions !== 'function' || typeof layouter.layout !== 'function') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SV.registeredLayouter[name] = layouter;
|
SV.registeredLayouter[name] = layouter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -26,6 +26,9 @@ export class Container {
|
|||||||
this.interactionOptions = engine.interactionOptions;
|
this.interactionOptions = engine.interactionOptions;
|
||||||
this.prevModelList = [];
|
this.prevModelList = [];
|
||||||
|
|
||||||
|
const g6Plugins = [];
|
||||||
|
|
||||||
|
if(g6Options.tooltip) {
|
||||||
const tooltip = new SV.G6.Tooltip({
|
const tooltip = new SV.G6.Tooltip({
|
||||||
offsetX: 10,
|
offsetX: 10,
|
||||||
offsetY: 20,
|
offsetY: 20,
|
||||||
@ -46,12 +49,15 @@ export class Container {
|
|||||||
itemTypes: ['node']
|
itemTypes: ['node']
|
||||||
});
|
});
|
||||||
|
|
||||||
|
g6Plugins.push(tooltip);
|
||||||
|
}
|
||||||
|
|
||||||
this.renderer = new Renderer(engine, DOMContainer, {
|
this.renderer = new Renderer(engine, DOMContainer, {
|
||||||
...g6Options,
|
fitCenter: g6Options.fitCenter,
|
||||||
modes: {
|
modes: {
|
||||||
default: this.initBehaviors(this.engine.optionsTable)
|
default: this.initBehaviors(this.engine.optionsTable)
|
||||||
},
|
},
|
||||||
plugins: [tooltip]
|
plugins: g6Plugins
|
||||||
});
|
});
|
||||||
|
|
||||||
this.afterInitRenderer();
|
this.afterInitRenderer();
|
||||||
|
|||||||
@ -25,17 +25,17 @@ export class ViewManager {
|
|||||||
constructor(engine: Engine, DOMContainer: HTMLElement) {
|
constructor(engine: Engine, DOMContainer: HTMLElement) {
|
||||||
this.engine = engine;
|
this.engine = engine;
|
||||||
this.layouter = new Layouter(engine);
|
this.layouter = new Layouter(engine);
|
||||||
this.mainContainer = new MainContainer(engine, DOMContainer);
|
this.mainContainer = new MainContainer(engine, DOMContainer, { tooltip: true });
|
||||||
this.prevLayoutGroupTable = null;
|
this.prevLayoutGroupTable = null;
|
||||||
|
|
||||||
const options: EngineOptions = this.engine.engineOptions;
|
const options: EngineOptions = this.engine.engineOptions;
|
||||||
|
|
||||||
if(options.freedContainer) {
|
if(options.freedContainer) {
|
||||||
this.freedContainer = new FreedContainer(engine, options.freedContainer, { fitCenter: true });
|
this.freedContainer = new FreedContainer(engine, options.freedContainer, { fitCenter: true, tooltip: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
if(options.leakContainer) {
|
if(options.leakContainer) {
|
||||||
this.leakContainer = new LeakContainer(engine, options.leakContainer, { fitCenter: true });
|
this.leakContainer = new LeakContainer(engine, options.leakContainer, { fitCenter: true, tooltip: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
this.shadowG6Instance = new SV.G6.Graph({
|
this.shadowG6Instance = new SV.G6.Graph({
|
||||||
@ -119,11 +119,16 @@ export class ViewManager {
|
|||||||
|
|
||||||
if(curGroup) {
|
if(curGroup) {
|
||||||
elements = prevGroup.element.filter(item => !curGroup.element.find(n => n.id === item.id)).filter(item => item.freed === false),
|
elements = prevGroup.element.filter(item => !curGroup.element.find(n => n.id === item.id)).filter(item => item.freed === false),
|
||||||
links = prevGroup.link.filter(item => !curGroup.link.find(n => n.id === item.id)),
|
links = prevGroup.link.filter(item => !curGroup.link.find(n => n.id === item.id));
|
||||||
elementIds = elements.map(item => item.id);
|
elements = curGroup.layouter.defineLeakRule(elements);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
elements = prevGroup.element;
|
||||||
|
links = prevGroup.link;
|
||||||
}
|
}
|
||||||
|
|
||||||
elements.forEach(item => {
|
elements.forEach(item => {
|
||||||
|
elementIds.push(item.id);
|
||||||
item.set('style', {
|
item.set('style', {
|
||||||
fill: '#ccc'
|
fill: '#ccc'
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import { LayoutGroup } from "./Model/modelConstructor";
|
||||||
import { Element } from "./Model/modelData";
|
import { Element } from "./Model/modelData";
|
||||||
import { SourceElement } from "./sources";
|
import { SourceElement } from "./sources";
|
||||||
|
|
||||||
@ -118,7 +119,8 @@ export interface EngineOptions {
|
|||||||
export interface Layouter {
|
export interface Layouter {
|
||||||
defineOptions(): LayoutGroupOptions;
|
defineOptions(): LayoutGroupOptions;
|
||||||
sourcesPreprocess?(sources: SourceElement[]): SourceElement[];
|
sourcesPreprocess?(sources: SourceElement[]): SourceElement[];
|
||||||
|
defineLeakRule?(elements: Element[]): Element[];
|
||||||
layout(elements: Element[], layoutOptions: LayoutOptions);
|
layout(elements: Element[], layoutOptions: LayoutOptions);
|
||||||
[key: string]: Function;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user