【问题标题】:Cascading or inheriting attributes from multiple node declarations in graphviz从graphviz中的多个节点声明级联或继承属性
【发布时间】:2014-10-09 19:13:53
【问题描述】:

我正在使用 graphviz/dot 生成图表。

我想将图中的节点和/或边分组为语义类,每个类都有一组节点和/或边属性,这些属性与 CSS 类似。但是,如果我将单个节点分组为多个类,则后面的属性声明将覆盖前面的属性声明,即使后面的声明中没有指定该属性。特别是,它将值恢复为默认/更高范围的值。

例如:

node [shape="hexagon", style="filled", fillcolor="lightskyblue1"];
{ node [shape="box"]; a; b; }
{ node [fillcolor="red"]; b; c; }

我想要什么:

a [shape="box", style="filled", fillcolor="lightskyblue1"];
b [shape="box", style="filled", fillcolor="red"];
c [shape="hexagon", style="filled", fillcolor="red"];

我得到了什么:

a [shape="box", style="filled", fillcolor="lightskyblue1"];
b [shape="hexagon", style="filled", fillcolor="red"];
c [shape="hexagon", style="filled", fillcolor="red"];

这可能吗?

【问题讨论】:

    标签: graphviz dot


    【解决方案1】:

    这里有不同的结果。

    a [shape="box", style="filled", fillcolor="lightskyblue1"];
    b [shape="box", style="filled", fillcolor="lightskyblue1"];
    c [shape="hexagon", style="filled", fillcolor="red"];
    

    这看起来对我来说是正确的。对象继承定义时的默认属性(=第一次出现)。 b 在[shape="box"] 的行上定义。 fillcolor="lightskyblue1" 从外部作用域生效。

    来自http://www.graphviz.org/content/dot-language(由我突出显示):

    如果默认属性是使用节点、边或图形语句定义的,或者通过未附加到节点或边的属性分配来定义,则之后定义的任何适当类型的对象都将继承此属性属性值。

    graphviz 版本 2.38.0

    【讨论】:

      猜你喜欢
      • 2023-03-18
      • 1970-01-01
      • 1970-01-01
      • 2013-03-25
      • 2017-02-15
      • 1970-01-01
      • 2012-10-19
      • 2019-02-07
      • 2019-08-01
      相关资源
      最近更新 更多