我想知道是否有办法在 tikz 中将泳道添加到流程图中?有一个流程图包,tikz
很棒。但对于我正在开发的特定应用程序,我需要包含泳道。我有一个这样的图表示例,来自Lucidchart,但我希望我tikz
也能做到这一点。
只是为了澄清,“泳道”是指图中的水平行,代表某个群体对该流程图块的所有权。
我也找到了这个帖子,但我不会创建桑基图。不确定我是否可以从他的包裹或帖子中获取带有流程图的通道。
示例图:
答案1
假设你已经有一些代码,比如这个
\documentclass[tikz]{standalone}
\usetikzlibrary{shapes}
\tikzset{
recgray/.style={draw,minimum width=3cm,minimum height=2cm,align=center,text width=3cm,fill=gray!50,font=\sffamily},
rndgray/.style={rounded corners=1cm,draw,minimum width=3cm,minimum height=2cm,align=center,text width=3cm,fill=gray!50,font=\sffamily},
recgren/.style={draw,minimum width=3cm,minimum height=2cm,align=center,text width=3cm,fill=green!50,font=\sffamily},
diagren/.style={diamond,draw,minimum width=3cm,minimum height=2cm,align=center,text width=3cm,fill=green!50,font=\sffamily,aspect=1.5},
}
\begin{document}
\begin{tikzpicture}[x=4.5cm,y=2cm]
\node[rndgray] (cus1) at (0,3) {Order generated};
\node[recgray] (sale1) at (0,1) {Order completed};
\node[recgray] (cre1) at (0,-1) {Order received};
\node[recgray] (ware1) at (0,-3) {Order entered};
\node[recgren] (cre2) at (1,-1) {Check credit};
\node[diagren] (cre3) at (2,-1) {OK?};
\node[recgray] (cre4) at (4,-1) {Invoice prepared};
\node[recgray] (cre5) at (5,-1) {Invoice sent};
\node[recgren] (sale3) at (2,1) {Credit problem\\addressed};
\node[diagren] (sale4) at (3.75,1) {OK?};
\node[rndgray] (sale5) at (4.75,1) {Order generated};
\node[recgray] (ware4) at (4.25,-3) {Packages assembled};
\node[recgray] (ware5) at (5.25,-3) {Order shipped};
\node[rndgray,minimum width=4.5cm,text width=4.5cm] (x) at (5.5,3) {Process payment};
\begin{scope}[every path/.style={-latex}]
\draw (cus1) edge (sale1)
(sale1) edge (cre1)
(cre1) edge (cre2)
(cre2) edge (cre3)
(cre3) edge node[midway,fill=white,inner sep=2pt] {Yes} (cre4)
(cre4) edge (cre5)
(cre3) edge node[midway,fill=white,inner sep=2pt] {No} (sale3)
(sale3) edge (sale4)
(sale4) edge node[midway,above] {No} (sale5)
(sale4) edge node[midway,fill=white,inner sep=2pt] {Yes} ++(0,-1.5)
(cre1) edge (ware1)
(ware1) edge (ware4)
(ware4) edge (ware5);
\draw (cre5.north east) -- ++(0,3);
\draw (ware5.north east) -- ++(0,5);
\end{scope}
\end{tikzpicture}
\end{document}
您只需添加一些矩形和一些普通节点。\foreach
在这里可能会非常有帮助。
\documentclass[tikz]{standalone}
\usetikzlibrary{shapes}
\tikzset{
recgray/.style={draw,minimum width=3cm,minimum height=2cm,align=center,text width=3cm,fill=gray!50,font=\sffamily},
rndgray/.style={rounded corners=1cm,draw,minimum width=3cm,minimum height=2cm,align=center,text width=3cm,fill=gray!50,font=\sffamily},
recgren/.style={draw,minimum width=3cm,minimum height=2cm,align=center,text width=3cm,fill=green!50,font=\sffamily},
diagren/.style={diamond,draw,minimum width=3cm,minimum height=2cm,align=center,text width=3cm,fill=green!50,font=\sffamily,aspect=1.5},
}
\begin{document}
\begin{tikzpicture}[x=4.5cm,y=2cm]
%---
\foreach \i in {-4,-2,0,2} {
\draw (-.75,\i) rectangle (6.25,\i+2);
\draw (-.75,\i) rectangle (-.5,\i+2);
}
\node[rotate=90,font=\sffamily] at (-.625,1) {Sales};
\node[rotate=90,font=\sffamily] at (-.625,3) {Customer};
\node[rotate=90,font=\sffamily] at (-.625,-1) {Credit/Invoicing};
\node[rotate=90,font=\sffamily] at (-.625,-3) {Warehouse};
%---
\node[rndgray] (cus1) at (0,3) {Order generated};
\node[recgray] (sale1) at (0,1) {Order completed};
\node[recgray] (cre1) at (0,-1) {Order received};
\node[recgray] (ware1) at (0,-3) {Order entered};
\node[recgren] (cre2) at (1,-1) {Check credit};
\node[diagren] (cre3) at (2,-1) {OK?};
\node[recgray] (cre4) at (4,-1) {Invoice prepared};
\node[recgray] (cre5) at (5,-1) {Invoice sent};
\node[recgren] (sale3) at (2,1) {Credit problem\\addressed};
\node[diagren] (sale4) at (3.75,1) {OK?};
\node[rndgray] (sale5) at (4.75,1) {Order generated};
\node[recgray] (ware4) at (4.25,-3) {Packages assembled};
\node[recgray] (ware5) at (5.25,-3) {Order shipped};
\node[rndgray,minimum width=4.5cm,text width=4.5cm] (x) at (5.5,3) {Process payment};
\begin{scope}[every path/.style={-latex}]
\draw (cus1) edge (sale1)
(sale1) edge (cre1)
(cre1) edge (cre2)
(cre2) edge (cre3)
(cre3) edge node[midway,fill=white,inner sep=2pt] {Yes} (cre4)
(cre4) edge (cre5)
(cre3) edge node[midway,fill=white,inner sep=2pt] {No} (sale3)
(sale3) edge (sale4)
(sale4) edge node[midway,above] {No} (sale5)
(sale4) edge node[midway,fill=white,inner sep=2pt] {Yes} ++(0,-1.5)
(cre1) edge (ware1)
(ware1) edge (ware4)
(ware4) edge (ware5);
\draw (cre5.north east) -- ++(0,3);
\draw (ware5.north east) -- ++(0,5);
\end{scope}
\end{tikzpicture}
\end{document}
(点击图片可查看更大区域)