答案1
我不会使用具有复杂嵌套语法和限制的树库并依赖自动定位,而是会以方便的方式使用标准 TikZ 语法。
- 为不同类型的节点定义样式
- 放置主坐标,使用计算语法划分距离
- 将主要节点放置在这些坐标处
- 放置更多节点,因为这样看起来好看,请尝试使用相对定位
- 绘制连接线
由于相对定位和使用计算是逻辑定位,当您调整一些值以完成时,一切都会保持良好的状态。
主要部分-剩余节点可以按照类似的方式添加:
\documentclass[tikz,border=4mm]{standalone}
\usetikzlibrary{calc,shapes,positioning}
\tikzset{%
root/.style = { draw, ellipse, fill=blue!10,
font = \sffamily\LARGE\bfseries, align = center},
main/.style = { draw, rounded corners = 6pt, fill=blue!10, align = center,
font = \sffamily\Large\bfseries, minimum height = 11ex,
inner sep = 6pt},
end/.style = { font = \sffamily\bfseries},
}
\newcommand*{\len}{18}
\begin{document}
\begin{tikzpicture}
% Base graph coordinates
\coordinate (A);
\coordinate (B) at ($(A)+(\len,0)$);
\coordinate (D) at ($(A)!.4!(B)$);
\coordinate (E) at ($(A)!.7!(B)$);
\coordinate (F) at ($(D)!.5!(E)$);
% main leaves coordinates
\coordinate (health) at ($(D)+(120:\len/3)$);
\coordinate (order) at ($(E)+(120:\len/3)$);
\coordinate (inventory) at ($(F)+(240:\len/3)$);
% graph lines
\draw (A) -- (B)
(D) -- (health)
(E) -- (order)
(F) -- (inventory);
% root node
\node [root] at (B) {Chemical\\Tracking\\System};
% main leaves nodes
\node [main, above = 0 of health] {Health \&\\Safety};
\node [main, above = 0 of order] {Order\\Chemicals};
\node [main, below = 0 of inventory] {Inventory\\Management};
% end leaves nodes, positioning in relation to existing nodes
% somehow manually, but relative positioning makes changes easier
\node (info) [end, anchor=west] at ($(A)+(0,0.2*\len)$) {Health \& Safety Info};
\node (compliance) [end, anchor=west] at ($(A)!.6666!(info.west)$) {Compliance Reporting};
\node (exposure) [end, anchor=west] at ($(A)!.3333!(info.west)$) {Chemical Exposure Report};
\node (laboratories) [end, anchor=west] at ($(A)-(0,0.1*\len)$) {Laboratories};
\node (stockroom) [end, anchor=west] at ($(A)!.5!(laboratories.west)$) {Chemical Stockroom};
\node (incident) [end] at ($(health)!.6666!(order)-(0,1)$) {Incident Reporting};
\node (request) [end] at ($(incident)!.4!(F)$) {Chemical Request};
\node (receiving) [end] at ($(inventory)!.5!(E)+(1,0)$) {Receiving};
\node (search) [end] at ($(order)!.5!(B)+(1,1)$) {Search};
% draw lines
\draw (info.east) -- ($(health)!(info.east)!(D)$);
\draw (compliance.east) -- ($(health)!(compliance.east)!(D)$);
\draw (exposure.east) -- ($(health)!(exposure.east)!(D)$);
\draw (incident.west) -- ($(health)!(incident.west)!(D)$);
\draw (request.east) -- ($(order)!(request.east)!(E)$);
\draw (stockroom.east) -- ($(inventory)!(stockroom.east)!(F)$);
\draw (laboratories.east) -- ($(inventory)!(laboratories.east)!(F)$);
\draw (receiving.west) -- ($(inventory)!(receiving.west)!(F)$);
\draw (search.west) -- ($(order)!(search.west)!(E)$);
\end{tikzpicture}
\end{document}