FIX:修复某些bug
This commit is contained in:
parent
32f403b5aa
commit
a7d9aed4ab
2
dist/sv.js
vendored
2
dist/sv.js
vendored
File diff suppressed because one or more lines are too long
@ -213,12 +213,29 @@ export class ModelConstructor {
|
|||||||
*/
|
*/
|
||||||
private createElement(sourceElement: SourceElement, elementName: string, groupName: string, layouterName: string, options: ElementOption): Element {
|
private createElement(sourceElement: SourceElement, elementName: string, groupName: string, layouterName: string, options: ElementOption): Element {
|
||||||
let element: Element = undefined,
|
let element: Element = undefined,
|
||||||
label = options.label? this.parserElementContent(sourceElement, options.label): '',
|
label: string | string[] = '',
|
||||||
id = elementName + '.' + sourceElement.id.toString();
|
id = elementName + '.' + sourceElement.id.toString();
|
||||||
|
|
||||||
|
if(options.label) {
|
||||||
|
if(Array.isArray(options.label)) {
|
||||||
|
label = options.label.map(item => {
|
||||||
|
let res = this.parserElementContent(sourceElement, item);
|
||||||
|
|
||||||
|
if(res === null || label === 'undefined') {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
label = this.parserElementContent(sourceElement, options.label);
|
||||||
|
|
||||||
if(label === null || label === 'undefined') {
|
if(label === null || label === 'undefined') {
|
||||||
label = '';
|
label = '';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
element = new Element(id, elementName, groupName, layouterName, sourceElement);
|
element = new Element(id, elementName, groupName, layouterName, sourceElement);
|
||||||
element.initProps(options);
|
element.initProps(options);
|
||||||
|
|||||||
@ -13,7 +13,7 @@ export interface G6NodeModel {
|
|||||||
type: string;
|
type: string;
|
||||||
size: number | [number, number];
|
size: number | [number, number];
|
||||||
anchorPoints: [number, number];
|
anchorPoints: [number, number];
|
||||||
label: string;
|
label: string | string[];
|
||||||
style: Style;
|
style: Style;
|
||||||
labelCfg: ElementLabelOption;
|
labelCfg: ElementLabelOption;
|
||||||
externalPointerId: string;
|
externalPointerId: string;
|
||||||
|
|||||||
@ -59,8 +59,9 @@ export default G6.registerNode('binary-tree-node', {
|
|||||||
getAnchorPoints() {
|
getAnchorPoints() {
|
||||||
return [
|
return [
|
||||||
[0.5, 0],
|
[0.5, 0],
|
||||||
[0.125, 0.5],
|
[0.875, 0.5],
|
||||||
[0.875, 0.5]
|
[0.5, 1],
|
||||||
|
[0.125, 0.5]
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -60,6 +60,7 @@ export default G6.registerNode('link-list-node', {
|
|||||||
[0.5, 0],
|
[0.5, 0],
|
||||||
[5 / 6, 0],
|
[5 / 6, 0],
|
||||||
[5 / 6, 0.5],
|
[5 / 6, 0.5],
|
||||||
|
[1, 0.5],
|
||||||
[5 / 6, 1],
|
[5 / 6, 1],
|
||||||
[0.5, 1],
|
[0.5, 1],
|
||||||
[0, 0.5]
|
[0, 0.5]
|
||||||
|
|||||||
@ -34,8 +34,43 @@ export default G6.registerNode('two-cell-node', {
|
|||||||
draggable: true
|
draggable: true
|
||||||
});
|
});
|
||||||
|
|
||||||
if (cfg.label) {
|
|
||||||
const style = (cfg.labelCfg && cfg.labelCfg.style) || {};
|
const style = (cfg.labelCfg && cfg.labelCfg.style) || {};
|
||||||
|
|
||||||
|
if (cfg.label) {
|
||||||
|
if(Array.isArray(cfg.label)) {
|
||||||
|
let tag = cfg.label[0], data = cfg.label[1];
|
||||||
|
|
||||||
|
group.addShape('text', {
|
||||||
|
attrs: {
|
||||||
|
x: width * (3 / 4),
|
||||||
|
y: height,
|
||||||
|
textAlign: 'center',
|
||||||
|
textBaseline: 'middle',
|
||||||
|
text: tag,
|
||||||
|
fill: style.fill || '#000',
|
||||||
|
fontSize: style.fontSize || 16,
|
||||||
|
cursor: cfg.style.cursor,
|
||||||
|
},
|
||||||
|
name: 'text',
|
||||||
|
draggable: true
|
||||||
|
});
|
||||||
|
|
||||||
|
group.addShape('text', {
|
||||||
|
attrs: {
|
||||||
|
x: width * (5 / 4),
|
||||||
|
y: height,
|
||||||
|
textAlign: 'center',
|
||||||
|
textBaseline: 'middle',
|
||||||
|
text: data,
|
||||||
|
fill: style.fill || '#000',
|
||||||
|
fontSize: style.fontSize || 16,
|
||||||
|
cursor: cfg.style.cursor,
|
||||||
|
},
|
||||||
|
name: 'text',
|
||||||
|
draggable: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
group.addShape('text', {
|
group.addShape('text', {
|
||||||
attrs: {
|
attrs: {
|
||||||
x: width * (3 / 4),
|
x: width * (3 / 4),
|
||||||
@ -51,15 +86,17 @@ export default G6.registerNode('two-cell-node', {
|
|||||||
draggable: true
|
draggable: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return wrapperRect;
|
return wrapperRect;
|
||||||
},
|
},
|
||||||
|
|
||||||
getAnchorPoints() {
|
getAnchorPoints() {
|
||||||
return [
|
return [
|
||||||
[0, 0.5],
|
[0.5, 0],
|
||||||
[3 / 4, 0.5],
|
[3 / 4, 0.5],
|
||||||
[0.5, 0]
|
[0.5, 1],
|
||||||
|
[0, 0.5]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -59,7 +59,7 @@ export class Layouter {
|
|||||||
item.set({
|
item.set({
|
||||||
x: pointerPosition[0],
|
x: pointerPosition[0],
|
||||||
y: pointerPosition[1],
|
y: pointerPosition[1],
|
||||||
rotation: angle
|
rotation: Math.sign(anchorVector[0]) * angle
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import { LayoutGroup } from "./Model/modelConstructor";
|
|
||||||
import { Element } from "./Model/modelData";
|
import { Element } from "./Model/modelData";
|
||||||
import { SourceElement } from "./sources";
|
import { SourceElement } from "./sources";
|
||||||
|
|
||||||
@ -38,7 +37,7 @@ export interface ElementOption {
|
|||||||
size: number | [number, number];
|
size: number | [number, number];
|
||||||
rotation: number;
|
rotation: number;
|
||||||
anchorPoints: [number, number];
|
anchorPoints: [number, number];
|
||||||
label: string;
|
label: string | string[];
|
||||||
labelOptions: ElementLabelOption;
|
labelOptions: ElementLabelOption;
|
||||||
style: Style;
|
style: Style;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user