Re: Grafici a torta con pgf-tikz

#45315
Up
0
Down
::


se ho ben capito cosa vuoi ottenere, ecco cosa devi modificare:

`% Pie chart

% Author: Robert Vollmert
\documentclass{article}

\usepackage{calc}
\usepackage{ifthen}
\usepackage{tikz}
%%%< \usepackage{verbatim} \usepackage[active,floats,tightpage]{preview} \PreviewEnvironment{tikzpicture} \setlength\PreviewBorder{5pt}% %%%>

\begin{document}
\begin{comment}
:Title: Pie chart
:Tags: Charts, Foreach

This example shows how to draw a basic pie chart. Note that labels are automatically
aligned and placed in a smart way. This makes the code more complicated. However,
charts can now bee drawn without worrying about overlapping labels.

:Author: Robert Vollmert
\end{comment}

\newcommand{\slice}[4]{
\pgfmathparse{0.5*#1+0.5*#2}
\let\midangle\pgfmathresult

% slice
\draw[thick,fill=black!10] (0,0) — (#1:1) arc (#1:#2:1) — cycle;

% outer label
\node[label=\midangle:#4] at (\midangle:1) {};

% inner label
\pgfmathparse{min((#2-#1-10)/110*(-0.3),0)}
\let\temp\pgfmathresult
\pgfmathparse{max(\temp,-0.5) + 0.8}
\let\innerpos\pgfmathresult
\node at (\midangle:\innerpos) {#3};
}

\begin{tikzpicture}[scale=3]
\newcounter{a}
\newcounter{b}
% \setlength{myp}{0pt}
\foreach \p/\t in {7/\textit{ante 1200}, 7/tra 1201 e 1300, 11/tra 1301 e 1400, 75/tra 1401 e 1600}
{

\setcounter{a}{\value{b}}
\addtocounter{b}{\p}
\pgfmathparse{\p/100}
\let\myp\pgfmathresult

\slice{\thea/100*360}
{\theb/100*360}
{\myp}{\t}
}

\end{tikzpicture}
\end{document}`

Go to top