当 mxHierarchicalLayout
与 strokeWidth > 1
一起使用时,所有最顶部和最左侧顶点的边框将无法正确显示。请参见下面的屏幕截图:
那是因为边框宽度不计入总顶点高度/宽度。
是否可以像 box-sizing: border-box;
一样为 CSS 设置 mxGraph
box sizing 模型?
如果不是,是否可以在布局引擎布局后将整个图形上下文向下或向左移动?
最佳答案
我认为边框绘制正确,但问题是最左边和最上面顶点的边框被隐藏了,因为它们被放置在 Canvas “后面”
,所以解决方法是根据您的需要将整个图表稍微移动到底部和右侧
。执行此操作的代码:
let layout = new mxHierarchicalLayout(graph);
layout.execute(graph.getDefaultParent());
graph.model.beginUpdate();
let children = graph.getChildCells();
graph.moveCells(children, undefined , 20); // assuming you want to "move your graph 20px to the bottom"
graph.model.endUpdate();
您可以使用相同的函数水平
移动您的图形(左右),检查
mxGraph.js
的moveCells
函数
mxGraph.prototype.moveCells = function(单元格、dx、dy、克隆、目标、evt、映射)
关于javascript - 如何为 mxGraph 顶点设置框大小模型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57361314/