support for dashed lines in graphs
[rrdtool.git] / doc / rrdgraph_graph.pod
1 =pod
2
3 =head1 NAME
4
5 rrdgraph_graph - rrdtool graph command reference
6
7 =head1 SYNOPSIS
8
9 B<PRINT>B<:>I<vname>B<:>I<format>
10
11 B<GPRINT>B<:>I<vname>B<:>I<format>
12
13 B<COMMENT>B<:>I<text>
14
15 B<VRULE>B<:>I<time>B<#>I<color>[B<:>I<legend>][B<:DASHED>[B<:dashes=>I<n_on>[,I<n_off>[,I<n_on>,I<n_off>,[...]]]][B<:dash-offset=>I<offset>]]
16
17 B<HRULE>B<:>I<value>B<#>I<color>[B<:>I<legend>][B<:DASHED>[B<:dashes=>I<n_on>[,I<n_off>[,I<n_on>,I<n_off>,[...]]]][B<:dash-offset=>I<offset>]]
18
19 B<LINE>[I<width>]B<:>I<value>[B<#>I<color>][B<:>[I<legend>][B<:STACK>]][B<:DASHED>[B<:dashes=>I<n_on>[,I<n_off>[,I<n_on>,I<n_off>,[...]]]][B<:dash-offset=>I<offset>]]
20
21 B<AREA>B<:>I<value>[B<#>I<color>][B<:>[I<legend>][B<:STACK>]]
22
23 B<TICK>B<:>I<vname>B<#>I<rrggbb>[I<aa>][B<:>I<fraction>[B<:>I<legend>]]
24
25 B<SHIFT>B<:>I<vname>B<:>I<offset>
26
27 B<TEXTALIGN>B<:>{B<left>|B<right>|B<justified>|B<center>}
28
29 B<PRINT>B<:>I<vname>B<:>I<CF>B<:>I<format> (deprecated)
30
31 B<GPRINT>B<:>I<vname>B<:>I<CF>B<:>I<format> (deprecated)
32
33 B<STACK>B<:>I<vname>B<#>I<color>[B<:>I<legend>] (deprecated)
34
35 =head1 DESCRIPTION
36
37 These instructions allow you to generate your image or report.
38 If you don't use any graph elements, no graph is generated.
39 Similarly, no report is generated if you don't use print options.
40
41 =head1 PRINT
42
43 =over 4
44
45
46 =item B<PRINT:>I<vname>B<:>I<format>[B<:strftime>]
47
48 Depending on the context, either the value component or the time
49 component of a B<VDEF> is printed using I<format>. It is an error
50 to specify a I<vname> generated by a B<DEF> or B<CDEF>.
51
52 Any text in I<format> is printed literally with one exception:
53 The percent character introduces a formatter string. This string
54 can be:
55
56 For printing values:
57
58 =over 4
59
60 =item B<%%>
61
62 just prints a literal '%' character
63
64 =item B<%#.#le>
65
66 prints numbers like 1.2346e+04. The optional integers # denote field
67 width and decimal precision.
68
69 =item B<%#.#lf>
70
71 prints numbers like 12345.6789, with optional field width
72 and precision.
73
74 =item B<%s>
75
76 place this after B<%le>, B<%lf> or B<%lg>. This will be replaced by the
77 appropriate SI magnitude unit and the value will be scaled
78 accordingly (123456 -> 123.456 k).
79
80 =item B<%S>
81
82 is similar to B<%s>. It does, however, use a previously defined
83 magnitude unit. If there is no such unit yet, it tries to define
84 one (just like B<%s>) unless the value is zero, in which case the magnitude
85 unit stays undefined. Thus, formatter strings using B<%S> and no B<%s>
86 will all use the same magnitude unit except for zero values.
87
88 =back
89
90 If you PRINT a VDEF value, you can also print the time associated with it by appending the string
91 B<:strftime> to the format. Note that rrdtool uses the strftime function of your OSs clibrary. This means that
92 the conversion specifier may vary. Check the manual page if you are uncertain. The following is a list of
93 conversion specifiers usually supported across the board. 
94
95 =over 4
96
97 =item B<%a>
98
99 The abbreviated weekday name according to the current locale.
100
101 =item B<%A>
102
103 The full weekday name according to the current locale.
104
105 =item B<%b>
106
107 The abbreviated month name according to the current locale.
108
109 =item B<%B>
110
111 The full month name according to the current locale.
112
113 =item B<%c>
114
115 The preferred date and time representation for the current locale.
116
117 =item B<%d>
118
119 The day of the month as a decimal number (range 01 to 31).
120
121 =item B<%H>
122
123 The hour as a decimal number using a 24-hour clock (range 00 to 23).
124
125 =item B<%I>
126
127 The hour as a decimal number using a 12-hour clock (range 01 to 12).
128
129 =item B<%j>
130
131 The day of the year as a decimal number (range 001 to 366).
132
133 =item B<%m>
134
135 The month as a decimal number (range 01 to 12).
136
137 =item B<%M>
138
139 The minute as a decimal number (range 00 to 59).
140
141 =item B<%p>
142
143 Either `AM' or `PM' according to the given time value, or the corresponding
144 strings for the current locale.  Noon is treated as `pm' and midnight as
145 `am'.  Note that in many locales and `pm' notation is unsupported and in
146 such cases %p will return an empty string.
147
148 =item B<%S>
149
150 The second as a decimal number (range 00 to 61).
151
152 =item B<%U>
153
154 The  week  number  of  the current year as a decimal number, range 00 to 53, starting with the
155 first Sunday as the first day of week 01. See also %V and %W.
156
157 =item B<%V>
158
159 The ISO 8601:1988 week number of the current year as a decimal number, range 01 to  53,  where
160 week  1 is the first week that has at least 4 days in the current year, and with Monday as the
161 first day of the week. See also %U and %W.
162
163 =item B<%w>
164
165 The day of the week as a decimal, range 0 to 6, Sunday being 0.  See also %u.
166
167 =item B<%W>
168
169 The week number of the current year as a decimal number, range 00 to  53,  starting  with  the
170 first Monday as the first day of week 01.
171
172 =item B<%x>
173
174 The preferred date representation for the current locale without the time.
175
176 =item B<%X>
177
178 The preferred time representation for the current locale without the date.
179
180 =item B<%y>
181
182 The year as a decimal number without a century (range 00 to 99).
183
184 =item B<%Y>
185
186 The year as a decimal number including the century.
187
188 =item B<%Z>
189
190 The time zone or name or abbreviation.
191
192 =item B<%%>
193
194 A literal `%' character.
195
196 =back
197
198 =item B<PRINT:>I<vname>B<:>I<CF>B<:>I<format>
199
200 I<Deprecated. Use the new form of this command in new scripts.>
201 The first form of this command is to be used with B<CDEF> I<vname>s.
202
203 =back
204
205 =head1 GRAPH
206
207 =over 4
208
209 =item B<GPRINT>B<:>I<vname>B<:>I<format>
210
211 This is the same as C<PRINT>, but printed inside the graph.
212
213 =item B<GPRINT>B<:>I<vname>B<:>I<CF>B<:>I<format>
214
215 I<Deprecated. Use the new form of this command in new scripts.>
216 This is the same as C<PRINT>, but printed inside the graph.
217
218 =item B<COMMENT>B<:>I<text>
219
220 Text is printed literally in the legend section of the graph. Note that in
221 RRDtool 1.2 you have to escape colons in COMMENT text in the same way you
222 have to escape them in B<*PRINT> commands by writing B<'\:'>.
223
224 =item B<VRULE>B<:>I<time>B<#>I<color>[B<:>I<legend>][B<:DASHED>[B<:dashes=>I<n_on>[,I<n_off>[,I<n_on>,I<n_off>,[...]]]][B<:dash-offset=>I<offset>]]
225
226 Draw a vertical line at I<time>.  Its color is composed from three
227 hexadecimal numbers specifying the rgb color components (00 is off, FF is
228 maximum) red, green and blue followed by an optional alpha. Optionally, a legend box and string is
229 printed in the legend section. I<time> may be a number or a variable
230 from a B<VDEF>. It is an error to use I<vname>s from B<DEF> or B<CDEF> here.
231 Dashed lines can be drawn using the B<DASHED> modifier. See B<LINE> for more
232 details.
233
234 =item B<HRULE>B<:>I<value>B<#>I<color>[B<:>I<legend>][B<:DASHED>[B<:dashes=>I<n_on>[,I<n_off>[,I<n_on>,I<n_off>,[...]]]][B<:dash-offset=>I<offset>]]
235
236 Draw a horizontal line at I<value>.  HRULE acts much like LINE except that
237 will have no effect on the scale of the graph. If a HRULE is outside the
238 graphing area it will just not be visible.
239
240 =item B<LINE>[I<width>]B<:>I<value>[B<#>I<color>][B<:>[I<legend>][B<:STACK>]][B<:DASHED>[B<:dashes=>I<n_on>[,I<n_off>[,I<n_on>,I<n_off>,[...]]]][B<:dash-offset=>I<offset>]]
241
242 Draw a line of the specified width onto the graph. I<width> can be a
243 floating point number. If the color is not specified, the drawing is done
244 'invisibly'. This is useful when stacking something else on top of this
245 line. Also optional is the legend box and string which will be printed in
246 the legend section if specified. The B<value> can be generated by B<DEF>,
247 B<VDEF>, and B<CDEF>.  If the optional B<STACK> modifier is used, this line
248 is stacked on top of the previous element which can be a B<LINE> or an
249 B<AREA>.
250
251 The B<DASHED> modifier enables dashed line style. Without any further options
252 a symmetric dashed line with a segment length of 5 pixels will be drawn.
253 The dash pattern can be changed using the B<dashes> parameter, which can be
254 followed by either one value or an even number (1, 2, 4, 6, ...) of positive
255 values. Each value provides the length of alternate I<n_on> and I<n_off>
256 portions of the stroke. The B<dash-offset> parameter specifies an I<offset>
257 into the pattern at which the stroke begins.
258
259 When you do not specify a color, you cannot specify a legend.  Should
260 you want to use STACK, use the "LINEx:<value>::STACK" form.
261
262 =item B<AREA>B<:>I<value>[B<#>I<color>][B<:>[I<legend>][B<:STACK>]]
263
264 See B<LINE>, however the area between the x-axis and the line will
265 be filled.
266
267 =item B<TICK>B<:>I<vname>B<#>I<rrggbb>[I<aa>][B<:>I<fraction>[B<:>I<legend>]]
268
269 Plot a tick mark (a vertical line) for each value of I<vname> that is
270 non-zero and not *UNKNOWN*. The I<fraction> argument specifies the length of
271 the tick mark as a fraction of the y-axis; the default value is 0.1 (10% of
272 the axis). Note that the color specification is not optional. The TICK marks normaly
273 start at the lower edge of the graphing area. If the fraction is negative they start
274 at the upper border of the graphing area.
275
276 =item B<SHIFT>B<:>I<vname>B<:>I<offset>
277
278 Using this command B<RRDtool> will graph the following elements
279 with the specified offset.  For instance, you can specify an
280 offset of S<( 7*24*60*60 = ) 604'800 seconds> to "look back" one
281 week. Make sure to tell the viewer of your graph you did this ...
282 As with the other graphing elements, you can specify a number or
283 a variable here.
284
285 =item B<TEXTALIGN>B<:>{B<left>|B<right>|B<justified>|B<center>}
286
287 Labels are placed below the graph. When they overflow to the left, they wrap
288 to the next line. By default, lines are justified left and right. The
289 B<TEXTALIGN> function lets you change this default. This is a command and
290 not an option, so that you can change the default several times in your
291 argument list.
292
293 =cut
294
295 # This section describes the curruently defunct
296 # PieChart code.
297 #
298 # =item B<PART>B<:>I<vname>B<#>I<rrggbb>[I<aa>][B<:>I<legend>]
299 #
300 # B<RRDtool> has now support for B<pie charts>. If you include the
301 # B<PART> command, the canvas is extended to make room for a chart.
302 # The size of the canvas is determined by the lesser of
303 # L<width and height|rrdgraph/item_Size>.
304 #
305 # Pie parts will be concatenated, the first one will start at the
306 # top and parts will be created clockwise.  The size of the part
307 # is defined by the value part of the L<VDEF|rrdgraph_data/VDEF>
308 # function.  It should return a number between 0 and 100, being a
309 # percentage.  Providing wrong input will produce undefined results.
310 #
311 #
312
313 =pod
314
315 =item B<STACK>B<:>I<vname>B<#>I<color>[B<:>I<legend>]
316
317 I<Deprecated.  Use the B<STACK> modifiers on the other commands.>
318
319 =back
320
321 B<Some notes on stacking>
322
323 When stacking, an element is not placed above the X-axis but rather
324 on top of the previous element.  There must be something to stack
325 upon.
326
327 You can use an B<invisible> LINE or AREA to stacked upon.
328
329 An B<unknown> value makes the entire stack unknown from that moment on.
330 You don't know where to begin (the unknown value) and therefore do
331 not know where to end.
332
333 If you want to make sure you will be displaying a certain variable,
334 make sure never to stack upon the unknown value.  Use a CDEF instruction
335 with B<IF> and B<UN> to do so.
336
337 =head1 NOTES on legend arguments
338
339 =head2 Escaping the colon
340
341 A colon ':' in a I<legend> argument will mark the end of the
342 legend. To enter a ':' as part of a legend, the colon must be escaped
343 with a backslash '\:'.  Beware that many environments process
344 backslashes themselves, so it may be necessary to write two
345 backslashes in order to one being passed onto rrd_graph.
346
347 =head2 String Formatting
348
349 The text printed below the actual graph can be formatted by appending special
350 escape characters at the end of a text. When ever such a character occurs,
351 all pending text is pushed onto the graph according to the character
352 specified.
353
354 Valid markers are: B<\j> for justified, B<\l> for left aligned, B<\r> for
355 right aligned, and B<\c> for centered. In the next section there is an
356 example showing how to use centered formatting.
357
358 B<\n> is a valid alias for B<\l> since incomplete parsing in earlier
359 versions of rrdtool lead to this behaviour and a number of people has been using it.
360
361 Normally there are two space characters inserted between every two items
362 printed into the graph. The space following a string can be suppressed by
363 putting a B<\g> at the end of the string. The B<\g> also ignores any space
364 inside the string if it is at the very end of the string. This can be used
365 in connection with B<%s> to suppress empty unit strings.
366
367  GPRINT:a:MAX:%lf%s\g
368
369 A special case is COMMENT:B<\s> which inserts some additional vertical space
370 before placing the next row of legends.
371
372 If you are using the proportional font in your graph, you can use tab
373 characters or the sequence B<\t> to line-up legend elements. Note that
374 the tabs inserted are relative to the start of the current legend
375 element!
376
377 Since RRDtool 1.3 is using Pango for rending text, you can use Pango markup.
378 Pango uses the xml B<span> tags for inline formatting instructions.:
379
380 A simple example of a marked-up string might be: 
381
382  <span foreground="blue" size="x-large">Blue text</span> is <i>cool</i>!
383
384 The complete list of attributes for the span tag (taken from the pango documentation):
385
386 =over
387
388 =item B<font_desc>
389
390 A font description string, such as "Sans Italic 12"; note that any other span attributes will override this description. So if you have "Sans Italic" and also a style="normal" attribute, you will get Sans normal, not italic.
391
392 =item B<font_family>
393
394 A font family name
395
396 =item B<face>
397
398 Synonym for font_family
399
400 =item B<size>
401
402 Font size in 1024ths of a point, or one of the absolute sizes 'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large', or one of the relative sizes 'smaller' or 'larger'. If you want to specify a absolute size, it's usually easier to take advantage of the ability to specify a partial font description using 'font_desc'; you can use font_desc='12.5' rather than size='12800'.
403
404 =item B<style>
405
406 One of 'normal', 'oblique', 'italic'
407
408 =item B<weight>
409
410 One of 'ultralight', 'light', 'normal', 'bold', 'ultrabold', 'heavy', or a numeric weight
411
412 =item B<variant>
413
414 'normal' or 'smallcaps'
415
416 =item B<stretch>
417
418 One of 'ultracondensed', 'extracondensed', 'condensed', 'semicondensed', 'normal', 'semiexpanded', 'expanded', 'extraexpanded', 'ultraexpanded'
419
420 =item B<foreground>
421
422 An RGB color specification such as '#00FF00' or a color name such as 'red'
423
424 =item B<background>
425
426 An RGB color specification such as '#00FF00' or a color name such as 'red'
427
428 =item B<underline>
429
430 One of 'none', 'single', 'double', 'low', 'error'
431
432 =item B<underline_color>
433
434 The color of underlines; an RGB color specification such as '#00FF00' or a color name such as 'red'
435
436 =item B<rise>
437
438 Vertical displacement, in 10000ths of an em. Can be negative for subscript, positive for superscript.
439
440 =item B<strikethrough>
441
442 'true' or 'false' whether to strike through the text
443
444 =item B<strikethrough_color>
445
446 The color of strikethrough lines; an RGB color specification such as '#00FF00' or a color name such as 'red'
447
448 =item B<fallback>
449
450 'true' or 'false' whether to enable fallback. If disabled, then characters will only be used from the closest matching font on the system. No fallback will be done to other fonts on the system that might contain the characters in the text. Fallback is enabled by default. Most applications should not disable fallback.
451
452 =item B<lang>
453
454 A language code, indicating the text language
455
456 =item B<letter_spacing>
457
458 Inter-letter spacing in 1024ths of a point.
459
460 =item B<gravity>
461
462 One of 'south', 'east', 'north', 'west', 'auto'.
463
464 =item B<gravity_hint>
465
466 One of 'natural', 'strong', 'line'.
467
468 =back
469
470 To save you some typing, there are also some shortcuts:
471
472 =over
473
474 =item B<b>
475
476 Bold
477
478 =item B<big>
479
480 Makes font relatively larger, equivalent to <span size="larger">
481
482 =item B<i>
483
484 Italic
485
486 =item B<s>
487
488 Strikethrough
489
490 =item B<sub>
491
492 Subscript
493
494 =item B<sup>
495
496 Superscript
497
498 =item B<small>
499
500 Makes font relatively smaller, equivalent to <span size="smaller">
501
502 =item B<tt>
503
504 Monospace font
505
506 =item B<u>
507
508 Underline 
509
510 =back
511
512 =head1 SEE ALSO
513
514 L<rrdgraph> gives an overview of how B<rrdtool graph> works.
515 L<rrdgraph_data> describes B<DEF>,B<CDEF> and B<VDEF> in detail.
516 L<rrdgraph_rpn> describes the B<RPN> language used in the B<?DEF> statements.
517 L<rrdgraph_graph> page describes all of the graph and print functions.
518
519 Make sure to read L<rrdgraph_examples> for tipsE<amp>tricks.
520
521 =head1 AUTHOR
522
523 Program by Tobias Oetiker E<lt>tobi@oetiker.chE<gt>
524
525 This manual page by Alex van den Bogaerdt E<lt>alex@ergens.op.het.netE<gt>