mirror of
https://gitee.com/antv/g6.git
synced 2024-12-04 12:49:04 +08:00
fix: resolve miniapp errors
This commit is contained in:
parent
2c0eb297fb
commit
afc11e125b
@ -125,7 +125,7 @@ const singleEdge: ShapeOptions = {
|
||||
stroke: cfg.color,
|
||||
};
|
||||
const shape =
|
||||
group.find(element => element.get('className') === 'edge-shape') || item.getKeyShape();
|
||||
group.find((element) => element.get('className') === 'edge-shape') || item.getKeyShape();
|
||||
|
||||
const { size } = cfg;
|
||||
cfg = this.getPathPoints!(cfg);
|
||||
@ -178,7 +178,7 @@ const singleEdge: ShapeOptions = {
|
||||
const labelPosition = labelCfg.position || this.labelPosition; // 文本的位置用户可以传入
|
||||
const style: LabelStyle = {};
|
||||
|
||||
const pathShape = group && group.find(element => element.get('className') === CLS_SHAPE);
|
||||
const pathShape = group && group.find((element) => element.get('className') === CLS_SHAPE);
|
||||
|
||||
// 不对 pathShape 进行判空,如果线不存在,说明有问题了
|
||||
let pointPercent;
|
||||
@ -247,7 +247,7 @@ const singleEdge: ShapeOptions = {
|
||||
if (isNil(labelCfg.autoRotate)) autoRotate = this.labelAutoRotate;
|
||||
else autoRotate = labelCfg.autoRotate;
|
||||
|
||||
const pathShape = group && group.find(element => element.get('className') === CLS_SHAPE);
|
||||
const pathShape = group && group.find((element) => element.get('className') === CLS_SHAPE);
|
||||
|
||||
// 不对 pathShape 进行判空,如果线不存在,说明有问题了
|
||||
let pointPercent;
|
||||
@ -349,7 +349,7 @@ const singleEdge: ShapeOptions = {
|
||||
drawLabel(cfg: EdgeConfig, group: IGroup): IShape {
|
||||
const { labelCfg: defaultLabelCfg } = this.options as ModelConfig;
|
||||
let defaultFontFamily;
|
||||
if (typeof window !== 'undefined' && window.getComputedStyle)
|
||||
if (typeof window !== 'undefined' && typeof window.getComputedStyle !== 'undefined')
|
||||
defaultFontFamily =
|
||||
window.getComputedStyle(document.body, null).getPropertyValue('font-family') ||
|
||||
'Arial, sans-serif';
|
||||
|
@ -327,10 +327,10 @@ export default class ItemController {
|
||||
const keyShape = (combo as ICombo).getKeyShape();
|
||||
if (!keyShape || keyShape.destroyed) return;
|
||||
(combo as ICombo).getShapeCfg(model); // 更新 combo 缓存的 size
|
||||
this.updateComboEdges(combo as ICombo)
|
||||
this.updateComboEdges(combo as ICombo);
|
||||
}, 201);
|
||||
} else {
|
||||
this.updateComboEdges(combo as ICombo)
|
||||
this.updateComboEdges(combo as ICombo);
|
||||
}
|
||||
}
|
||||
|
||||
@ -636,7 +636,6 @@ export default class ItemController {
|
||||
item.changeVisibility(visible);
|
||||
|
||||
if (item.getType && item.getType() === NODE) {
|
||||
|
||||
const edges = (item as INode).getEdges();
|
||||
each(edges, (edge: IEdge) => {
|
||||
// 若隐藏节点,则将与之关联的边也隐藏
|
||||
|
@ -42,7 +42,7 @@ export default abstract class LayoutController {
|
||||
|
||||
const pipes = layoutCfg.pipes;
|
||||
if (Array.isArray(pipes)) {
|
||||
return pipes.map((pipe) => pipe?.type || "");
|
||||
return pipes.map((pipe) => pipe?.type || '');
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -52,7 +52,7 @@ export default abstract class LayoutController {
|
||||
const current = this.getLayoutCfgType(cfg);
|
||||
// already has pipes
|
||||
if (Array.isArray(this.layoutType)) {
|
||||
return this.layoutType.every((type, index) => type === current[index])
|
||||
return this.layoutType.every((type, index) => type === current[index]);
|
||||
}
|
||||
|
||||
return cfg?.type === this.layoutType;
|
||||
@ -151,7 +151,7 @@ export default abstract class LayoutController {
|
||||
const comboLength = comboItems.length;
|
||||
for (let i = 0; i < comboLength; i++) {
|
||||
const comboItem = comboItems[i];
|
||||
if (comboItem.destroyed ) continue;
|
||||
if (comboItem.destroyed) continue;
|
||||
const model = comboItem.getModel();
|
||||
if (!comboItem.isVisible()) {
|
||||
hiddenEdges.push(model);
|
||||
@ -159,7 +159,15 @@ export default abstract class LayoutController {
|
||||
}
|
||||
combos.push(model);
|
||||
}
|
||||
return { nodes, hiddenNodes, edges, hiddenEdges, combos, hiddenCombos, comboEdges } as GraphData;
|
||||
return {
|
||||
nodes,
|
||||
hiddenNodes,
|
||||
edges,
|
||||
hiddenEdges,
|
||||
combos,
|
||||
hiddenCombos,
|
||||
comboEdges,
|
||||
} as GraphData;
|
||||
}
|
||||
|
||||
protected reLayoutMethod(layoutMethod, layoutCfg): Promise<void> {
|
||||
@ -171,7 +179,7 @@ export default abstract class LayoutController {
|
||||
layoutCfg.onLayoutEnd = () => {
|
||||
graph.emit('aftersublayout', { type: layoutType });
|
||||
reslove();
|
||||
}
|
||||
};
|
||||
|
||||
layoutMethod.init(this.data);
|
||||
if (layoutType === 'force') {
|
||||
@ -206,11 +214,13 @@ export default abstract class LayoutController {
|
||||
start = start.then(() => this.reLayoutMethod(layoutMethod, currentCfg));
|
||||
});
|
||||
|
||||
start.then(() => {
|
||||
if (layoutCfg.onAllLayoutEnd) layoutCfg.onAllLayoutEnd();
|
||||
}).catch((error) => {
|
||||
console.warn('relayout failed', error);
|
||||
});
|
||||
start
|
||||
.then(() => {
|
||||
if (layoutCfg.onAllLayoutEnd) layoutCfg.onAllLayoutEnd();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.warn('relayout failed', error);
|
||||
});
|
||||
}
|
||||
|
||||
// 筛选参与布局的nodes和edges
|
||||
@ -237,14 +247,14 @@ export default abstract class LayoutController {
|
||||
}, {});
|
||||
edegsFilter = (edge) => {
|
||||
return nodesMap[edge.source] && nodesMap[edge.target];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
nodes: nodes.filter(nodesFilter),
|
||||
edges: edges.filter(edegsFilter),
|
||||
...rest
|
||||
}
|
||||
...rest,
|
||||
};
|
||||
}
|
||||
|
||||
protected getLayoutBBox(nodes) {
|
||||
@ -261,13 +271,13 @@ export default abstract class LayoutController {
|
||||
const groupNodes = Object.values(groupBy(nodes, 'layoutOrder'));
|
||||
return {
|
||||
groupNodes,
|
||||
layoutNodes
|
||||
}
|
||||
layoutNodes,
|
||||
};
|
||||
}
|
||||
|
||||
// 控制布局动画
|
||||
// eslint-disable-next-line class-methods-use-this
|
||||
public layoutAnimate() { }
|
||||
public layoutAnimate() {}
|
||||
|
||||
// 将当前节点的平均中心移动到原点
|
||||
public moveToZero() {
|
||||
|
Loading…
Reference in New Issue
Block a user