zxsq_graphviz使用说明
GraphViz for Discuz!实现了在Discuz!论坛将dot源码渲染为图形。graphviz是贝尔实验室开发的一个开源的工具包,它使用一个特定的DSL(领域特定
语言):dot作为脚本语言,然后使用布局引擎来解析此脚本,并完成自动布局。可以用于程序结构图、流程图、网络图、数据结构图、UML图、状态机图等。
使用方法
本插件不提供编辑器按钮,请直接输入代码
[gv] put your dot code here [ /gv]
gv接受一个参数,表示dot解析引擎,可选引擎:dot,neato,fdp,sfdp,twopi,circo
如 [gv=neato]put your dot code here[/gv] 表示用neato引擎画无向图
不带参数时,默认解析引擎为 dot
即 [gv] [ /gv] 等同于 [gv=dot] [ /gv]
示例
一个简单的有向图
[gv]
digraph {
"A" [shape="circle"];
"B" [shape="rectangle"];
"C" [shape="diamond"];
"A" -> "B" [label="A to B"];
"B" -> "C" [label="B to C"];
"A" -> "C" [label="A to C"];
}[/gv]
[gv=dot]digraph {
"A" [shape="circle"];
"B" [shape="rectangle"];
"C" [shape="diamond"];
"A" -> "B" [label="A to B"];
"B" -> "C" [label="B to C"];
"A" -> "C" [label="A to C"];
}[/gv]
一个哈希表
[gv]
digraph st2{
fontname = "Verdana";
fontsize = 10;
rankdir=TB;
node [fontname = "Verdana", fontsize = 10, color="skyblue", shape="record"];
edge [fontname = "Verdana", fontsize = 10, color="crimson", style="solid"];
st_hash_type [label="{<head>st_hash_type|(*compare)|(*hash)}"];
st_table_entry [label="{<head>st_table_entry|hash|key|record|<next>next}"];
st_table [label="{st_table|<type>type|num_bins|num_entries|<bins>bins}"];
st_table:bins -> st_table_entry:head;
st_table:type -> st_hash_type:head;
st_table_entry:next -> st_table_entry:head [style="dashed", color="forestgreen"];
}
[/gv]
[gv=dot]digraph st2{
fontname = "Verdana";
fontsize = 10;
rankdir=TB;
node [fontname = "Verdana", fontsize = 10, color="skyblue", shape="record"];
edge [fontname = "Verdana", fontsize = 10, color="crimson", style="solid"];
st_hash_type [label="{<head>st_hash_type|(*compare)|(*hash)}"];
st_table_entry [label="{<head>st_table_entry|hash|key|record|<next>next}"];
st_table [label="{st_table|<type>type|num_bins|num_entries|<bins>bins}"];
st_table:bins -> st_table_entry:head;
st_table:type -> st_hash_type:head;
st_table_entry:next -> st_table_entry:head [style="dashed", color="forestgreen"];
}[/gv]
指定引擎
neato引擎
[gv=neato]
graph hmc_graph{
"hmc01" -- "test520"
"test520" -- "lpar2"
"test520" -- "lpar3"
"hmc01" -- "test570"
"test570" -- "aixtest01"
"test570" -- "aixtest02"
"test570" -- "aixtest03"
"hmc01" -- "test510"
"test510" -- "lpar1"
}[/gv]
[gv=neato]graph hmc_graph{
"hmc01" -- "test520"
"test520" -- "lpar2"
"test520" -- "lpar3"
"hmc01" -- "test570"
"test570" -- "aixtest01"
"test570" -- "aixtest02"
"test570" -- "aixtest03"
"hmc01" -- "test510"
"test510" -- "lpar1"
}[/gv]
更多示例请访问:
http://www.tecbbs.com/forum.php?mod=viewthread&tid=6724
http://www.graphviz.org/Gallery.php
|