如何为使用CSV格式生成的draw.io图赋予唯一的行名?

问题描述 投票:0回答:1

我正在使用示例csv生成网络图。我需要命名将一个组件连接到另一组件的线。

在示例行中,以下代码生成:

# connect: {"from": "user", "to": "name", "invert": true, "label": "", \
#          "style": "curved=1;endArrow=blockThin;endFill=1;fontSize=11;"}
# connect: {"from": "refs", "to": "id", "style": "curved=1;fontSize=11;"}

示例csv为:

##
## Example CSV import. Use ## for comments and # for configuration. Paste CSV below.
## The following names are reserved and should not be used (or ignored):
## id, tooltip, placeholder(s), link and label (see below)
##
#
## Node label with placeholders and HTML.
## Default is '%name_of_first_column%'.
#
# label: %name%<br>Hostname: <i style="color:gray;">%hostname%</i><br>IP: <i style="font-style: normal;color:gray;">%ip%</i><br>Zone: <i style="color:gray;">%zone%</i>
#
## Node style (placeholders are replaced once).
## Default is the current style for nodes.
#
# style: label;image=%image%;whiteSpace=wrap;html=1;rounded=1;fillColor=%fill%;strokeColor=%stroke%;
#
## Uses the given column name as the identity for cells (updates existing cells).
## Default is no identity (empty value or -).
#
# identity: -
#
## Connections between rows ("from": source colum, "to": target column).
## Label, style and invert are optional. Defaults are '', current style and false.
## In addition to label, an 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).
## The label is concatenated in the form fromlabel + label + tolabel if all are defined.
## The target column may contain a comma-separated list of values.
## Multiple connect entries are allowed.
#
# connect: {"from": "user", "to": "name", "invert": true, "label": "", \
#          "style": "curved=1;endArrow=blockThin;endFill=1;fontSize=11;"}
# connect: {"from": "refs", "to": "id", "style": "curved=1;fontSize=11;"}
#
## Node x-coordinate. Possible value is a column name. Default is empty. Layouts will
## override this value.
#
# left: 
#
## Node y-coordinate. Possible value is a column name. Default is empty. Layouts will
## override this value.
#
# top: 
#
## Node width. Possible value is a number (in px), auto or an @ sign followed by a column
## name that contains the value for the width. Default is auto.
#
# width: auto
#
## Node height. Possible value is a number (in px), auto or an @ sign followed by a column
## name that contains the value for the height. Default is auto.
#
# height: auto
#
## Padding for autosize. Default is 0.
#
# padding: -12
#
## Comma-separated list of ignored columns for metadata. (These can be
## used for connections and styles but will not be added as metadata.)
#
# ignore: id,image,fill,stroke
#
## Column to be renamed to link attribute (used as link).
#
# link: url
#
## Spacing between nodes. Default is 40.
#
# nodespacing: 40
#
## Spacing between parallel edges. Default is 40.
#
# edgespacing: 40
#
## Name of layout. Possible values are auto, none, verticaltree, horizontaltree,
## verticalflow, horizontalflow, organic, circle. Default is auto.
#
# layout: horizontalflow
#
## ---- CSV below this line. First line are column names. ----
name,hostname,id,zone,ip,user,email,fill,stroke,refs,url,image
A,Users1,a,zone0,10.1.1.1,,[email protected],#dae8fc,#6c8ebf,,https://users1.domain.com,https://cdn2.iconfinder.com/data/icons/office-icon-set-3/512/users.png
B,Users2,b,zone0,10.1.1.2,,[email protected],#dae8fc,#6c8ebf,,https://users2.domain.com,https://cdn2.iconfinder.com/data/icons/office-icon-set-3/512/users.png
C,Users3,c,zone2,10.1.1.3,,[email protected],#dae8fc,#6c8ebf,,https://users3.domain.com,https://cdn2.iconfinder.com/data/icons/office-icon-set-3/512/users.png
D,Login1,d,zone1,10.1.1.4,A,[email protected],#b3b3b3,#000000,,https://login1.domain.com,https://cdn0.iconfinder.com/data/icons/icocentre-free-icons/147/f-server_128-512.png

我不知道什么是属性名称,它将自动为行指定名称。

我期望是否有一种方法可以对“#connect:{}” json部分进行编码,以便可以命名行。

diagram mxgraph draw.io
1个回答
0
投票

使用“ fromlabel”或“ tolabel” rethar“ label”,如>>

# connect: {"from": "user", "to": "name", "invert": true, "tolabel": "zone", \
#          "style": "curved=1;endArrow=blockThin;endFill=1;fontSize=11;"}
© www.soinside.com 2019 - 2024. All rights reserved.