如何使用 diagrams.net 的 CSV 导入在连接器中启用和使用占位符

How do I enable and use placeholders in connectors using CSV import of diagrams.net

我有一个正在使用 CSV 构建的图表。我已经弄清楚如何在形状标签中使用占位符。但是我也希望能够在连接中使用占位符。我注意到在导入已有内容后,连接对象没有在 Edit Data 部分启用 Placeholder 设置。有没有办法从 connect json 启用它?我想后续问题也是如何将自定义 data 设置为连接。

我对这个问题的主要目标是,我可以使用 fromto 向我的连接标签添加一种数据流 ID,这样它就可以像 DF1-2.

这是我目前的情况:

## My Dataflow
# stylename: shapeType
# styles: { "docker-service": "shape=rectangle;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;"}
# labelname: labelType
# labels: { "process": "%name%<br><i style=\"color:gray;\">P%Pnum%</i>", \
#           "data-flow": "tls 1.2 %dataFlowNum%", \
#           "regular": "%name%"}
# identity: gid
# namespace: jay-
# parent: rparent
# parentstyle: shape=rectangle;html=1;dashed=1;align=left;verticalAlign=bottom;fillColor=#FFE6CC;strokeColor=#D79B00;
# connect: {"from":"refstls", "to":"gid", "invert":true, "label":"TLS v1.2", "style":"curved=0;endFill=1;fontSize=11;endArrow=blockThin;endFill=1;"}
# width: auto
# height: auto
# padding: 15
# nodespacing: 40
# levelspacing: 100
# edgespacing: 40
# layout: auto
## CSV starts under this line
gid,name,rparent,Pnum,labelType,shapeType,refstls
0,Network,,,regular,docker-service,,
1,docker ingress,0,1,process,docker-service,,
2,service1,0,2,process,docker-service,1,
3,service2,0,3,process,docker-service,1
4,service3,0,4,process,docker-service,1

目前,diagrams.net 不支持该功能,但请随时在此处投票并跟踪此功能请求: https://trello.com/c/y9IAQ9kJ/96-allow-custom-data-on-connections-when-importing-csvs

谢谢,

我正在查看解释连接器的 CSV 示例评论,并注意到前几天我错过了一些似乎在限制条件下做我想做的事情。

tolabelfromlabel可以满足我的需求

optional fromlabel and tolabel can be used to name the column that contains the text for the label in the edges source or target (invert ignored).

基于我的示例的解决方案是:

## My Dataflow
# stylename: shapeType
# styles: { "docker-service": "shape=rectangle;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;"}
# labelname: labelType
# labels: { "process": "%name%<br><i style=\"color:gray;\">P%Pnum%</i>", \
#           "data-flow": "tls 1.2 %dataFlowNum%", \
#           "regular": "%name%"}
# identity: gid
# namespace: jay-
# parent: rparent
# parentstyle: shape=rectangle;html=1;dashed=1;align=left;verticalAlign=bottom;fillColor=#FFE6CC;strokeColor=#D79B00;
# connect: {"from":"refstls", "to":"gid", "invert":true,"fromlabel":"Pnum","tolabel":"Pnum", "label":"-", "style":"curved=0;endFill=1;fontSize=11;endArrow=blockThin;endFill=1"}
# width: auto
# height: auto
# padding: 15
# nodespacing: 40
# levelspacing: 100
# edgespacing: 40
# layout: auto
## CSV starts under this line
gid,name,rparent,Pnum,labelType,shapeType,refstls
0,Network,,,regular,docker-service,,
1,docker ingress,0,1,process,docker-service,,
2,service1,0,2,process,docker-service,1,
3,service2,0,3,process,docker-service,1
4,service3,0,4,process,docker-service,1

此方法的主要缺点是未考虑 "invert"。