甘特图中的链接和里程碑问题

甘特图中的链接和里程碑问题

我目前正在使用 pgfgantt 将甘特图添加到 Latex 文档中。该图表涵盖了不到一年的时间。我使用了来自 (获取甘特图周显示周数) 添加周数,并且运行正常。我有两个问题需要解决:

  • 里程碑几乎是看不见的
  • 我更喜欢直线,例如链接类型(fs),但是没有文字(以避免混乱)。

    \documentclass[tikz]{standalone}
    \usepackage{pgfgantt}
    \title{Gantt Chart}
    \begin{document}
    
    \newcounter{myWeekNum}
    \stepcounter{myWeekNum}
    %
    \newcommand{\myWeek}{\themyWeekNum
            \stepcounter{myWeekNum}
            \ifnum\themyWeekNum=53
            \setcounter{myWeekNum}{1}
            \else\fi
    }
    \setcounter{myWeekNum}{26}
    \ganttset{%
            calendar week text={\myWeek{}}%
    }
    \begin{figure}[h!bt]
            \caption{Time Plan}
            \begin{center}
                    \begin{ganttchart}[
                            vgrid={*{6}{draw=none}, dotted},
                            hgrid={dotted},
                            x unit=.08cm,
                            y unit title=.6cm,
                            y unit chart=1cm,
                            time slot format=isodate,
                            link/.style={->, ultra thick},
                            link bulge=4,
                            time slot format/start date=2017-07-01]{2017-07-01}{2018-06-30}
                            \ganttset{bar height=.6}
                            \gantttitlecalendar{year, month=name, week} \\
                            \ganttmilestone[name=e0]{Start}{2017-07-03} \\
                            \ganttbar[name=e1]{Task01}{2017-07-03}{2017-08-15} \\
                            \ganttbar[name=e2]{Task02}{2017-08-01}{2017-08-08}\\
                            \ganttbar[name=e3]{Task03}{2017-08-01}{2017-12-29}\\
                            \ganttbar[name=e4]{Task04}{2017-08-01}{2017-08-15}\\
                            \ganttbar[name=e5]{Task05}{2017-08-16}{2017-08-31}\\
                            \ganttbar[name=e6]{Task06}{2017-09-01}{2017-09-21}\\
                            \ganttbar[name=e7]{Task07}{2017-09-22}{2017-10-31}\\
                            \ganttmilestone[name=e8]{M1}{2017-11-01}\\
                            \ganttbar[name=e9]{Task08}{2017-11-01}{2017-11-14}\\
                            \ganttbar[name=e10]{Task09}{2017-11-01}{2017-12-22}\\
                            \ganttbar[name=e11]{Task10}{2017-12-25}{2018-01-01}\\
                            \ganttbar[name=e12]{Task11}{2018-01-02}{2018-01-05}\\
                            \ganttmilestone[name=e13]{M2}{2018-01-08}\\
                            \ganttbar[name=e14]{Task14}{2018-01-08}{2018-02-07}\\
                            \ganttbar[name=e15]{Task15}{2018-02-08}{2018-03-14}\\
                            \ganttmilestone[name=e16]{M3}{2018-03-15}\\
                            \ganttbar[name=e17]{Task17}{2018-03-15}{2018-05-14}\\
                            \ganttbar[name=e18]{Task18}{2018-05-15}{2018-05-23}\\
                            \ganttbar[name=e19]{Task19}{2018-05-24}{2018-05-31}
                            \ganttlink[link mid=.8]{e3}{e16}
                            \ganttlink[link type=-]{e4}{e5}
                            \ganttlink{e5}{e6}
                            \ganttlink{e6}{e7}
                            \ganttlink{e7}{e8}
                            \ganttlink{e8}{e9}
                            \ganttlink{e8}{e10}
                            \ganttlink{e10}{e11}
                            \ganttlink{e11}{e12}
                            \ganttlink{e12}{e13}
                            \ganttlink{e13}{e14}
                            \ganttlink{e14}{e15}
                            \ganttlink{e15}{e16}
                            \ganttlink{e16}{e17}
                            \ganttlink{e17}{e18}
                            \ganttlink{e18}{e19}
                    \end{ganttchart}
            \end{center}
    \end{figure}
    \end{document}
    

甘特图

你有什么指点吗?

答案1

对于1.,添加milestone/.append style={inner ysep=3mm},到图表设置。

对于 2. 您可以根据例如创建一个新类型的链接f-s,并将文本标签设置为空:

\newganttlinktypealias{straight}{f-s}
\setganttlinklabel{straight}{}

在 之前添加这些ganttchart并使用link type=straight

一个缩短的完整示例,因此更容易看到:

代码输出

\documentclass[tikz,border=5mm]{standalone}
\usepackage{pgfgantt}
\begin{document}

\newcounter{myWeekNum}
\stepcounter{myWeekNum}
%
\newcommand{\myWeek}{\themyWeekNum
        \stepcounter{myWeekNum}
        \ifnum\themyWeekNum=53
        \setcounter{myWeekNum}{1}
        \else\fi
}
\setcounter{myWeekNum}{26}
\ganttset{%
        calendar week text={\myWeek{}}%
}

% define a new link type
\newganttlinktypealias{straight}{f-s}
% remove label
\setganttlinklabel{straight}{}
\begin{ganttchart}[
            vgrid={*{6}{draw=none}, dotted},
            hgrid={dotted},
            x unit=.08cm,
            y unit title=.6cm,
            y unit chart=1cm,
            time slot format=isodate,
            link/.style={->, ultra thick},
            link bulge=4,
            time slot format/start date=2017-07-01,
            milestone/.append style={inner ysep=3mm}, % <-- added
             ]{2017-06-15}{2017-09-03}
            \ganttset{bar height=.6}
            \gantttitlecalendar{year, month=name, week} \\
            \ganttmilestone[name=e0]{Start}{2017-07-03} \\
            \ganttbar[name=e1]{Task01}{2017-07-03}{2017-07-15}\\
            \ganttbar[name=e2]{Task02}{2017-07-16}{2017-08-01}\\
            \ganttbar[name=e4]{Task04}{2017-08-02}{2017-08-15}\\

           \ganttlink{e0}{e1} 
           \ganttlink[link type=-]{e1}{e2} 
           \ganttlink[link type=straight]{e2}{e4}

\end{ganttchart}
\end{document}

相关内容