10

How can I create a "score counter" like the one in the picture, so that I can set a maximum for any circle and add as much concentric circles (counters regarding the same thing) as I want? The diameter of a circle should fit its content, so that we can use little or big items inside (e.g 4790K and G32558 in this case).

enter image description here

\documentclass{article}

\usepackage{tikz}

\begin{document}
    \begin{tikzpicture}

    \end{tikzpicture}
\end{document}

3 Answers 3

22

Edit: An amended version where cnt radius is really a radius!

Here is a solution using:

  • cnt radius key to fix the intern radius,
  • cnt min line width key to set the width of circles,
  • cnt max line width key to set the width of arcs,
  • cnt key to add a new modern counter,
  • cnt label style to customize the central label.

enter image description here

\documentclass[tikz]{standalone}
\tikzset{
  cnt radius/.store in=\minradius,
  cnt min line width/.store in=\minlinewidth,
  cnt max line width/.store in=\maxlinewidth,
  cnt add val/.code n args={3}{% arguments: color, diameter, proportion
    \begin{pgfinterruptpath}
    \draw[line width={\maxlinewidth*.8},draw=#1,line cap=round,
    ]
    (\tikzlastnode) ++(90:{(#2)/2}) arc(90:{90-((#3)*360)}:{(#2)/2});
    \end{pgfinterruptpath}
  },
  cnt/.style args={#1 color #2 with #3}{% arguments: number, color, proportion
    circle,inner sep=0,node contents={},draw=#2,line width=\minlinewidth,
    minimum size={2*\minradius+(#1*2*\maxlinewidth)},append after command={
      \pgfextra{\pgfkeysalso{/tikz/cnt add val={#2}{2*\minradius+(#1*2*\maxlinewidth)}{#3}}}
    },
  },
  cnt label/.style={text=#1,font=\sffamily\bfseries,yscale=1.2,align=flush center},
}

\begin{document}
\begin{tikzpicture}
  \begin{scope}[cnt radius=1.5cm,cnt min line width=.5mm,cnt max line width=3mm]
    \node[cnt=1 color lime with .7];
    \node[cnt=2 color orange with .8];
    \node[cnt=3 color cyan!50!black with .9];
    \node[cnt label=cyan!50!black,text width=3cm]{\Huge 4790K};
  \end{scope}
\end{tikzpicture}
\end{document}
5

Alternative soluton:

\documentclass[tikz,border=1mm]{standalone}
    \usetikzlibrary{calc}

    \begin{document}
\begin{tikzpicture}[
     start angle = 90,
    Score/.style = {name=#1,
                   shape=circle, inner sep=0pt, %draw,
                   font=\Large}
                   ]
    \def\scoreWIDTH{10mm}
\node[Score=c1] {4790K};
%score list
\foreach[count=\xi from 0] \i/\j in {red/0.9, blue/0.7, yellow/0.8}
{
\draw[\i]   (c1) circle (\scoreWIDTH+1.2*\xi mm);
\draw[line width=1mm,\i]
            (c1) + (0,\scoreWIDTH+1.2*\xi mm) arc[radius=\scoreWIDTH+1.2*\xi mm,
                                              delta angle=-\j*360];
}
\end{tikzpicture}
    \end{document}

Your score list and desired color you put in \foreach , line width is defined as parameter of \draw. For more color you need add \color or better \xcolor package and select desired color (similarly as is in answer of Guuk).

enter image description here

(Achieved result is in pdf far better)

5

One solution:

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{calc}

\usepackage{xcolor}

\begin{document}

\begin{tikzpicture}
\coordinate (orig) at (0,0);
% 
\def\decal {0.4cm}
\def\stepC {0.25cm}

% Current et max values
\def\VoltageC {1.3}
\def\VoltageMax {1.5}
\def\TempC {6.5}
\def\TempMax {8.0}
\def\PwC {4800sp}
\def\PwMax {5000sp}

% width for text inside
\def\textWIDTH {5cm}


%command for plotting  circles
\newcommand{\CircleScore}[4]{%
  \draw (orig) circle (#1);
  \draw[line width=5pt,#4] (orig) ++(90:#1) arc (90:90-360*#2/#3:#1);
}

\node[anchor=center,at=(orig),text width=\textWIDTH,text centered,rectangle](txtC){\textbf{blablalalallalalalalallaalalK}};

%plot circles
\CircleScore{\textWIDTH/2+\decal}{\VoltageC}{\VoltageMax}{green!50!black}
\CircleScore{\textWIDTH/2+\decal+\stepC}{\TempC}{\TempMax}{orange!50!black}
\CircleScore{\textWIDTH/2+\decal+2*\stepC}{\PwC}{\PwMax}{blue!50!black}

\end{tikzpicture}

\end{document}

Details: The fit is not automatic. You must specify the value of \textWIDTH. For other values of data, you must change values of the variables \VoltageC, \VoltageMax, \TempC, \TempMax, \PwC and \PwMax. This solution can be improve.

NB: I use sp unit when I specify "large" integer for avoiding dimension too large error

Result:

Example

0

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.