]> sipb.mit.edu Git - ikiwiki.git/blob - doc/plugins/sparkline.mdwn
web commit by RichMorin
[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 # examples
24
25         \[[sparkline 1 3 5 -3 10 0 width=40 height=16
26         featurepoint="4,-3,red,3" featurepoint="5,10,green,3"]]
27
28 This creates a simple line graph, graphing several points.
29 [[if test="enabled(sparkline)" then="""
30 [[sparkline 1 3 5 -3 10 0 width=40 height=16
31 featurepoint="4,-3,red,3" featurepoint="5,10,green,3"]]
32 """]]
33 It will be drawn 40 pixels wide and 16 pixels high. The high point in the
34 line has a green marker, and the low point has a red marker.
35
36         \[[sparkline 1 -1(red) 1 -1(red) 1 1 1 -1(red) -1(red) style=bar barwidth=2
37         barspacing=1 height=13]]
38
39 This more complex example generates a bar graph. 
40 [[if test="enabled(sparkline)" then="""
41 [[sparkline 1 -1(red) 1 -1(red) 1 1 1 -1(red) -1(red)
42 style=bar barwidth=2 barspacing=1 height=13]]
43 """]]
44 The bars are 2 pixels wide, and separated by one pixel, and the graph is 13
45 pixels tall. Width is determined automatically for bar graphs. The points
46 with negative values are colored red, instead of the default black.
47
48 # usage
49
50 The form for the data points is "x,y", or just "y" if the x values don't
51 matter. Bar graphs can also add "(color)" to specify a color for that bar.
52
53 The following named parameters are recognised. Most of these are the same
54 as those used by the underlying sparkline library, which is documented in
55 more detail in [its wiki](http://sparkline.wikispaces.com/usage).
56
57 * `style` - Either "line" (the default) or "bar".
58 * `width` - Width of the graph in pixels. Only needed for line graphs.
59 * `height` - Height of the graph in pixels. Defaults to 16.
60 * `barwidth` - Width of bars in a bar graph. Default is 1 pixel.
61 * `barspacing` - Spacing between bars in a bar graph, in pixels. Default is
62   1 pixel.
63 * `ymin`, `ymax` - Minimum and maximum values for the Y axis. This is
64   normally calculated automatically, but can be explicitly specified to get
65   the same values for multiple related graphs.
66 * `featurepoint` - Adds a circular marker to a line graph, with optional
67   text. This can be used to label significant points.
68   
69   The value is a comma-delimited list of parameters specifying the feature
70   point: X value, Y value, color name, circle diameter, text (optional),
71   and text location (optional). Example: `featurepoint="3,5,blue,3"`
72   
73   Available values for the text location are: "top", "right", "bottom", and
74   "left".