如何避免 pgfgantt 中笨拙的 \ganttlink?

如何避免 pgfgantt 中笨拙的 \ganttlink?

我想在此图表(Microsoft Project 软件)中清晰显示甘特图,尤其是与活动 A 链接的活动 B、C 和 D。请帮助我。

    \documentclass[12pt,border=12pt]{standalone}
    \usepackage{tikz,pgf,pgfgantt}
    \usepackage[utf8]{inputenc}
    \usepackage{xcolor} 

    \begin{document}
    \begin{ganttchart}[vgrid, hgrid, bar/.append style={orange}, link/.append style={thick}, link bulge=.5, link/.style={->, thick}]{1}{33}
   \gantttitle{Example 1 - Gantt Chart (in Days)}{33} \\
   \gantttitlelist{1,...,33}{1} \\
   \ganttgroup{Project Duration}{1}{33} \\
   \ganttbar{Activity A}{1}{2} \\
   \ganttbar{Activity B}{3}{6} \\
   \ganttbar{Activity C}{3}{5} \\
   \ganttbar{Activity D}{3}{7} \\
   \ganttbar{Activity E}{7}{8} \\
   \ganttbar{Activity F}{8}{11} \\
   \ganttbar{Activity G}{7}{9} \\
   \ganttbar{Activity H}{10}{15} \\
   \ganttbar{Activity I}{16}{22} \\
   \ganttbar{Activity J}{8}{11} \\
   \ganttbar{Activity K}{8}{10} \\
   \ganttbar{Activity L}{10}{10} \\
   \ganttbar{Activity M}{11}{14} \\
   \ganttbar{Activity N}{10}{15} \\
   \ganttbar{Activity O}{23}{31} \\
   \ganttbar{Activity P}{11}{18} \\
   \ganttbar{Activity Q}{32}{33} \\
   \ganttlink{elem1}{elem2}
   \ganttlink{elem1}{elem3}
   \ganttlink{elem1}{elem4}
   \ganttlink{elem2}{elem5}
   \ganttlink{elem4}{elem6}
   \ganttlink{elem2}{elem7}
   \ganttlink{elem7}{elem8}
   \ganttlink{elem4}{elem10}
   \ganttlink{elem4}{elem11}
   \ganttlink{elem7}{elem12}
   \ganttlink{elem11}{elem13}
   \ganttlink{elem7}{elem14}
   \ganttlink{elem11}{elem16}
   \ganttlink{elem3}{elem9}
   \ganttlink{elem5}{elem9}
   \ganttlink{elem6}{elem9}
   \ganttlink{elem8}{elem9}
   \ganttlink{elem9}{elem15}
   \ganttlink{elem10}{elem15}
   \ganttlink{elem12}{elem15}
   \ganttlink{elem13}{elem15}
   \ganttlink{elem14}{elem17}
   \ganttlink{elem15}{elem17}
   \ganttlink{elem16}{elem17}
   \end{ganttchart}
   \end{document}

在此处输入图片描述

该甘特图的网络图如下: 在此处输入图片描述

答案1

您可以尝试使用链接的link bulge和参数。定义链接的水平延伸,而定义链接折回的两个条之间的分数垂直距离。例如,link midlink bulgelink mid

\ganttlink[link bulge=0.4]{elem1}{elem2}
\ganttlink[link bulge=1, link mid=0.3]{elem1}{elem3}
\ganttlink[link bulge=1.3]{elem1}{elem4}

你得到

图表的前几个链接

完整代码

\documentclass[12pt,border=12pt]{standalone}
\usepackage{pgfgantt} % loads tikz which loads pgf and xcolor
\usepackage[utf8]{inputenc}

\begin{document}
\begin{ganttchart}[vgrid, hgrid, bar/.append style={orange}, link/.append style={thick}, link bulge=.5, link/.style={->, thick}]{1}{33}
\gantttitle{Example 1 - Gantt Chart (in Days)}{33} \\
\gantttitlelist{1,...,33}{1} \\
\ganttgroup{Project Duration}{1}{33} \\
\ganttbar{Activity A}{1}{2} \\
\ganttbar{Activity B}{3}{6} \\
\ganttbar{Activity C}{3}{5} \\
\ganttbar{Activity D}{3}{7} \\
\ganttbar{Activity E}{7}{8} \\
\ganttbar{Activity F}{8}{11} \\
\ganttbar{Activity G}{7}{9} \\
\ganttbar{Activity H}{10}{15} \\
\ganttbar{Activity I}{16}{22} \\
\ganttbar{Activity J}{8}{11} \\
\ganttbar{Activity K}{8}{10} \\
\ganttbar{Activity L}{10}{10} \\
\ganttbar{Activity M}{11}{14} \\
\ganttbar{Activity N}{10}{15} \\
\ganttbar{Activity O}{23}{31} \\
\ganttbar{Activity P}{11}{18} \\
\ganttbar{Activity Q}{32}{33} \\
\ganttlink[link bulge=0.4]{elem1}{elem2}
\ganttlink[link bulge=1, link mid=0.3]{elem1}{elem3}
\ganttlink[link bulge=1.3]{elem1}{elem4}
\ganttlink{elem2}{elem5}
\ganttlink{elem4}{elem6}
\ganttlink{elem2}{elem7}
\ganttlink{elem7}{elem8}
\ganttlink{elem4}{elem10}
\ganttlink{elem4}{elem11}
\ganttlink{elem7}{elem12}
\ganttlink{elem11}{elem13}
\ganttlink{elem7}{elem14}
\ganttlink{elem11}{elem16}
\ganttlink{elem3}{elem9}
\ganttlink{elem5}{elem9}
\ganttlink{elem6}{elem9}
\ganttlink{elem8}{elem9}
\ganttlink{elem9}{elem15}
\ganttlink{elem10}{elem15}
\ganttlink{elem12}{elem15}
\ganttlink{elem13}{elem15}
\ganttlink{elem14}{elem17}
\ganttlink{elem15}{elem17}
\ganttlink{elem16}{elem17}
\end{ganttchart}
\end{document}

相关内容