如何控制边的初始位置和最终位置?

如何控制边的初始位置和最终位置?

这是我第一次尝试使用 Tikz 环境。我绘制了下面的图表:

Tikz 图表

我怎样才能绘制边缘以使末端与矩形边缘的中心相匹配(图中的红点)?

代码:

\tikzset{
  block/.style={rectangle, text width=8em, minimum height=4ex, text centered, draw=black, fill=orange!30},
  arrow/.style={draw, thick,->,>=stealth},
}
\begin{tikzpicture}[node distance=1cm]
    \node [block] (dev-team) {Development team};
    \node [block, below=of dev-team] (git-repo) {Git repository};
    \node [block, below=of git-repo] (jenkins) {Jenkins};
    \node [block, right=of jenkins, yshift=1.5cm] (unit-tests) {unit tests};
    \node [block, right=of jenkins, yshift=0.5cm] (localisation) {localisation};
    \node [block, right=of jenkins, yshift=-0.5cm] (code-quality) {code quality};
    \node [block, right=of jenkins, yshift=-1.5cm] (ui-automation)  {UI automation};
    \node [block, below=of jenkins] (testflight) {Testflight};
    \node [block, below=of testflight, text width=2em, xshift=-1.5cm] (PO) {PO};
    \node [block, below=of testflight, text width=2em, xshift=-0.5cm] (BA) {BA};
    \node [block, below=of testflight, text width=2em, xshift=0.5cm] (DM) {DM};
    \node [block, below=of testflight, text width=2em, xshift=1.5cm] (QA) {QA};

    \path [arrow] (dev-team) -- (git-repo);
    \path [arrow] (git-repo) -- (jenkins);
    \path [arrow] (jenkins) -- (unit-tests);
    \path [arrow] (jenkins) -- (localisation);
    \path [arrow] (jenkins) -- (code-quality);
    \path [arrow] (jenkins) -- (ui-automation);
    \path [arrow] (jenkins) -- (testflight);
    \path [arrow] (testflight) -- (PO);
    \path [arrow] (testflight) -- (BA);
    \path [arrow] (testflight) -- (DM);
    \path [arrow] (testflight) -- (QA);
\end{tikzpicture}

顺便问一下,有没有更好的选项来定位节点“Jenkins”和“Testflight”的“子节点”?我尝试过这个child选项,但没有成功。

答案1

您可以使用以下<name>.<anchor>语法:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\tikzset{
  block/.style={rectangle, text width=8em, minimum height=4ex, text centered, draw=black, fill=orange!30},
  arrow/.style={draw, thick,->,>=stealth},
}
\begin{tikzpicture}[node distance=1cm]
    \node [block] (dev-team) {Development team};
    \node [block, below=of dev-team] (git-repo) {Git repository};
    \node [block, below=of git-repo] (jenkins) {Jenkins};
    \node [block, right=of jenkins, yshift=1.5cm] (unit-tests) {unit tests};
    \node [block, right=of jenkins, yshift=0.5cm] (localisation) {localisation};
    \node [block, right=of jenkins, yshift=-0.5cm] (code-quality) {code quality};
    \node [block, right=of jenkins, yshift=-1.5cm] (ui-automation)  {UI automation};
    \node [block, below=of jenkins] (testflight) {Testflight};
    \node [block, below=of testflight, text width=2em, xshift=-1.5cm] (PO) {PO};
    \node [block, below=of testflight, text width=2em, xshift=-0.5cm] (BA) {BA};
    \node [block, below=of testflight, text width=2em, xshift=0.5cm] (DM) {DM};
    \node [block, below=of testflight, text width=2em, xshift=1.5cm] (QA) {QA};

    \path [arrow] (dev-team) -- (git-repo);
    \path [arrow] (git-repo) -- (jenkins);
    \path [arrow] (jenkins.east) -- (unit-tests.west);
    \path [arrow] (jenkins.east) -- (localisation.west);
    \path [arrow] (jenkins.east) -- (code-quality.west);
    \path [arrow] (jenkins.east) -- (ui-automation.west);
    \path [arrow] (jenkins) -- (testflight);
    \path [arrow] (testflight.south) -- (PO.north);
    \path [arrow] (testflight.south) -- (BA.north);
    \path [arrow] (testflight.south) -- (DM.north);
    \path [arrow] (testflight.south) -- (QA.north);
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容