2

I am trying to create a Tikz node with some text that has the ‘data storage’ flowchart shape:

Data Storage or Stored Data Symbol

This is what I'm building on:

\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\tikzstyle{storage} = [rectangle, minimum width=3cm, minimum height=1cm, text width=3cm, text centered, draw=black]
\begin{tikzpicture}[node distance=2cm]
    \node (sto1) [storage] {Some text}
\end{tikzpicture}

I have been trying to get the data storage node shape, mainly referring to this question as well as this one, however I haven't succeeded in creating it.

2
  • 1
    Are you looking for \tikz\node[cylinder, aspect=.5, minimum height=5mm, cylinder uses custom fill, cylinder body fill=blue!30, draw] {}; ?
    – Kpym
    May 11, 2018 at 14:28
  • @Kpym This seems to create a cylinder which has the fill that I want but still the borders of a cylinder.
    – hb20007
    May 11, 2018 at 14:46

3 Answers 3

3
\documentclass[tikz,border=3.14mm]{standalone}
\makeatletter % https://tex.stackexchange.com/a/241737/121799
\tikzset{pics/named scope code/.style={code={\tikz@fig@mustbenamed%
  \begin{scope}[local bounding box/.expanded=\tikz@fig@name]#1\end{scope}%
}}}
\makeatother
\tikzset{pics/.cd,
  pic memory/.style={named scope code={
  \filldraw[fill=blue!30!gray!50](0,0) arc(90:270:0.5 and 1) --++(4,0) arc(-90:-270:0.5 and 1) --cycle
 node[pos=.6,below={1cm},anchor=center] {#1};
  }}
}
\begin{document}
\begin{tikzpicture}
\pic (memory1) at (0,0) {pic memory=Test text};
\draw[thick,blue,-latex] (memory1.west) -- ++(-2,0);
\draw[thick,red,-latex] (memory1.north) -- ++(-1,2);
\end{tikzpicture}
\end{document}

enter image description here

0
1

Something like this can be done with a rounded rectangle node:

\documentclass[tikz, border=1mm]{standalone}
\usetikzlibrary{shapes.misc}
\begin{document}
\begin{tikzpicture}[
    datastore/.style={draw, rounded rectangle, rounded rectangle east arc=concave, rounded rectangle arc length=150}
]

\node[datastore, minimum width=4cm, minimum height=1.5cm, fill=cyan!30, draw=cyan!70!black]{Example};
\end{tikzpicture}
\end{document}

enter image description here

1

To draw a flowchart symbol for "Storage", similar to the one mentioned in "display" shape for flowchart with tikz , you can use the following code.

  \documentclass{article}
  \usepackage[margin=0.5in]{geometry}
  \usepackage{pgfplots}
  \usepackage{tikz}
  \usetikzlibrary{shapes.geometric, arrows}
  
  \tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, text 
   width=3cm, draw=orange, fill=orange!20]
  \tikzstyle{arrow} = [thick,->,>=stealth]
  
  \makeatletter
  
  \pgfdeclareshape{display}
  {
    \inheritsavedanchors[from=rectangle] % this is nearly a rectangle
    \inheritanchorborder[from=rectangle]
    \inheritanchor[from=rectangle]{north}
    \inheritanchor[from=rectangle]{west}
    \inheritanchor[from=rectangle]{east}
    \inheritanchor[from=rectangle]{south}
    \inheritanchor[from=rectangle]{center}
    \inheritbackgroundpath[from=rectangle]
    \backgroundpath{
      % points
      \southwest \pgf@xa=\pgf@x \pgf@ya=\pgf@y
      \northeast \pgf@xb=\pgf@x \pgf@yb=\pgf@y
      % dimensions
      \pgfmathsetlength{\pgfutil@tempdima}{\pgf@xb-\pgf@xa}
      \pgfmathsetlength{\pgfutil@tempdimb}{\pgf@yb-\pgf@ya}
      % path
      \pgfpathmoveto{\pgfpointadd{\pgfqpoint{\pgf@xa}{\pgf@ya}}{\pgfqpoint{-0.2\pgfutil@tempdima} 
       {0pt}}}
          \pgfpatharc{-90}{90}{0.2\pgfutil@tempdima and 0.5\pgfutil@tempdimb}
  
      \pgfpathlineto{\pgfpointadd{\pgfqpoint{\pgf@xa}{\pgf@yb}}{\pgfqpoint{0.8\pgfutil@tempdima} 
      {0pt}}}    
      \pgfpathlineto{\pgfpointadd{\pgfqpoint{\pgf@xb}{\pgf@yb}}{\pgfqpoint{-0.2\pgfutil@tempdima} 
       {0pt}}}
      \pgfpatharc{90}{-90}{0.2\pgfutil@tempdima and 0.5\pgfutil@tempdimb}
      \pgfpathlineto{\pgfpointadd{\pgfqpoint{\pgf@xb}{\pgf@ya}}{\pgfqpoint{-0.2\pgfutil@tempdima} 
      {0pt}}}
      \pgfpathlineto{\pgfpointadd{\pgfqpoint{\pgf@xa}{\pgf@ya}}{\pgfqpoint{0.8\pgfutil@tempdima} 
      {0pt}}}
      \pgfpathclose    
    }
  }
  \makeatother
  
  \tikzstyle{disp} = [display, draw, fill = cyan!20, 
  text width = 5em, align=center, minimum height = 3.5em]
  
  
  \pgfplotsset{width=10cm, compat=1.9}
  \begin{document}
  \begin{tikzpicture}[node distance=2cm]
  \node (disp) [disp] {Storage};
  \node (pro2b) [process, right of = disp, xshift=2cm] {Process 2b};
  \draw [arrow] (disp) -- (pro2b);
  \end{tikzpicture}
  \end{document}
  

enter image description here

1
  • Welcome to TeX.SE!
    – Mensch
    Mar 25 at 20:11

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.