pgfgantt: バーの端に日付を追加するにはどうすればいいですか?

pgfgantt: バーの端に日付を追加するにはどうすればいいですか?

問題

pgffgantt パッケージを使用してガントチャートを作成しています。タスクの日付をバーの上に表示したいと思います (下の画像ではオレンジ色)

私の目標

私はさまざまな質問に基づいてうまくいかなかったことをやろうとしました(12)、日付が正しい場所に表示されず、2 つのバーが同じ行にあると、重なり合うことになります...

誰かこれをどうやって行うのか知っていますか、それとも私に正しい方向を指し示してくれる人はいますか?

最小限の動作例

\documentclass[a4paper, 12pt]{article}
\usepackage[babel=true, kerning=true]{microtype} % Required by the package pgfgantt
\usepackage{pgfgantt}

\begin{document}
    \begin{ganttchart}[
            expand chart=\linewidth,
            time slot format=little-endian,  % Format of the date dd-mm-yyyy
            inline,
            vgrid={*6{draw=none}, *1{dotted}},  % Draw a line 1 out of 7 times, which is the same as framing the weeks
        ]{14-02-2022}{12-08-2022}
        \ganttset{calendar week text=\currentweek} % Overload the week text, display the week number (1, 2,, ...) instead of "Week <number>"
        \gantttitlecalendar{month=name, week}\\

        % Group 1
        \ganttset{
            bar/.append style={fill=lightblue},
            group/.append style={fill=darkblue},
        }
        \ganttgroup{Group 1}{14-02-2022}{25-06-2022}\\
        \ganttbar{Task 1}{14-04-2022}{28-05-2022}\\
        \ganttbar{Task 2}{18-02-2022}{18-04-2022} \ganttbar{Task 2 bis}{18-05-2022}{18-06-2022} \\
        % \ganttbar{Task 3}{14-02-2022}{28-03-2022}\\

    \end{ganttchart}
\end{document}

答え1

次のコードは、2 つのコマンドを作成し\myganttgroup\myganttbar2 つの元のバーまたはグループにラベルを追加します。

\PassOptionsToPackage{svgnames}{xcolor}
\documentclass[a4paper, 12pt]{article}
\usepackage[babel=true, kerning=true]{microtype} % Required by the package pgfgantt
\usepackage{pgfgantt}

\tikzset{
    date/.style={text=yellow!80!black, font=\small, anchor=south}
}
    
\newcommand{\myganttgroup}[4][]{%
\ganttgroup[#1, name=#2]{#2}{#3}{#4}
\node[date] at (#2.north west) {#3};
\node[date] at (#2.north east) {#4};
}

\newcommand{\myganttbar}[4][]{%
\ganttbar[#1, name=#2]{#2}{#3}{#4}
\node[date] at (#2.north west) {#3};
\node[date] at (#2.north east) {#4};
}


\begin{document}
    \begin{ganttchart}[
            expand chart=\linewidth,
            time slot format=little-endian,  % Format of the date dd-mm-yyyy
            inline,
            vgrid={*6{draw=none}, *1{dotted}},  % Draw a line 1 out of 7 times, which is the same as framing the weeks
        ]{14-02-2022}{12-08-2022}
        \ganttset{calendar week text=\currentweek} % Overload the week text, display the week number (1, 2,, ...) instead of "Week <number>"
        \gantttitlecalendar{month=name, week}\\

        % Group 1
        \ganttset{
            bar/.append style={fill=LightBlue},
            group/.append style={fill=DarkBlue},
        }
%        \ganttgroup{Group 1}{14-02-2022}{25-06-2022}\\
        \myganttgroup{Group 1}{14-02-2022}{25-06-2022}\\
        \myganttbar{Task 1}{14-04-2022}{28-05-2022}\\
        \myganttbar{Task 2}{18-02-2022}{18-04-2022} \myganttbar{Task 2 bis}{18-05-2022}{18-06-2022} \\
        % \ganttbar{Task 3}{14-02-2022}{28-03-2022}\\
%        \node[left] at (task1.north west) {A};
%        \node[right] at (task1.north east) {B};

    \end{ganttchart}
\end{document}

ここに画像の説明を入力してください

関連情報