summaryrefslogtreecommitdiff
path: root/support/pdbf-toolkit/pdbf.sty
blob: dd5a5b3e763e0f4dfc8430cfebf0502b8164dcbd (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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
\def\filedate{2015/02/23}
\def\fileversion{1.0}
\NeedsTeXFormat{LaTeX2e}
\AtEndOfPackage{\ProvidesPackage{pdbf}
             [\filedate\space\space\space\space\fileversion\space\space\space\space(Patrick Bender)]}
\RequirePackage{zref-savepos}
\RequirePackage{zref-abspage}
\RequirePackage{zref-user}
\RequirePackage{xcolor}
\RequirePackage{graphicx}
\RequirePackage{xstring}
\RequirePackage{xparse}
\RequirePackage{array}

\newcounter{visual}
\newcounter{overlay}
\stepcounter{visual}
\stepcounter{overlay}

\newwrite\pdbf@tempfile
\immediate\openout\pdbf@tempfile=pdbf-config.json
\immediate\write\pdbf@tempfile{[}

\AtBeginDocument{
	\newlength{\emptylen} 
	\settowidth{\emptylen}{} 
	
	\ifdim\emptylen=\paperwidth
	  \errmessage{^^J ^^J Error: paperwidth value missing! Did you forgot to specify the papersize via the geometry package? ^^J}%
	\fi
	
	\ifdim\emptylen=\paperheight
	  \errmessage{^^J ^^J Error: paperheight value missing! Did you forgot to specify the papersize via the geometry package? ^^J}%
	\fi
	
	\newwrite\pdbf@temp
	\immediate\openout\pdbf@temp=pdbf-dim.json
	\immediate\write\pdbf@temp{\@charlb "width": "\number\paperwidth",}
	\immediate\write\pdbf@temp{"height": "\number\paperheight" \@charrb}
	\immediate\closeout\pdbf@temp
}

\AtEndDocument{
	\immediate\write\pdbf@tempfile{]}
	\immediate\closeout\pdbf@tempfile
}

\zref@addprops{savepos}{abspage}

\DeclareRobustCommand\pdbf@save[1]{%
      \zsavepos{#1}%
}

%DataText
\define@key{pdbf}{color}{\def\pdbfDynamicTextColor{#1}}
\def\pdbfDynamicTextColor{blue}
\define@key{pdbf}{linkTo}{\def\pdbf@linkTo{#1}}
\def\pdbf@linkTo{}
\define@key{pdbf}{linkSelector}{\def\pdbf@linkSelector{#1}}
\def\pdbf@linkSelector{}
\define@key{pdbf}{linkLabel}{\def\pdbf@linkLabel{#1}}
\def\pdbf@linkLabel{}

%DataTable
\define@key{pdbf}{verticalLines}{\def\pdbf@verticalLines{#1}}
\def\pdbf@verticalLines{a}
\define@key{pdbf}{horizontalLinesHeader}{\def\pdbf@horizontalLinesHeader{#1}}
\def\pdbf@horizontalLinesHeader{a}
\define@key{pdbf}{horizontalLinesBody}{\def\pdbf@horizontalLinesBody{#1}}
\def\pdbf@horizontalLinesBody{a}

%Common
\define@key{pdbf}{name}{\def\pdbf@name{#1}}
\def\pdbf@name{}
\define@key{pdbf}{width}{\def\pdbf@width{#1}}
\define@key{pdbf}{height}{\def\pdbf@height{#1}}
\def\pdbf@xunitname{}
\define@key{pdbf}{xunit}{\StrSubstitute{\detokenize{#1}}{"}{\@backslashchar"}[\pdbf@xunitname]}
\def\pdbf@yunitname{}
\define@key{pdbf}{yunit}{\StrSubstitute{\detokenize{#1}}{"}{\@backslashchar"}[\pdbf@yunitname]}
\def\pdbf@options{{}}
\define@key{pdbf}{options}{\StrSubstitute{\detokenize{#1}}{"}{\@backslashchar"}[\pdbf@opt]\def\pdbf@options{{\pdbf@opt}}}
\def\pdbfQuality{1.0}
\define@key{pdbf}{quality}{\def\pdbfQuality{#1}}
\def\pdbf@chartType{Line}
\define@key{pdbf}{chartType}{\StrSubstitute{\detokenize{#1}}{"}{\@backslashchar"}[\pdbf@chartType]}
\define@key{pdbf}{customImage}{\def\pdbf@customImage{#1}}

%LineChart und BarChart
\def\pdbfLogscale{false}
\define@key{pdbf}{logscale}[true]{\def\pdbfLogscale{#1}}
\def\pdbfLegendpos{topright}
\define@key{pdbf}{legendpos}{\def\pdbfLegendpos{#1}}
\def\pdbf@includeZero{false}
\define@key{pdbf}{includeZero}{\def\pdbf@includeZero{#1}}
\def\pdbf@drawPoints{false}
\define@key{pdbf}{drawPoints}{\def\pdbf@drawPoints{#1}}
\def\pdbf@fillGraph{false}
\define@key{pdbf}{fillGraph}{\def\pdbf@fillGraph{#1}}
\def\pdbf@showRangeSelector{false}
\define@key{pdbf}{showRangeSelector}{\def\pdbf@showRangeSelector{#1}}

%BarChart
\def\pdbf@overlap{-1}
\define@key{pdbf}{overlap}[2]{\def\pdbf@overlap{#1}}

%Pivot
\def\pdbf@rows{[]}
\define@key{pdbf}{rows}{\StrSubstitute{\detokenize{#1}}{"}{\@backslashchar"}[\pdbf@rows]}
\def\pdbf@cols{[]}
\define@key{pdbf}{cols}{\StrSubstitute{\detokenize{#1}}{"}{\@backslashchar"}[\pdbf@cols]}
\def\pdbf@aggregation{Minimum}
\define@key{pdbf}{aggregation}{\StrSubstitute{\detokenize{#1}}{"}{\@backslashchar"}[\pdbf@aggregation]}
\def\pdbf@aggregationattribute{}
\define@key{pdbf}{aggregationattribute}{\StrSubstitute{\detokenize{#1}}{"}{\@backslashchar"}[\pdbf@aggregationattribute]}
\def\pdbf@aggregationBig{}
\define@key{pdbf}{aggregationBig}{\StrSubstitute{\detokenize{#1}}{"}{\@backslashchar"}[\pdbf@aggregationBig]}
\def\pdbf@aggregationattributeBig{}
\define@key{pdbf}{aggregationattributeBig}{\StrSubstitute{\detokenize{#1}}{"}{\@backslashchar"}[\pdbf@aggregationattributeBig]}

%Multiplot
\def\pdbf@xCount{0}
\define@key{pdbf}{xCount}{\StrSubstitute{\detokenize{#1}}{"}{\@backslashchar"}[\pdbf@xCount]}
\def\pdbf@yCount{0}
\define@key{pdbf}{yCount}{\StrSubstitute{\detokenize{#1}}{"}{\@backslashchar"}[\pdbf@yCount]}
\def\pdbf@leftArr{auto}
\define@key{pdbf}{leftArr}{\StrSubstitute{\detokenize{#1}}{"}{\@backslashchar"}[\pdbf@leftArr]}
\def\pdbf@rightArr{auto}
\define@key{pdbf}{rightArr}{\StrSubstitute{\detokenize{#1}}{"}{\@backslashchar"}[\pdbf@rightArr]}
\def\pdbf@topArr{auto}
\define@key{pdbf}{topArr}{\StrSubstitute{\detokenize{#1}}{"}{\@backslashchar"}[\pdbf@topArr]}
\def\pdbf@bottomArr{auto}
\define@key{pdbf}{bottomArr}{\StrSubstitute{\detokenize{#1}}{"}{\@backslashchar"}[\pdbf@bottomArr]}
\def\pdbf@xValues{}
\define@key{pdbf}{xValues}{\StrSubstitute{\detokenize{#1}}{"}{\@backslashchar"}[\pdbf@xValues]}
\def\pdbf@yValues{}
\define@key{pdbf}{yValues}{\StrSubstitute{\detokenize{#1}}{"}{\@backslashchar"}[\pdbf@yValues]}
\def\pdbf@yFirst{false}
\define@key{pdbf}{yFirst}[true]{\def\pdbf@yFirst{#1}}
\def\pdbf@forceXequal{false}
\define@key{pdbf}{forceXequal}[true]{\def\pdbf@forceXequal{#1}}
\def\pdbf@forceYequal{false}
\define@key{pdbf}{forceYequal}[true]{\def\pdbf@forceYequal{#1}}

%CSV
\define@key{pdbfCSV}{headers}{\StrSubstitute{\detokenize{#1}}{"}{\@backslashchar"}[\pdbf@headers]}
\def\pdbf@headers{[]}
\define@key{pdbfCSV}{quote}{\StrSubstitute{\detokenize{#1}}{"}{\@backslashchar"}[\pdbf@quote]}
\def\pdbf@quote{\@backslashchar"}
\define@key{pdbfCSV}{seperator}{\StrSubstitute{\detokenize{#1}}{"}{\@backslashchar"}[\pdbf@seperator]}
\def\pdbf@seperator{,}

%Chart, Pivot table, Multiplot Chart
\NewDocumentCommand\pdbf@chart{o m m m}{%
	\edef\pdbf@fontsave{\f@size}%
	\setkeys{pdbf}{#1}%
	\ifdefined \pdbf@width \else%
  		\errmessage{^^J ^^J Error: width value missing! ^^J}%
	\fi%
	\ifdefined \pdbf@height \else%
		\errmessage{^^J ^^J Error: height value missing! ^^J}%
	\fi%
	\StrSubstitute{#2}{"}{\@backslashchar"}[\pdbf@query]%
	\StrSubstitute{#3}{"}{\@backslashchar"}[\pdbf@queryB]%
	\edef\pdbf@tmpOverlay{Overlay\arabic{visual}}%
	{\fontsize{5pt}{1sp}\selectfont%
		\setlength\tabcolsep{1sp}%
		% Place Image
		\begin{tabular}{ccc}%
		\pdbf@save{Overlay\arabic{visual}1}&&\\%
		\ifdefined\pdbf@customImage%
				&\includegraphics[width=\pdbf@width, height=\pdbf@height]{\pdbf@customImage}&\\%
		\else%
				\IfFileExists{./Overlay\arabic{visual}.pdf}{%
			    		&\includegraphics[width=\pdbf@width, height=\pdbf@height, page=1]{./Overlay\arabic{visual}.pdf}&\\%
				}{%
			    		&\includegraphics[width=\pdbf@width, height=\pdbf@height, page=1]{./dummy.pdf}&\\%
				}%
		\fi%
		&&\zsavepos{Overlay\arabic{visual}2}\\%
		\end{tabular}%
		% Write part of pdbf-config.json
		\ifnum \value{overlay} > 1%
			\immediate\write\pdbf@tempfile{,\@charlb}%
		\else%
			\immediate\write\pdbf@tempfile{\@charlb}%
		\fi%
		\immediate\write\pdbf@tempfile{\space\space\space\space"name": "Overlay\arabic{visual}",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space"type": \@charlb}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space"C": "pdbf.json.#4",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space"I": \@charlb}%
		\ifdefined\pdbf@customImage%
				\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"customImage": "\pdbf@customImage",}%
		\fi%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"name": "\pdbf@name",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"linkTo": "\pdbf@linkTo",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"linkSelector": "\pdbf@linkSelector",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"linkLabel": "\pdbf@linkLabel",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"verticalLines": "\pdbf@verticalLines",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"horizontalLinesHeader": "\pdbf@horizontalLinesHeader",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"horizontalLinesBody": "\pdbf@horizontalLinesBody",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"logScale": \pdbfLogscale,}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"xUnitName": "\pdbf@xunitname",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"yUnitName": "\pdbf@yunitname",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"query": "\pdbf@query",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"queryB": "\pdbf@queryB",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"options": "\pdbf@options",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"quality": \pdbfQuality,}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"overlap": \pdbf@overlap,}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"legendpos": "\pdbfLegendpos",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"includeZero": \pdbf@includeZero,}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"drawPoints": \pdbf@drawPoints,}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"fillGraph": \pdbf@fillGraph,}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"showRangeSelector": \pdbf@showRangeSelector,}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"aggregation": "\pdbf@aggregation",}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"aggregationattribute": "\pdbf@aggregationattribute",}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"aggregationBig": "\pdbf@aggregationBig",}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"aggregationattributeBig": "\pdbf@aggregationattributeBig",}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"xCount": \pdbf@xCount,}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"yCount": \pdbf@yCount,}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"leftArr": "\pdbf@leftArr",}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"rightArr": "\pdbf@rightArr",}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"topArr": "\pdbf@topArr",}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"bottomArr": "\pdbf@bottomArr",}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"xValues": "\pdbf@xValues",}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"yValues": "\pdbf@yValues",}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"yFirst": \pdbf@yFirst,}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"forceXequal": \pdbf@forceXequal,}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"forceYequal": \pdbf@forceYequal,}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"cols": "\pdbf@cols",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"rows": "\pdbf@rows",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"chartType": "\pdbf@chartType",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"x1": \zposx{Overlay\arabic{visual}1},}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"x2": \zposx{Overlay\arabic{visual}2},}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"y1": \zposy{Overlay\arabic{visual}1},}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"y2": \zposy{Overlay\arabic{visual}2},}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"fontsize": \pdbf@fontsave,}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"page": \zref@extract{Overlay\arabic{visual}1}{abspage}}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\@charrb}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\@charrb}%
		\immediate\write\pdbf@tempfile{\@charrb}%
		\stepcounter{visual}%
		\stepcounter{overlay}%
	}%
	\put(-10000,0){abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789pdbf!\textasciitilde\textbraceleft\textbraceright\textbackslash\textasciicircum\textsection\textdollar\%\&/()=?\#+\textbar\textunderscore[].,;:\pdbf@tmpOverlay-}~%
	\relax
}

\NewDocumentCommand\chart{O{} o m}{%
{\pdbf@chart[#1]{#3}{\IfValueTF{#2}{#2}{#3}}{Chart}}%
}

\NewDocumentCommand\pivotTable{O{} o m}{%
{\pdbf@chart[#1]{#3}{\IfValueTF{#2}{#2}{#3}}{Pivot}}%
}

\NewDocumentCommand\multiplotChart{O{} o m}{%
{\pdbf@chart[#1]{#3}{\IfValueTF{#2}{#2}{#3}}{MultiplotChart}}%
}

%Datatext, Datatable, SQL, etc.
\NewDocumentCommand\pdbf@sqlmult{m m m m}{%
\setkeys{pdbf}{#4}%
\edef\pdbf@fontsave{\f@size}%
\edef\pdbf@fontskipsave{\the\baselineskip}%
\edef\pdbf@tabcolsep{\the\tabcolsep}%
{\fontsize{5pt}{1sp}\selectfont%
		\setlength\tabcolsep{1sp}%
		\begin{tabular}[t]{ccc}%
		\pdbf@save{Overlay\arabic{visual}1}&{\color{\pdbfDynamicTextColor}\fontsize{\pdbf@fontsave}{\pdbf@fontskipsave}\setlength\tabcolsep{\pdbf@tabcolsep}\selectfont#1}&\\%
		&&\zsavepos{Overlay\arabic{visual}2}\\%
		\end{tabular}%
		% Write part of pdbf-config.json
		\StrSubstitute{#2}{"}{\@backslashchar"}[\pdbf@query]%
		\StrSubstitute{#2}{"}{\@backslashchar"}[\pdbf@queryB]%
		\ifnum \value{overlay} > 1%
			\immediate\write\pdbf@tempfile{,\@charlb}%
		\else%
			\immediate\write\pdbf@tempfile{\@charlb}%
		\fi%
		\immediate\write\pdbf@tempfile{\space\space\space\space"name": "Overlay\arabic{visual}",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space"type": \@charlb}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space"C": "#3",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space"I": \@charlb}%
		\ifdefined\pdbf@customImage%
				\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"customImage": "\pdbf@customImage",}%
		\fi%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"name": "\pdbf@name",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"linkTo": "\pdbf@linkTo",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"linkSelector": "\pdbf@linkSelector",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"linkLabel": "\pdbf@linkLabel",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"verticalLines": "\pdbf@verticalLines",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"horizontalLinesHeader": "\pdbf@horizontalLinesHeader",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"horizontalLinesBody": "\pdbf@horizontalLinesBody",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"logScale": \pdbfLogscale,}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"xUnitName": "\pdbf@xunitname",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"yUnitName": "\pdbf@yunitname",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"query": "\pdbf@query",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"queryB": "\pdbf@queryB",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"options": "\pdbf@options",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"quality": \pdbfQuality,}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"overlap": \pdbf@overlap,}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"legendpos": "\pdbfLegendpos",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"includeZero": \pdbf@includeZero,}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"drawPoints": \pdbf@drawPoints,}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"fillGraph": \pdbf@fillGraph,}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"showRangeSelector": \pdbf@showRangeSelector,}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"aggregation": "\pdbf@aggregation",}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"aggregationattribute": "\pdbf@aggregationattribute",}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"aggregationBig": "\pdbf@aggregationBig",}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"aggregationattributeBig": "\pdbf@aggregationattributeBig",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"xCount": \pdbf@xCount,}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"yCount": \pdbf@yCount,}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"leftArr": "\pdbf@leftArr",}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"rightArr": "\pdbf@rightArr",}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"topArr": "\pdbf@topArr",}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"bottomArr": "\pdbf@bottomArr",}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"xValues": "\pdbf@xValues",}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"yValues": "\pdbf@yValues",}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"yFirst": \pdbf@yFirst,}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"forceXequal": \pdbf@forceXequal,}% 
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"forceYequal": \pdbf@forceYequal,}%  
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"cols": "\pdbf@cols",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"rows": "\pdbf@rows",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"chartType": "\pdbf@chartType",}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"x1": \zposx{Overlay\arabic{visual}1},}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"x2": \zposx{Overlay\arabic{visual}2},}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"y1": \zposy{Overlay\arabic{visual}1},}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"y2": \zposy{Overlay\arabic{visual}2},}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"fontsize": \pdbf@fontsave,}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"page": \zref@extract{Overlay\arabic{visual}1}{abspage}}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\@charrb}%
		\immediate\write\pdbf@tempfile{\space\space\space\space\@charrb}%
		\immediate\write\pdbf@tempfile{\@charrb}%
		\stepcounter{visual}%
		\stepcounter{overlay}%
}%
}

\NewDocumentCommand\sql{O{} o m}{%
\StrSubstitute{#3}{_}{$\string_$}[\pdbf@tmpstore]
{\pdbf@sqlmult{\IfValueTF{#2}{#2}{\pdbf@tmpstore}}{#3}{pdbf.json.Text}{#1}}%
}

\def\pdbf@csxdefaux#1{%
    \protected@write\@mainaux{}{%
       \string\expandafter\string\gdef
        \string\csname\space pdbf@Overlay\arabic{visual}\string\endcsname{\expandafter\detokenize\expandafter\expandafter\expandafter{#1}}%
    }%
}

\NewDocumentCommand\dataText{O{} m}{%
{\expandafter\ifx\csname pdbf@Overlay\arabic{visual}\endcsname\relax\pdbf@csxdefaux{dummy}\else\pdbf@csxdefaux{\csname pdbf@Overlay\arabic{visual}\endcsname}\fi%
\pdbf@sqlmult{\csname pdbf@Overlay\arabic{visual}\endcsname}{#2}{pdbf.json.DataText}{#1}}%
}

\NewDocumentCommand\dataTable{O{} m}{%
{\expandafter\ifx\csname pdbf@Overlay\arabic{visual}\endcsname\relax\pdbf@csxdefaux{dummy}\else\pdbf@csxdefaux{\csname pdbf@Overlay\arabic{visual}\endcsname}\fi%
\pdbf@sqlmult{\csname pdbf@Overlay\arabic{visual}\endcsname}{#2}{pdbf.json.DataTable}{#1}}%
}

%Database
\NewDocumentCommand\pdbf@db{O{} m m m m m}{%
	\setkeys{pdbfCSV}{#1}%
	\StrSubstitute{#2}{"}{\@backslashchar"}[\pdbf@valueA]%
	\StrSubstitute{#3}{"}{\@backslashchar"}[\pdbf@valueB]%
	\StrSubstitute{#4}{"}{\@backslashchar"}[\pdbf@valueC]%
	\StrSubstitute{#5}{"}{\@backslashchar"}[\pdbf@valueD]%
	\ifnum \value{overlay} > 1%
		\immediate\write\pdbf@tempfile{,\@charlb}%
	\else%
		\immediate\write\pdbf@tempfile{\@charlb}%
	\fi%
	\immediate\write\pdbf@tempfile{\space\space\space\space"name": "Database",}%
	\immediate\write\pdbf@tempfile{\space\space\space\space"type": \@charlb}%
	\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space"C": "pdbf.json.Database",}%
	\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space"I": \@charlb}%
	\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"type": #6,}%
	\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"value1": "\pdbf@valueA",}%
	\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"value2": "\pdbf@valueB",}%
	\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"value3": "\pdbf@valueC",}%
	\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"value4": "\pdbf@valueD",}%
	\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"headers": \pdbf@headers,}%
	\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"quote": "\pdbf@quote",}%
	\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\space\space\space\space"seperator": "\pdbf@seperator"}%
	\immediate\write\pdbf@tempfile{\space\space\space\space\space\space\space\space\@charrb}%
	\immediate\write\pdbf@tempfile{\space\space\space\space\@charrb}%
	\immediate\write\pdbf@tempfile{\@charrb}%
	\stepcounter{overlay}%
}

\NewDocumentCommand\dbSQLText{m}{%
	\pdbf@db{#1}{}{}{}{1}
}

\NewDocumentCommand\dbSQLFile{m}{%
	\pdbf@db{#1}{}{}{}{2}
}

\NewDocumentCommand\dbSQLJDBC{m m m m}{%
	\pdbf@db{#1}{#2}{#3}{#4}{3}
}

\NewDocumentCommand\dbCSVFile{O{} m m}{%
	\pdbf@db[#1]{#2}{#3}{}{}{4}
}

\endinput