javascript - 如何为 mxGraph 顶点设置框大小模型?

标签 javascript css flowchart mxgraph

mxHierarchicalLayoutstrokeWidth > 1 一起使用时,所有最顶部和最左侧顶点的边框将无法正确显示。请参见下面的屏幕截图:

enter image description here

那是因为边框宽度不计入总顶点高度/宽度。

是否可以像 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.jsmoveCells函数

mxGraph.prototype.moveCells = function(单元格、dx、dy、克隆、目标、evt、映射)

关于javascript - 如何为 mxGraph 顶点设置框大小模型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57361314/

相关文章:

javascript - css3 动画链接工作奇怪

html - Bootstrap 3 标题颜色不均匀

javascript - 在 HTML5/js/PHP/CSS 中是否有一种标准的编程方式来创建可重用的对象?

python - ryu 在将流添加到交换机后使用交换机处理数据包

graphviz - Graphviz DOT 文件中的多个图形

javascript - 如何让这样的代码在 JsFiddle.net 中运行?

javascript - 函数看不到 JSON 对象(javascript、jQuery)

javascript - 如何将连接到外部数据库的外部 php 文件中的数据发送到我的扩展程序的 content-script.js?

javascript - 将固定侧边栏停止在页脚处 - 防止重叠

flowchart - 数据流程图和流程图有什么区别?