mxgraph 中有泳道示例,但它不是自动的。所以我以graphlayout的例子为基础,做了一些改动:
- 始终使用 mxSwimlaneLayout
- 从泳道示例中获取泳道单元样式
- 创建了两条泳道
- 将它们用作顶点的父级
以下是我创建泳道的方法:
var lane1 = graph.insertVertex(parent, null, 'Lane 1', 0, 0, 1000, 100, 'swimlane');
var lane2 = graph.insertVertex(parent, null, 'Lane 2', 0, 100, 1000, 100, 'swimlane');
// use as parent...
var v1 = graph.insertVertex(lane1, null, 'A', 0, 0, w, h);
并执行布局:
layout.orientation = mxConstants.DIRECTION_WEST;
layout.resizeParent = true;
layout.execute(parent, [lane1, lane2]);
这是测试页。
现在,这里有两个问题:
- 节点未放置在通道内;似乎根本不尊重车道。如何进行布局以将节点放置在适当的通道内?像父母一样划清界限似乎是不够的。
- 我以为 WEST 会在左边建立图表,但事实恰恰相反...... NORTH 也会下降......为什么?