]> sipb.mit.edu Git - ikiwiki.git/blob - doc/plugins/sparkline.mdwn
response
[ikiwiki.git] / doc / plugins / sparkline.mdwn
1 [[!template id=plugin name=sparkline author="[[Joey]]"]]
2 [[!tag type/chrome]]
3
4 This plugin allows for easily embedding sparklines into wiki pages. A
5 sparkline is a small word-size graphic chart, that is designed to be
6 inlined alongside text.
7
8 # requirements
9
10 The plugin uses the [Sparkline PHP Graphing Library](http://sparkline.org/)
11 as it has better output than the native perl sparkline library. Therefore,
12 to use the plugin, you will need:
13
14 * The Sparkline PHP Graphing Library, installed in php's path so that
15   php can find it when `sparkline/Sparkline.php` is required.
16 * The GD PHP module used by the Sparkline library.
17 * A "php" program in the path, that can run standalone php programs.
18 * [[!cpan Digest::SHA1]]
19
20 On a Debian system, this can be accomplished by installing these packages:
21 `libsparkline-php` `php5-gd` `php5-cli` `libdigest-sha1-perl`
22
23 This plugin also uses the [[!cpan Digest::SHA1]] perl module.
24
25 # examples
26
27         \[[!sparkline 1 3 5 -3 10 0 width=40 height=16
28         featurepoint="4,-3,red,3" featurepoint="5,10,green,3"]]
29
30 This creates a simple line graph, graphing several points.
31 [[!if test="enabled(sparkline)" then="""
32 [[!sparkline 1 3 5 -3 10 0 width=40 height=16
33 featurepoint="4,-3,red,3" featurepoint="5,10,green,3"]]
34 """]]
35 It will be drawn 40 pixels wide and 16 pixels high. The high point in the
36 line has a green marker, and the low point has a red marker.
37
38         \[[!sparkline 1 -1(red) 1 -1(red) 1 1 1 -1(red) -1(red) style=bar barwidth=2
39         barspacing=1 height=13]]
40
41 This more complex example generates a bar graph. 
42 [[!if test="enabled(sparkline)" then="""
43 [[!sparkline 1 -1(red) 1 -1(red) 1 1 1 -1(red) -1(red)
44 style=bar barwidth=2 barspacing=1 height=13]]
45 """]]
46 The bars are 2 pixels wide, and separated by one pixel, and the graph is 13
47 pixels tall. Width is determined automatically for bar graphs. The points
48 with negative values are colored red, instead of the default black.
49
50 # usage
51
52 The form for the data points is "x,y", or just "y" if the x values don't
53 matter. Bar graphs can also add "(color)" to specify a color for that bar.
54
55 The following named parameters are recognised. Most of these are the same
56 as those used by the underlying sparkline library, which is documented in
57 more detail in [its wiki](http://sparkline.wikispaces.com/usage).
58
59 * `style` - Either "line" (the default) or "bar".
60 * `width` - Width of the graph in pixels. Only needed for line graphs.
61 * `height` - Height of the graph in pixels. Defaults to 16.
62 * `barwidth` - Width of bars in a bar graph. Default is 1 pixel.
63 * `barspacing` - Spacing between bars in a bar graph, in pixels. Default is
64   1 pixel.
65 * `ymin`, `ymax` - Minimum and maximum values for the Y axis. This is
66   normally calculated automatically, but can be explicitly specified to get
67   the same values for multiple related graphs.
68 * `featurepoint` - Adds a circular marker to a line graph, with optional
69   text. This can be used to label significant points.
70   
71   The value is a comma-delimited list of parameters specifying the feature
72   point: X value, Y value, color name, circle diameter, text (optional),
73   and text location (optional). Example: `featurepoint="3,5,blue,3"`
74   
75   Available values for the text location are: "top", "right", "bottom", and
76   "left".