diff --git a/cypress/platform/knsv.html b/cypress/platform/knsv.html
index 9fe9f4e19..8ae25a819 100644
--- a/cypress/platform/knsv.html
+++ b/cypress/platform/knsv.html
@@ -29,35 +29,27 @@
stateDiagram
- direction LR
- state A {
- direction BT
- a --> b
- }
- state C {
- direction RL
- c --> d
- }
- A --> C
-
-
- %%{int:{
-"themeVariables": {
- "transitionColor":"red",
- "labelColor":"yellow",
- "transitionLabelColor":"blue",
- "stateBkg":"green",
- "compositeBackground":"pink",
- "altBackground":"purple",
- "clusterTitleBackground":"blue",
- "compositeBorder":"red"
-}}}%%
-stateDiagram
- state CompositeState {
- state AnotherCompositeState {
- AnotherState --> YetANotherState:a label
+ state CompositeState {
+ YourState123456789012345123456789123456789012345123456789123456789012345123456789123456789012345123456789 --> MyState:a label
}
-}
+
+
+
+flowchart
+subgraph CompositeState
+ subgraph AnotherCompositeStateCompositeStateCompositeStateCompositeState
+ YourState --a label--> MyState
+ end
+
+end
+
+
+stateDiagram-v2
+ state CompositeState {
+ state AnotherCompositeState1234567890 {
+ YourState
+ }
+ }
@@ -77,7 +69,7 @@ sequenceDiagram
theme: 'default',
arrowMarkerAbsolute: true,
// themeCSS: '.edgePath .path {stroke: red;} .arrowheadPath {fill: red;}',
- logLevel: 5,
+ logLevel: 2,
flowchart: { nodeSpacing: 10, curve: 'cardinal', htmlLabels: true },
htmlLabels: true,
// gantt: { axisFormat: '%m/%d/%Y' },
diff --git a/src/dagre-wrapper/clusters.js b/src/dagre-wrapper/clusters.js
index 8f1ad8780..25697f416 100644
--- a/src/dagre-wrapper/clusters.js
+++ b/src/dagre-wrapper/clusters.js
@@ -136,7 +136,11 @@ const roundedWithTitle = (parent, node) => {
const padding = 0 * node.padding;
const halfPadding = padding / 2;
- const width = node.width > bbox.width ? node.width : bbox.width + node.padding;
+ const width =
+ node.width > bbox.width + node.padding ? node.width + node.padding : bbox.width + node.padding;
+ if (node.width <= bbox.width + node.padding) {
+ node.diff = (bbox.width - node.width) / 2;
+ }
// center the rect around its coordinate
rect
@@ -163,7 +167,6 @@ const roundedWithTitle = (parent, node) => {
);
const rectBox = rect.node().getBBox();
- node.width = rectBox.width;
node.height = rectBox.height;
node.intersect = function(point) {
@@ -227,7 +230,7 @@ export const clear = () => {
};
export const positionCluster = node => {
- log.info('Position cluster');
+ log.info('Position cluster (' + node.id + ', ' + node.x + ', ' + node.y + ')');
const el = clusterElems[node.id];
el.attr('transform', 'translate(' + node.x + ', ' + node.y + ')');
diff --git a/src/dagre-wrapper/index.js b/src/dagre-wrapper/index.js
index 04fe05f8b..2793c1dfd 100644
--- a/src/dagre-wrapper/index.js
+++ b/src/dagre-wrapper/index.js
@@ -50,12 +50,15 @@ const recursiveRender = (_elem, graph, diagramtype, parentCluster) => {
log.info('(Insert) Node XXX' + v + ': ' + JSON.stringify(graph.node(v)));
if (node && node.clusterNode) {
// const children = graph.children(v);
- log.info('Cluster identified', v, node, graph.node(v));
- const newEl = recursiveRender(nodes, node.graph, diagramtype, graph.node(v));
+ log.info('Cluster identified', v, node.width, graph.node(v));
+ const o = recursiveRender(nodes, node.graph, diagramtype, graph.node(v));
+ const newEl = o.elem;
updateNodeBounds(node, newEl);
+ node.diff = o.diff || 0;
+ log.info('Node nounds ', v, node, node.width, node.x, node.y);
setNodeElem(newEl, node);
- log.warn('Recursive render complete', newEl, node);
+ log.warn('Recursive render complete ', newEl, node);
} else {
if (graph.children(v).length > 0) {
// This is a cluster but not to be rendered recusively
@@ -95,6 +98,7 @@ const recursiveRender = (_elem, graph, diagramtype, parentCluster) => {
dagre.layout(graph);
log.info('Graph after layout:', graphlib.json.write(graph));
// Move the nodes to the correct place
+ let diff = 0;
sortNodesByHierarchy(graph).forEach(function(v) {
const node = graph.node(v);
log.info('Position ' + v + ': ' + JSON.stringify(graph.node(v)));
@@ -132,7 +136,14 @@ const recursiveRender = (_elem, graph, diagramtype, parentCluster) => {
positionEdgeLabel(edge, paths);
});
- return elem;
+ graph.nodes().forEach(function(v) {
+ const n = graph.node(v);
+ log.info(v, n.type, n.diff);
+ if (n.type === 'group') {
+ diff = n.diff;
+ }
+ });
+ return { elem, diff };
};
export const render = (elem, graph, markers, diagramtype, id) => {
diff --git a/src/dagre-wrapper/nodes.js b/src/dagre-wrapper/nodes.js
index cc4a98f26..bd14c630c 100644
--- a/src/dagre-wrapper/nodes.js
+++ b/src/dagre-wrapper/nodes.js
@@ -935,15 +935,17 @@ export const positionNode = node => {
const el = nodeElems[node.id];
log.trace(
'Transforming node',
+ node.diff,
node,
- 'translate(' + (node.x - node.width / 2 - 5) + ', ' + (node.y - node.height / 2 - 5) + ')'
+ 'translate(' + (node.x - node.width / 2 - 5) + ', ' + node.width / 2 + ')'
);
const padding = 8;
+ const diff = node.diff || 0;
if (node.clusterNode) {
el.attr(
'transform',
'translate(' +
- (node.x - node.width / 2 - padding) +
+ (node.x + diff - node.width / 2) +
', ' +
(node.y - node.height / 2 - padding) +
')'
@@ -951,4 +953,5 @@ export const positionNode = node => {
} else {
el.attr('transform', 'translate(' + node.x + ', ' + node.y + ')');
}
+ return diff;
};