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,11 +213,28 @@ export class ModelConstructor {
|
||||
*/
|
||||
private createElement(sourceElement: SourceElement, elementName: string, groupName: string, layouterName: string, options: ElementOption): Element {
|
||||
let element: Element = undefined,
|
||||
label = options.label? this.parserElementContent(sourceElement, options.label): '',
|
||||
label: string | string[] = '',
|
||||
id = elementName + '.' + sourceElement.id.toString();
|
||||
|
||||
if(label === null || label === 'undefined') {
|
||||
label = '';
|
||||
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') {
|
||||
label = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
element = new Element(id, elementName, groupName, layouterName, sourceElement);
|
||||
|
||||
@ -13,7 +13,7 @@ export interface G6NodeModel {
|
||||
type: string;
|
||||
size: number | [number, number];
|
||||
anchorPoints: [number, number];
|
||||
label: string;
|
||||
label: string | string[];
|
||||
style: Style;
|
||||
labelCfg: ElementLabelOption;
|
||||
externalPointerId: string;
|
||||
|
||||
@ -59,8 +59,9 @@ export default G6.registerNode('binary-tree-node', {
|
||||
getAnchorPoints() {
|
||||
return [
|
||||
[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],
|
||||
[5 / 6, 0],
|
||||
[5 / 6, 0.5],
|
||||
[1, 0.5],
|
||||
[5 / 6, 1],
|
||||
[0.5, 1],
|
||||
[0, 0.5]
|
||||
|
||||
@ -34,22 +34,58 @@ export default G6.registerNode('two-cell-node', {
|
||||
draggable: true
|
||||
});
|
||||
|
||||
const style = (cfg.labelCfg && cfg.labelCfg.style) || {};
|
||||
|
||||
if (cfg.label) {
|
||||
const style = (cfg.labelCfg && cfg.labelCfg.style) || {};
|
||||
group.addShape('text', {
|
||||
attrs: {
|
||||
x: width * (3 / 4),
|
||||
y: height,
|
||||
textAlign: 'center',
|
||||
textBaseline: 'middle',
|
||||
text: cfg.label,
|
||||
fill: style.fill || '#000',
|
||||
fontSize: style.fontSize || 16,
|
||||
cursor: cfg.style.cursor,
|
||||
},
|
||||
name: 'text',
|
||||
draggable: true
|
||||
});
|
||||
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', {
|
||||
attrs: {
|
||||
x: width * (3 / 4),
|
||||
y: height,
|
||||
textAlign: 'center',
|
||||
textBaseline: 'middle',
|
||||
text: cfg.label,
|
||||
fill: style.fill || '#000',
|
||||
fontSize: style.fontSize || 16,
|
||||
cursor: cfg.style.cursor,
|
||||
},
|
||||
name: 'text',
|
||||
draggable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return wrapperRect;
|
||||
@ -57,9 +93,10 @@ export default G6.registerNode('two-cell-node', {
|
||||
|
||||
getAnchorPoints() {
|
||||
return [
|
||||
[0, 0.5],
|
||||
[0.5, 0],
|
||||
[3 / 4, 0.5],
|
||||
[0.5, 0]
|
||||
[0.5, 1],
|
||||
[0, 0.5]
|
||||
];
|
||||
}
|
||||
});
|
||||
@ -59,7 +59,7 @@ export class Layouter {
|
||||
item.set({
|
||||
x: pointerPosition[0],
|
||||
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 { SourceElement } from "./sources";
|
||||
|
||||
@ -38,7 +37,7 @@ export interface ElementOption {
|
||||
size: number | [number, number];
|
||||
rotation: number;
|
||||
anchorPoints: [number, number];
|
||||
label: string;
|
||||
label: string | string[];
|
||||
labelOptions: ElementLabelOption;
|
||||
style: Style;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user