pgf-tikz / pgf-pie

Some LaTeX macros for pie charts using the PGF/TikZ package.
Other
12 stars 9 forks source link

Misplaced label text caused by rotation #17

Open Arinerron opened 1 year ago

Arinerron commented 1 year ago

image

\begin{tikzpicture}[]
\pie[hide number=true,text=inside,scale=0.9,sum=auto,rotate=80,lines/.style={draw=\thecolor,none},hide number=true,before number=,after number=]{
    11/A,
    4/B,
    1/C,
    4/D
}
\end{tikzpicture}

(also, any idea why is the text aligned so weirdly loool)

muzimuzhi commented 1 year ago

Can't reproduce your result (only "A" has "11%"). Can you provide a complete example?

It seems the the text positioning issue is caused by the rotation

\documentclass{article}
\usepackage{pgf-pie}

\begin{document}
\noindent
\foreach \i in {0,10,...,90} {%
  \begin{tikzpicture}
    \pie[hide number=true,text=inside,sum=auto,rotate=\i,radius=2]{
        11/A,
        4/B,
        1/C,
        4/D
    }
  \end{tikzpicture}
}
\end{document}

image

Arinerron commented 1 year ago

The percent issue I found to be this stupid renewcommand on \pie that somehow made its way into our LaTeX document. I can close the issue if you want and open a separate one for the rotation issue, or rename this? (whichever you prefer)

muzimuzhi commented 1 year ago

Issue renamed.

The problem is caused by the newline \\ inserted between label text and number text. The newline should be omitted if one of label or number text is hidden.

I've prepare a patch, see https://github.com/pgf-tikz/pgf-pie/compare/master...muzimuzhi:pgf-pie:optional-newline, but first the workflow file main.yml need to be updated.

Arinerron commented 1 year ago

Nice catch haha, I'll test it next time I'm on my laptop. And thanks for the quick response and fix :) this library is a lifesaver tbh

Arinerron commented 1 year ago

lgtm, thanks again

muzimuzhi commented 1 year ago

Let's keep this open until a fix for it is released.

Leative commented 1 month ago

Just came across that problem, fixed it and wanted to provide a quick PR. But now I realize this issue and a fix already exist. What prevents this from being released?