長方形を使った TikZ のマイルストーン グラフィック

長方形を使った TikZ のマイルストーン グラフィック

フォーラム内で、この美しくデザインされたマイルストーン/タイムライン グラフィックを見つけました。 TikZ のマイルストーン グラフィック

このグラフィックに関しては、次の 2 つの変更を加えたいと思います。

  1. 円(長方形)の垂直位置を設定するためにコードを調整するにはどうすればよいですか?

  2. 長方形の水平サイズと垂直サイズを設定するためにコードを調整するにはどうすればよいですか?

私の目標は、ガントチャートのように、タイムラインの上に複数のバーを表示することです。

あなたの助けに大いに感謝します!


\documentclass{standalone}
\usepackage{datatool}
\usepackage{tikz}
\usetikzlibrary{shadows}
\usetikzlibrary{positioning}
%\usetikzlibrary{calc,intersections}

\usepackage{filecontents}
\begin{filecontents*}{tasks.dat}
phase,taskid,name,position,size
initial,initial,Decision to vote shares,2,8
softblocking,softblocking,Soft Blocking,9,8
afterAGM,afterAGM,No blocking,17,8
\end{filecontents*}

\DTLloaddb[noheader=false]{tasks}{tasks.dat}

\begin{document}
\begin{tikzpicture}[week/.style={font=\bfseries, text=white},
initial/.style={fill=yellow,rectangle,opacity=0.5},
softblocking/.style={fill=red!60,rectangle,opacity=0.5},
afterAGM/.style={fill=green,rectangle,opacity=0.5} ]

% Tasks Headers
\DTLforeach*{tasks}{\phase=phase, \taskid=taskid, \name=name, \position=position,\size=size}{\node(\taskid)[\phase, minimum size=\size em] at (\position, 0) {};
\draw (node cs:name=\taskid, anchor=north) to ++(0,1) node[above, scale=\size/6] {\name};
}

% Timeline Bar
\filldraw[fill=black, draw=white,line width=0.5ex,opacity=0.75] (0,-0.5) rectangle (20,0.5);

% Weeks.
\node[week] at (2,0) {Announcement};
\node[week] at (5,0) {TRD -6};
\node[week] at (9,0) {TRD -4};
\node[week] at (13,0) {TRD, AGM -7};
\node[week] at (17,0) {AGM};
\end{tikzpicture}
\end{document}  

答え1

どのような見た目にしたいのかよくわかりません。おそらくこのようではないと思いますが、あなたの説明から私が得たのはこれです!(またはもっとこのような? ただし、これは私が描いたものなので、少し奇妙であることに注意してください。

ちなみに、Claudio Fiandrino のtimelineライブラリの使用を検討してください。

可変マイルストーン

\documentclass[tikz,border=5pt]{standalone}
\usepackage{datatool}
\usetikzlibrary{shadows,positioning}

\usepackage{filecontents}
\begin{filecontents*}{tasks.dat}
phase,taskid,name,xposition,yposition,width,height
initial,initial,Decision to vote shares,2,5,8,10
softblocking,softblocking,Soft Blocking,9,0,8,24
afterAGM,afterAGM,No blocking,17,-6,8,2
\end{filecontents*}

\DTLloaddb[noheader=false]{tasks}{tasks.dat}

\begin{document}
\begin{tikzpicture}[week/.style={font=\bfseries, text=white},
initial/.style={fill=yellow,rectangle,opacity=0.5},
softblocking/.style={fill=red!60,rectangle,opacity=0.5},
afterAGM/.style={fill=green,rectangle,opacity=0.5} ]

% Tasks Headers
\DTLforeach*{tasks}{\phase=phase, \taskid=taskid, \name=name, \xposition=xposition, \yposition=yposition, \mywidth=width, \myheight=height}{\node(\taskid)[\phase, minimum width=\mywidth em, minimum height=\myheight mm] at (\xposition, \yposition) {};
\draw (node cs:name=\taskid, anchor=north) to ++(0,1) node[above, scale=\mywidth/6] {\name};
}

% Timeline Bar
\filldraw[fill=black, draw=white,line width=0.5ex,opacity=0.75] (0,-0.5) rectangle (20,0.5);

% Weeks.
\node[week] at (2,0) {Announcement};
\node[week] at (5,0) {TRD -6};
\node[week] at (9,0) {TRD -4};
\node[week] at (13,0) {TRD, AGM -7};
\node[week] at (17,0) {AGM};
\end{tikzpicture}
\end{document}

関連情報