如何在Graphviz中将SVG用于自定义节点形状? [英] How to use SVG for custom node shapes in graphviz?

查看:337
本文介绍了如何在Graphviz中将SVG用于自定义节点形状?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 graphviz (dot命令行工具,具体来说)生成图形的SVG布局.我想使用我的 Inkscape 生成的SVG文件来定义节点形状,并且按照 graphviz教程.我输出的是SVG,因此,从理论上讲,通过将形状声明为<symbol> s并在图中将它们声明为<use>,应该很容易做到这一点. 此电子邮件使我相信该功能是实施,我只是想不通如何使用它.

I'm trying to use graphviz (the dot command-line tool, to be more specific) to generate a SVG layout of a graph. I would like to use my Inkscape-generated SVG files to define node shapes, and I followed the instructions on the graphviz tutorial. I'm outputting SVG so, in theory, this should be easy to do by declaring the shapes as <symbol>s and <use>ing them in the diagram. This e-mail makes me believe that the functionality was implemented, and I just can't figure out how to use it.

我尝试让节点的image属性指向自定义形状SVG文件.我还尝试将节点的shape设置为custom并将shapefile指向形状SVG. dot抱怨是否输入了无效的文件名,并且其插件图表明它可以读取SVG.我猜测是我使用了错误的属性,或者尝试的SVG文件有问题.

I tried having a node's image attribute pointing to the custom shape SVG file. I also tried setting the node's shape to custom and pointing the shapefile to the shape SVG. dot complains if I put an invalid file name, and its plugin graph suggests that it can read SVG. I'm guessing that either I'm using the wrong attributes, or there's something wrong with the SVG files that I have tried.

无论价值多少,我都在<svg>属性上设置了viewBox.

For whatever it's worth, I do have viewBox set on the <svg> attribute.

推荐答案

graphviz仅支持使用绝对单位(像素,英寸等)在<svg>上设置widthheight属性的SVG输入. Inkscape将height="100%" width="100%" viewBox="0 0 width_in_pixels height_in_pixels"输出为<svg>元素上的属性.

graphviz only supports SVG input where the width and height attributes are set on <svg> using absolute units (pixels, inches etc.). Inkscape outputs height="100%" width="100%" viewBox="0 0 width_in_pixels height_in_pixels" as attributes on the <svg> element.

我提交了错误报告,并且graphviz开发人员向我指出了关于图像属性的帮助,其中描述了在自定义节点形状中使用SVG的要求.

I filed a bug report, and a graphviz developer pointed me to the help for the image attribute, which describes the requirements for using SVG in custom node shapes.

这篇关于如何在Graphviz中将SVG用于自定义节点形状?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆