|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
\notation (gauge or progress bar)Hi all,
I'm experiencing a problem with some old code that used to work using TeXlive 2008 but not any more using TeXlive 2009. The idea is, that typing \notation{7/10} would produce, for instance, 7 blue rectangles followed with 3 grey rectangles, like a gauge or a progress bar. Here's the error i'm getting using texlive 2009: ! Use of \pgf@lib@dec@parsemark doesn't match its definition. <argument> b etween positions 0 and 1 step \note@sep with { \node [inner sep... l.142 ...rlé \notation{7/10}\hfill{}\vspace{0pt}} The source code follows ; I'm not especially proud of it, so i'd be glad if someone could give me a hand and even happier with a simpler solution to achieve the same results. Thanks very much in advance, Nicolas %========== \newlength\note@sep \newlength\firststep \newlength\laststep \newlength\tickheight \pgfkeys{ /note/.code args={#1/#2}{\def\notea{#1}\def\noteb{#2}}, /note/tick/.initial=rectangle, /note/tick size/.cd,.default=1ex, .code={% \def\ticksize{#1}% \pgfmathsetlength\tickheight{(1.1ex-\ticksize)/2}}, } \pgfkeys{/note/tick size} \tikzset{ rects/.style 2 args={% %decorate, postaction={decorate}, decoration={markings, mark=between positions 0 and 1 step #2 with { %\arrow[draw=#1]{>} \node [inner sep=0, outer sep=0,\pgfkeysvalueof{/note/tick},minimum size=\ticksize, text width=, fill=#1]{}; }% }% }% } \newcommand\notation[1]{ \raisebox{\tickheight}{% \begin{tikzpicture} \pgfkeys{/note=#1} \pgfmathsetlength\note@sep{\ticksize*1.33} \pgfmathsetlength\firststep{\note@sep*\notea} \pgfmathsetlength\laststep{\note@sep*(\noteb-1)} \fill[rects={\themecolor{light2}}{\note@sep}] (0,0)--(\firststep,0); \fill[rects={\themecolor{dark1}}{\note@sep}] (\firststep,0)--(\laststep,0); \end{tikzpicture} }} %========== ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
|
|
Re: \notation (gauge or progress bar)Hi,
Not sure what the problem is. Sorry. However, it being an unusually slow day, how about this: \documentclass{article} \usepackage{tikz} \begin{document} \makeatletter \pgfkeys{/progress bar/.cd, .unknown/.code={\expandafter\tikzset\expandafter{\pgfkeyscurrentname=#1}}, completed/.code args={#1/#2}{\def\pb@completed{#1}\def\pb@total{#2}}, completed=0/10, completed block/.style={ draw=none, red!65!black }, to do block/.style={ draw=none, fill=blue!50!black }, every block/.style={ fill }, block width/.initial=1ex, block height/.initial=1.5ex, block sep/.initial=0.5ex, go left/.code={ \def\pb@xfactor{1} \def\pb@yfactor{0} }, go right/.code={ \def\pb@xfactor{1} \def\pb@yfactor{0} }, go up/.code={ \def\pb@xfactor{0} \def\pb@yfactor{1} }, go down/.code={ \def\pb@xfactor{0} \def\pb@yfactor{-1} }, go right } \newcommand\progressbar[1][]{% \tikz{% \pgfkeys{/progress bar/.cd, #1}% \foreach\pb@i in{1,...,\pb@total}{ \ifnum\pb@i>\pb@completed \pgfkeys{/progress bar/current block/.style={/progress bar/to do block}} \else \pgfkeys{/progress bar/current block/.style={/progress bar/completed block}} \fi \path [ xshift=\pgfkeysvalueof{/progress bar/block sep}*(\pb@i-1)*\pb@xfactor, xshift=\pgfkeysvalueof{/progress bar/block width}*(\pb@i-1)*\pb@xfactor, yshift=\pgfkeysvalueof{/progress bar/block sep}*(\pb@i-1)*\pb@yfactor, yshift=\pgfkeysvalueof{/progress bar/block height}*(\pb@i-1)*\pb@yfactor, /progress bar/.cd, every block/.try, current block/.try ] (0,0) rectangle +(\pgfkeysvalueof{/progress bar/block width},\pgfkeysvalueof{/progress bar/block height}); } }% } \makeatother \progressbar[completed=9/10] \progressbar[completed=7/10, go up] \progressbar[completed=5/10, go down, to do block/.style={fill=green!70!black}] \progressbar[completed=5/10, go left, every block/.append style={rounded corners=0.25ex}] \end{document} Hope this helps Mark 2009/11/5 Nicolas Girard <girard.nicolas@...>: > Hi all, > I'm experiencing a problem with some old code that used to work using > TeXlive 2008 but not any more using TeXlive 2009. > The idea is, that typing \notation{7/10} would produce, for instance, 7 > blue rectangles followed with 3 grey rectangles, like a gauge or a progress bar. > > Here's the error i'm getting using texlive 2009: > > ! Use of \pgf@lib@dec@parsemark doesn't match its definition. > <argument> b > etween positions 0 and 1 step \note@sep with { \node [inner > sep... > l.142 ...rlé \notation{7/10}\hfill{}\vspace{0pt}} > > The source code follows ; I'm not especially proud of it, so i'd be glad if > someone could give me a hand and even happier with a simpler solution to > achieve the same results. > > Thanks very much in advance, > Nicolas > > > %========== > \newlength\note@sep > \newlength\firststep > \newlength\laststep > \newlength\tickheight > \pgfkeys{ > /note/.code args={#1/#2}{\def\notea{#1}\def\noteb{#2}}, > /note/tick/.initial=rectangle, > /note/tick size/.cd,.default=1ex, > .code={% > \def\ticksize{#1}% > \pgfmathsetlength\tickheight{(1.1ex-\ticksize)/2}}, > } > \pgfkeys{/note/tick size} > > \tikzset{ > rects/.style 2 args={% > %decorate, > postaction={decorate}, > decoration={markings, > mark=between positions 0 and 1 step #2 with { > %\arrow[draw=#1]{>} > \node [inner sep=0, outer > sep=0,\pgfkeysvalueof{/note/tick},minimum size=\ticksize, > text width=, > fill=#1]{}; > }% > }% > }% > } > > \newcommand\notation[1]{ > \raisebox{\tickheight}{% > \begin{tikzpicture} > \pgfkeys{/note=#1} > \pgfmathsetlength\note@sep{\ticksize*1.33} > \pgfmathsetlength\firststep{\note@sep*\notea} > \pgfmathsetlength\laststep{\note@sep*(\noteb-1)} > \fill[rects={\themecolor{light2}}{\note@sep}] (0,0)--(\firststep,0); > \fill[rects={\themecolor{dark1}}{\note@sep}] > (\firststep,0)--(\laststep,0); > \end{tikzpicture} > }} > %========== > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > pgf-users mailing list > pgf-users@... > https://lists.sourceforge.net/lists/listinfo/pgf-users > ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
|
|
Re: \notation (gauge or progress bar)2009/11/5 Mark Wibrow <m.wibrow@...>:
> Hi, > > Not sure what the problem is. Sorry. > > However, it being an unusually slow day, how about this: > Wow ! Fantastic ! Very nice piece of code, thanks for your efforts ! It might be a good addition to the Tikz example gallery ( http://www.texample.net/tikz/examples/ ) Thanks again, Nicolas ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
|
|
Re: \notation (gauge or progress bar)Hi,
This is much more general solution where an arbitrary path can be used for the progress bar, and arbitrary code can be used for each block: \documentclass{article} \usepackage{tikz} \usetikzlibrary{decorations} \begin{document} \makeatletter \tikzset{ block width/.code=\pgfmathsetlengthmacro\progressbarblockwidth{#1}, block height/.code=\pgfmathsetlengthmacro\progressbarblockheight{#1}, block sep/.code=\pgfmathsetlengthmacro\progressbarblocksep{#1}, block width=1ex, block height=1ex, block sep=0.5ex, completed block/.style={ draw=none, fill=red!75!black }, remaining block/.style={ draw=none, fill=blue!75!black }, every block/.style={ }, completed/.code args={#1/#2}{% \def\progressbarcompleted{#1}% \def\progressbartotal{#2}% \pgf@x=\progressbarblockwidth\relax% \advance\pgf@x by\progressbarblocksep\relax% \c@pgf@counta=#2\relax% \pgf@x=\c@pgf@counta\pgf@x \edef\progressbarlength{\the\pgf@x} }, completed=0/10, block/.store in=\progresbarblockcode, block={ \path [current block] (-\progressbarblockwidth/2,-\progressbarblockheight/2) rectangle +(\progressbarblockwidth, \progressbarblockheight); }, path/.store in=\progressbarpath, go right/.style={ path={ (0,0) -- (\progressbarlength, 0) } }, go left/.style={ path={ (0,0) -- (-\progressbarlength, 0) } }, go up/.style={ path={ (0,0) -- (0,\progressbarlength) } }, go down/.style={ path={ (0,0) -- (0,-\progressbarlength) } }, go clockwise from/.style={ path={ (0,0) arc (#1:#1-360:0.1591549*\progressbarlength) } }, go anticlockwise from/.style={ path={ (0,0) arc (#1:#1+360:0.1591549*\progressbarlength) } }, go right, } \newcount\progressbarcount \pgfdeclaredecoration{progress bar}{initial}{ \state{initial} [ width=0pt, persistent precomputation={% \ifdim\progressbarlength=\pgfdecoratedpathlength\relax% \else \pgf@x=\pgfdecoratedpathlength, \divide\pgf@x by\progressbartotal \advance\pgf@x by-\progressbarblockwidth \ifdim0pt>\pgf@x% \pgf@x=1sp\relax% \fi% \edef\progressbarblocksep{\the\pgf@x}% \fi% \progressbarcount=0 }, next state=do block ]{} \state{do block} [ width=\progressbarblockwidth, persistent postcomputation={\advance\progressbarcount by1}, next state=do sep ] { \ifnum\progressbarcompleted>\progressbarcount \tikzset{current block/.style={every block/.try, completed block}}% \else \tikzset{current block/.style={every block/.try, remaining block}}% \fi \progresbarblockcode } \state{do sep} [ width=\progressbarblocksep, next state=do block ] {} \state{final}{} } \newcommand\progressbar[1][]{% \unskip% \tikz\path[decoration={progress bar}, decorate, #1] \progressbarpath; \ignorespaces% } \makeatother \parindent=0pt \foreach \i in {0,...,10} { \progressbar[completed=\i/10] } \foreach \i in {0,...,15} { \progressbar[completed=\i/15, go clockwise from=90] } \foreach \i in {0,...,15} { \progressbar[completed=\i/15, path={(0,0) .. controls (0,1) and (0.75,1) .. (0.75,2.5)}] } \end{document} Regards Mark ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
|
|
Re: \notation (gauge or progress bar)Hi,
In answer to the original question, the reason why the original code failed was because the step argument was a macro, for example: mark=between positions 0 and 1 step \somemacro width {...} Because the space after \somemacro is ignored by the TeX parser, the TikZ parser chokes as it is expecting one. The solution here is to use parenthesis as the expression is parsed by the mathematical engine: mark=between positions 0 and 1 step (\somemacro) width {...} Anyway, the markings decoration is powerful enough to do what was required. In what is shown below everything is not paramaterised, but it is simple to see how it could be. \documentclass{article} \usepackage{tikz} \usetikzlibrary{decorations.markings} \begin{document} \tikzset{ completed/.style args={#1/#2}{ decoration={ markings, mark=between positions 0 and 1 step (1/#2) with { \ifnum\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}>#1\relax% \pgfkeysvalueof{/tikz/remaining block code} \else \pgfkeysvalueof{/tikz/completed block code} \fi } }, decorate }, completed block code/.initial={ \draw circle (2pt); }, remaining block code/.initial={ \draw (-2pt,-2pt) -- (2pt,2pt); \draw (-2pt,2pt) -- (2pt,-2pt); } } \begin{tikzpicture} \path [completed=5/10] (0,0) -- (3,2); \end{tikzpicture} \end{document} Regards Mark ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
|
|
Re: \notation (gauge or progress bar)Obviously I meant
mark=between positions 0 and 1 step (\somemacro) with {...} tha is, `with' not `width'. 2009/11/7 Mark Wibrow <m.wibrow@...>: > Hi, > > In answer to the original question, the reason why the original code > failed was because the step argument was a macro, for example: > > mark=between positions 0 and 1 step \somemacro width {...} > > Because the space after \somemacro is ignored by the TeX parser, the > TikZ parser chokes as it is expecting one. The solution here is to use > parenthesis as the expression is parsed by the mathematical engine: > > mark=between positions 0 and 1 step (\somemacro) width {...} > > Anyway, the markings decoration is powerful enough to do what was > required. In what is shown below everything is not paramaterised, but > it is simple to see how it could be. > > > \documentclass{article} > > \usepackage{tikz} > \usetikzlibrary{decorations.markings} > > \begin{document} > > \tikzset{ > completed/.style args={#1/#2}{ > decoration={ > markings, > mark=between positions 0 and 1 step (1/#2) with { > \ifnum\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}>#1\relax% > \pgfkeysvalueof{/tikz/remaining block code} > \else > \pgfkeysvalueof{/tikz/completed block code} > \fi > } > }, > decorate > }, > completed block code/.initial={ > \draw circle (2pt); > }, > remaining block code/.initial={ > \draw (-2pt,-2pt) -- (2pt,2pt); > \draw (-2pt,2pt) -- (2pt,-2pt); > } > } > > \begin{tikzpicture} > \path [completed=5/10] (0,0) -- (3,2); > \end{tikzpicture} > > \end{document} > > > Regards > > Mark > ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
|
|
Re: \notation (gauge or progress bar)And...it should be
mark=between positions 0 and 1 step (1/(#2-1)) with { \ifnum\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}>#1\relax% \pgfkeysvalueof{/tikz/remaining block code} \else \pgfkeysvalueof{/tikz/completed block code} \fi } otherwise you get 1 too many blocks 2009/11/7 Mark Wibrow <m.wibrow@...>: > Obviously I meant > > mark=between positions 0 and 1 step (\somemacro) with {...} > > tha is, `with' not `width'. > > > 2009/11/7 Mark Wibrow <m.wibrow@...>: >> Hi, >> >> In answer to the original question, the reason why the original code >> failed was because the step argument was a macro, for example: >> >> mark=between positions 0 and 1 step \somemacro width {...} >> >> Because the space after \somemacro is ignored by the TeX parser, the >> TikZ parser chokes as it is expecting one. The solution here is to use >> parenthesis as the expression is parsed by the mathematical engine: >> >> mark=between positions 0 and 1 step (\somemacro) width {...} >> >> Anyway, the markings decoration is powerful enough to do what was >> required. In what is shown below everything is not paramaterised, but >> it is simple to see how it could be. >> >> >> \documentclass{article} >> >> \usepackage{tikz} >> \usetikzlibrary{decorations.markings} >> >> \begin{document} >> >> \tikzset{ >> completed/.style args={#1/#2}{ >> decoration={ >> markings, >> mark=between positions 0 and 1 step (1/#2) with { >> \ifnum\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}>#1\relax% >> \pgfkeysvalueof{/tikz/remaining block code} >> \else >> \pgfkeysvalueof{/tikz/completed block code} >> \fi >> } >> }, >> decorate >> }, >> completed block code/.initial={ >> \draw circle (2pt); >> }, >> remaining block code/.initial={ >> \draw (-2pt,-2pt) -- (2pt,2pt); >> \draw (-2pt,2pt) -- (2pt,-2pt); >> } >> } >> >> \begin{tikzpicture} >> \path [completed=5/10] (0,0) -- (3,2); >> \end{tikzpicture} >> >> \end{document} >> >> >> Regards >> >> Mark >> > ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
| Free embeddable forum powered by Nabble | Forum Help |