blob: 7eb1b7193292d728c887763e3c2cc54ffd795693 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
% Copyright 2008 by Till Tantau
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.
%
% See the file doc/generic/pgf/licenses/LICENSE for more details.
\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/datavisualization/pgflibrarydatavisualization.barcharts.code.tex,v 1.3 2008/11/12 23:39:37 tantau Exp $
\usepgfmodule{datavisualization}
%
% This file defines additional data visualization classes.
%
\pgfooclass{candle stick visualizer}
{
\attribute attribute;
\attribute offset;
\attribute use path rise=\pgfsetfillcolor{white}\pgfusepath{fill,stroke};
\attribute use path fall=\pgfsetfillcolor{black}\pgfusepath{fill,stroke};
\attribute use path wick=\pgfusepath{stroke};
\method candle stick visualizer(#1) {
\pgfooeset{attribute}{#1}
\pgfoothis.set stick width(4pt)
}
\method default connects() {
\pgfoothis.get handle(\pgf@dv@me)
\pgfkeysvalueof{/pgf/data visualization/obj}.connect(\pgf@dv@me,visualize,visualize datapoint signal)
}
\method set stick width(#1) {
\pgfmathparse{#1}
\pgfmathdivide{\pgfmathresult}{2}
\let\pgf@dv@lib@w=\pgfmathresult
% Compute the normalized vector:
\pgfkeyssetvalue{/data point/\pgfoovalueof{attribute}}{1}
\pgfcanvaspositionofdatapoint%
\pgfsettocanvasposition\pgf@dv@lib@lower%
\pgfkeyssetvalue{/data point/\pgfoovalueof{attribute}}{10}
\pgfcanvaspositionofdatapoint%
\pgfsettocanvasposition\pgf@dv@lib@upper%
\pgf@process{\pgfpointnormalised{\pgfpointdiff{\pgf@dv@lib@upper}{\pgf@dv@lib@lower}}}%
% Rotate by 90 degrees
\pgf@xa=\pgf@x%
\pgf@x=-\pgf@dv@lib@w\pgf@y%
\pgf@y=\pgf@dv@lib@w\pgf@xa%
\edef\pgf@dv@lib@temp{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
\pgfoolet{offset}\pgf@dv@lib@temp
}
\method set use path rise(#1) {
\pgfooset{use path rise}{#1}
}
\method set use path fall(#1) {
\pgfooset{use path fall}{#1}
}
\method visualize() {
{
\pgfooget{attribute}\pgf@lib@attribute%
\pgfkeysgetvalue{/data point/\pgf@lib@attribute/low}\pgf@lib@low
\pgfkeysgetvalue{/data point/\pgf@lib@attribute/high}\pgf@lib@high
\pgfkeysgetvalue{/data point/\pgf@lib@attribute/entry}\pgf@lib@entry
\pgfkeysgetvalue{/data point/\pgf@lib@attribute/exit}\pgf@lib@exit
\ifx\pgf@lib@low\pgfutil@empty\pgf@dv@lib@cs@skiptrue\fi
\ifx\pgf@lib@low\relax\pgf@dv@lib@cs@skiptrue\fi
\ifx\pgf@lib@high\pgfutil@empty\pgf@dv@lib@cs@skiptrue\fi
\ifx\pgf@lib@high\relax\pgf@dv@lib@cs@skiptrue\fi
\ifx\pgf@lib@entry\pgfutil@empty\pgf@dv@lib@cs@skiptrue\fi
\ifx\pgf@lib@entry\relax\pgf@dv@lib@cs@skiptrue\fi
\ifx\pgf@lib@exit\pgfutil@empty\pgf@dv@lib@cs@skiptrue\fi
\ifx\pgf@lib@exit\relax\pgf@dv@lib@cs@skiptrue\fi
\ifpgf@dv@lib@cs@skip%
\else%
\begin{pgfscope}
% Ok, compute low point
\pgfkeyssetvalue{/data point/\pgf@lib@attribute}\pgf@lib@low
\pgfcanvaspositionofdatapoint%
\pgfsettocanvasposition\pgf@dv@lib@lowpoint%
% Ok, compute hight point
\pgfkeyssetvalue{/data point/\pgf@lib@attribute}\pgf@lib@high
\pgfcanvaspositionofdatapoint%
\pgfsettocanvasposition\pgf@dv@lib@highpoint%
% Compute entry and exit
\pgfkeyssetvalue{/data point/\pgf@lib@attribute}\pgf@lib@entry
\pgfcanvaspositionofdatapoint%
\pgfsettocanvasposition\pgf@dv@lib@entrypoint%
\pgfkeyssetvalue{/data point/\pgf@lib@attribute}\pgf@lib@exit
\pgfcanvaspositionofdatapoint%
\pgfsettocanvasposition\pgf@dv@lib@exitpoint%
\ifdim\pgf@lib@entry pt<\pgf@lib@exit pt\relax%
\pgf@dv@lib@risetrue%
\fi%
\ifpgf@dv@lib@rise
\let\pgf@dv@lib@a=\pgf@dv@lib@entrypoint
\let\pgf@dv@lib@b=\pgf@dv@lib@exitpoint
\else
\let\pgf@dv@lib@a=\pgf@dv@lib@exitpoint
\let\pgf@dv@lib@b=\pgf@dv@lib@entrypoint
\fi
% Start drawing...
\pgfpathmoveto{\pgf@dv@lib@lowpoint}
\pgfpathlineto{\pgf@dv@lib@a}
\pgfpathmoveto{\pgf@dv@lib@highpoint}
\pgfpathlineto{\pgf@dv@lib@b}
\pgfoovalueof{use path wick}
\pgfpathmoveto{\pgfpointadd{\pgf@dv@lib@a}{\pgfoovalueof{offset}}}
\pgfpathlineto{\pgfpointadd{\pgf@dv@lib@b}{\pgfoovalueof{offset}}}
\pgfpathlineto{\pgfpointadd{\pgf@dv@lib@b}{\pgfpointscale{-1}{\pgfoovalueof{offset}}}}
\pgfpathlineto{\pgfpointadd{\pgf@dv@lib@a}{\pgfpointscale{-1}{\pgfoovalueof{offset}}}}
\pgfpathclose
\ifpgf@dv@lib@rise
\pgfoovalueof{use path rise}
\else
\pgfoovalueof{use path fall}
\fi
\end{pgfscope}
\fi
}
}
\newif\ifpgf@dv@lib@cs@skip
\newif\ifpgf@dv@lib@rise
}
\endinput
|