This is a continuation from Part I, where a solution was provided to create rotating labels in a radial fashion.
Closeup of the output looking like this:
I was able to improve the solution, preventing upside-down labels as they rotated through 360 degrees, with the following code, the difference being the 'ifthenelse' conditional clause…
\makeatletter
\newcommand*{\rotateme}[1]{%
\pgfmathparse{
(\tikz@grow@circle@from@start-(\pgfkeysvalueof{/tikz/sibling angle})*(\tikznumberofcurrentchild-1))
}%
\pgfmathparse{
ifthenelse(\pgfmathresult > 90 && \pgfmathresult < 270,\pgfmathresult + 180,\pgfmathresult)
}
\rotatebox[origin=c]{\pgfmathresult}{#1}%
}
\makeatother
What I would like to do now, is extend the radial nature of this topic, for the case where labels are quite long. Replacing the circular concept nodes, with ellipses or rectangles with rounded corners, which are also rotated. Note the following current output, the error is quite pronounced.
My skills with tikz are quite poor, relatively speaking, is anyone able to assist here?
The full working example stands as follows:
\documentclass[tikz]{standalone}
\usetikzlibrary{mindmap}
\newsavebox\rotatenodebox
\makeatletter
\newcommand*{\rotateme}[1]{%
\pgfmathparse{
(\tikz@grow@circle@from@start-(\pgfkeysvalueof{/tikz/sibling angle})*(\tikznumberofcurrentchild-1))
}%
\pgfmathparse{
ifthenelse(\pgfmathresult > 90 && \pgfmathresult < 270,\pgfmathresult + 180,\pgfmathresult)
}
\rotatebox[origin=c]{\pgfmathresult}{#1}%
}
\makeatother
\tikzset{
conc3/.style={concept,scale=.5},
rot/.style={
conc3,
execute at begin node={\begingroup\begin{lrbox}{\rotatenodebox}},
execute at end node={\end{lrbox}\rotateme{\usebox\rotatenodebox}\endgroup},
}
}
\tikzset{
conc4/.style={concept,scale=0.75},
rotL/.style={
conc4
}
}
\begin{document}
\begin{tikzpicture}
\path[small mindmap,concept,text=white]
node[concept] {Bla} [clockwise from=345]
child[concept color=red,text=black]{
node[concept]at(1,0){Bla Bla}[clockwise from=90]
child[concept color=red!95!black,text=black]{
node[rotL]{A}[clockwise from = 120]
child {node[rot] {A.A}}
child {node[rot] {A.B}}
child {node[rot] {A.C}}
}
child[concept color=red!75!black,text=white,grow=50]{
node[rotL]{B}[clockwise from = 80]
child {node[rot] {B.A}}
child {node[rot] {B.B}}
child {node[rot] {B.C}}
}
child[concept color=red!50!black,text=white ,grow=10]{
node[rotL]{C}[clockwise from = 40]
child {node[rot] {C.A}}
child {node[rot] {C.B}}
child {node[rot] {C.C}}
}
child[concept color=red!25!black,text=white,grow=-30]{
node[rotL]{D}[clockwise from = 0]
child {node[rot] {D.A}}
child {node[rot] {D.B}}
child {node[rot] {D.C}}
}
child[concept color=red!10!black,text=white,grow=-70]{
node[rotL]{D}[clockwise from = -40]
child {node[rot] {D.A}}
child {node[rot] {D.B}}
child {node[rot] {D.C}}
}
}
child[concept color=green,text=black, grow=195]{
node[concept]{Bla Bla}[clockwise from=80]
child[concept color=green!10!black,text=white]{
node[rotL]{Bla}[clockwise from = 110]
child {node[rot] {A.A}}
child {node[rot] {A.B}}
child {node[rot] {A.C}}
}
child[concept color=green!25!black,text=white,grow=120]{
node[rotL]{Bla}[clockwise from = 150]
child {node[rot] {A.A}}
child {node[rot] {A.B}}
child {node[rot] {A.C}}
}
child[concept color=green!50!black,text=white,grow=160]{
node[rotL]{Bla}[clockwise from = 190]
child {node[rot] {B.A}}
child {node[rot] {B.B}}
child {node[rot] {B.C}}
}
child[concept color=green!75!black,text=white ,grow=200]{
node[rotL]{Bla}[clockwise from = 230]
child {node[rot] {C.A}}
child {node[rot] {C.B}}
child {node[rot] {C.C}}
}
child[concept color=green!95!black,text=black,grow=240]{
node[rotL]{Bla}[clockwise from = 270]
child {node[rot] {D.A}}
child {node[rot] {D.B}}
child {node[rot] {D.C}}
}
}
child[concept color=orange,text=black, grow = 270] {
node[concept]at(-1.5,-2.5){Bla Bla}[clockwise from=360]
child[concept color=orange!95!black]{
node[rotL]{Bla}[clockwise from = 30]
child {node[rot] {A.A}}
child {node[rot] {A.B}}
child {node[rot] {A.C}}
}
child[concept color=orange!75!black, grow = 320]{
node[rotL]{Bla}[clockwise from =350]
child {node[rot] {In Honour of the Great Long Don Silver}}
child {node[rot] {In Honour of the Great Long Don Silver}}
child {node[rot] {In Honour of the Great Long Don Silver}}
}
child[concept color=orange!50!black, text=white, grow=280]{
node[rotL]{Bla}[clockwise from =310]
child {node[rot] {C.A}}
child {node[rot] {C.B}}
child {node[rot] {C.C}}
}
child[concept color=orange!25!black, text=white, grow=240]{
node[rotL]{Bla}[clockwise from =270]
child {node[rot] {D.A}}
child {node[rot] {D.B}}
child {node[rot] {D.C}}
}
child[concept color=orange!10!black, text=white, grow=200]{
node[rotL]{Bla}[clockwise from =230]
child {node[rot] {E.A}}
child {node[rot] {E.B}}
child {node[rot] {E.C}}
}
};
\end{tikzpicture}
\end{document}
Best Answer
This answer is similar to what Qrrbrbbirbel did with the node text rotation. But instead of rotating the node text, I modified the
edge from parent
path such that more information is squeezed in.The nodes that are needed to be rotated need the
mind your rotate
key.First the code and the result,
What is happening in a nutshell is; the regular parent - child node names are caught. Using their coordinates a rotation angle is computed. Also the size of the child is measured(roughly!). Then a temporary non-rotated node is placed on top of the child so that the connection bar doesn't get confused.
There are a few points I've left out;