4

I am able to create a diagram with Smart Diagram using the code

\begin{figure}[htp]
\centering
\smartdiagram[priority descriptive diagram]{%
text1\\text1,
text2\\text2,
text3\\text3,
text4\\text4
}
\end{figure}

My question are:

  1. how is possibile change the arrow orientation?
  2. how can I add a text box under the arrow?
3

Here is a quick fix using an auxiliary command:

\documentclass[border=10pt]{standalone}
\usepackage{smartdiagram}

\makeatletter
\NewDocumentCommand{\smartdiagramx}{r[] m}{%
    \StrCut{#1}{:}\diagramtype\option
    \IfStrEq{\diagramtype}{priority descriptive diagram}{% true-priority descriptive diagram
        \pgfmathparse{subtract(\sm@core@priorityarrowwidth,\sm@core@priorityarrowheadextend)}
        \pgfmathsetmacro\sm@core@priorityticksize{\pgfmathresult/2}
        \pgfmathsetmacro\arrowtickxshift{(\sm@core@priorityarrowwidth-\sm@core@priorityticksize)/2}
        \begin{tikzpicture}[every node/.style={align=center,let hypenation}]
        \foreach \smitem [count=\xi] in {#2}{\global\let\maxsmitem\xi}
        \foreach \smitem [count=\xi] in {#2}{%
            \edef\col{\@nameuse{color@\xi}}
            \node[description,drop shadow](module\xi)
            at (0,0+\xi*\sm@core@descriptiveitemsysep) {\smitem};
            \draw[line width=\sm@core@prioritytick,\col]
            ([xshift=-\arrowtickxshift pt]module\xi.base west)--
            ($([xshift=-\arrowtickxshift pt]module\xi.base west)-(\sm@core@priorityticksize pt,0)$);
        }%
        \coordinate (A) at (module1);
        \coordinate (B) at (module\maxsmitem);
        \CalcHeight(A,B){heightmodules}
        \pgfmathadd{\heightmodules}{\sm@core@priorityarrowheightadvance}
        \pgfmathsetmacro{\distancemodules}{\pgfmathresult}
        \pgfmathsetmacro\arrowxshift{\sm@core@priorityarrowwidth/2}
        \begin{pgfonlayer}{background}
        \node[priority arrow,rotate=180,transform shape] at ([xshift=-\arrowxshift pt]module\maxsmitem.north west){};
        \end{pgfonlayer}
        \end{tikzpicture}
    }{}% end-priority descriptive diagram
}%

\makeatother

\begin{document}
\smartdiagramx[priority descriptive diagram]{%
    text1\\text1,
    text2\\text2,
    text3\\text3,
    text4\\text4
}
\end{document}

The result:

enter image description here

Another version with text at the bottom and top-down fading:

\documentclass[border=10pt]{standalone}
\usepackage{smartdiagram}

\tikzfading[name=priorityarrowfadingdown,
top color=transparent!5,
bottom color=transparent!80
]

\tikzset{priority
arrow fill/.style={
  fill=gray,
  path fading=priorityarrowfadingdown
  }
}

\makeatletter
\NewDocumentCommand{\smartdiagramx}{r[] m m}{%
    \StrCut{#1}{:}\diagramtype\option
    \IfStrEq{\diagramtype}{priority descriptive diagram}{% true-priority descriptive diagram
        \pgfmathparse{subtract(\sm@core@priorityarrowwidth,\sm@core@priorityarrowheadextend)}
        \pgfmathsetmacro\sm@core@priorityticksize{\pgfmathresult/2}
        \pgfmathsetmacro\arrowtickxshift{(\sm@core@priorityarrowwidth-\sm@core@priorityticksize)/2}
        \begin{tikzpicture}[every node/.style={align=center,let hypenation}]
        \foreach \smitem [count=\xi] in {#2}{\global\let\maxsmitem\xi}
        \foreach \smitem [count=\xi] in {#2}{%
            \edef\col{\@nameuse{color@\xi}}
            \node[description,drop shadow](module\xi)
            at (0,0+\xi*\sm@core@descriptiveitemsysep) {\smitem};
            \draw[line width=\sm@core@prioritytick,\col]
            ([xshift=-\arrowtickxshift pt]module\xi.base west)--
            ($([xshift=-\arrowtickxshift pt]module\xi.base west)-(\sm@core@priorityticksize pt,0)$);
        }%
        \coordinate (A) at (module1);
        \coordinate (B) at (module\maxsmitem);
        \CalcHeight(A,B){heightmodules}
        \pgfmathadd{\heightmodules}{\sm@core@priorityarrowheightadvance}
        \pgfmathsetmacro{\distancemodules}{\pgfmathresult}
        \pgfmathsetmacro\arrowxshift{\sm@core@priorityarrowwidth/2}
        \begin{pgfonlayer}{background}
        \node[priority arrow,rotate=180,transform shape] (pr-arrow) at ([xshift=-\arrowxshift pt]module\maxsmitem.north west){};
        \end{pgfonlayer}
        \node[below] at (pr-arrow.tip){#3};
        \end{tikzpicture}
    }{}% end-priority descriptive diagram
}%

\makeatother

\begin{document}
\smartdiagramx[priority descriptive diagram]{%
    text1\\text1,
    text2\\text2,
    text3\\text3,
    text4\\text4
}{Text}
\end{document}

The result:

enter image description here

|improve this answer|||||
  • Wow, all of that just to invert the arrow? :P – Alenanno Jan 6 '16 at 15:31
  • @Alenanno: not really.. just added rotate=180,transform shape, but that required to have the rest of the code – Claudio Fiandrino Jan 6 '16 at 15:46
  • Ah. Since you're the maintainer, have you thought of including the inversion as an option? – Alenanno Jan 6 '16 at 15:49
  • 1
    @Alenanno: Sure.. unfortunately, I have a very long to do list for the package, but very little time at the moment. – Claudio Fiandrino Jan 6 '16 at 15:52
  • Ah sure. I was just wondering! :D keep up the good work. – Alenanno Jan 6 '16 at 15:53
0

This is another option, relatively easier

MWE:

\documentclass{article}
\usepackage{smartdiagram}
\begin{document}

\smartdiagramset{set color list={blue!40!yellow, blue!40!orange, blue!40!red, blue!40!purple, blue!40!gray}}
\tikzset{priority arrow/.append style={rotate=180,anchor=0,xshift=30,}}
\smartdiagram[priority descriptive diagram]{yellow, orange, red, purple, blue}

\end{document}

Output:

enter image description here

|improve this answer|||||
  • Is there a way to include a text below the arrow? – bajun65537 Jan 9 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.