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
|
[[template id=plugin name=sparkline author="[[Joey]]"]]
[[tag type/chrome]]
This plugin allows for easily embedding sparklines into wiki pages. A
sparkline is a small word-size graphic chart, that is designed to be
inlined alongside text.
# requirements
The plugin uses the [Sparkline PHP Graphing Library](http://sparkline.org/)
as it has better output than the native perl sparkline library. Therefore,
to use the plugin, you will need:
* The Sparkline PHP Graphing Library, installed in php's path so that
php can find it when `sparkline/Sparkline.php` is required.
* The GD PHP module used by the Sparkline library.
* A "php" program in the path, that can run standalone php programs.
* [[cpan Digest::SHA1]]
On a Debian system, this can be accomplished by installing these packages:
`libsparkline-php` `php5-gd` `php5-cli` `libdigest-sha1-perl`
# examples
\[[sparkline 1 3 5 -3 10 0 width=40 height=16
featurepoint="4,-3,red,3" featurepoint="5,10,green,3"]]
This creates a simple line graph, graphing several points.
[[if test="enabled(sparkline)" then="""
[[sparkline 1 3 5 -3 10 0 width=40 height=16
featurepoint="4,-3,red,3" featurepoint="5,10,green,3"]]
"""]]
It will be drawn 40 pixels wide and 16 pixels high. The high point in the
line has a green marker, and the low point has a red marker.
\[[sparkline 1 -1(red) 1 -1(red) 1 1 1 -1(red) -1(red) style=bar barwidth=2
barspacing=1 height=13]]
This more complex example generates a bar graph.
[[if test="enabled(sparkline)" then="""
[[sparkline 1 -1(red) 1 -1(red) 1 1 1 -1(red) -1(red)
style=bar barwidth=2 barspacing=1 height=13]]
"""]]
The bars are 2 pixels wide, and separated by one pixel, and the graph is 13
pixels tall. Width is determined automatically for bar graphs. The points
with negative values are colored red, instead of the default black.
# usage
The form for the data points is "x,y", or just "y" if the x values don't
matter. Bar graphs can also add "(color)" to specify a color for that bar.
The following named parameters are recognised. Most of these are the same
as those used by the underlying sparkline library, which is documented in
more detail in [its wiki](http://sparkline.wikispaces.com/usage).
* `style` - Either "line" (the default) or "bar".
* `width` - Width of the graph in pixels. Only needed for line graphs.
* `height` - Height of the graph in pixels. Defaults to 16.
* `barwidth` - Width of bars in a bar graph. Default is 1 pixel.
* `barspacing` - Spacing between bars in a bar graph, in pixels. Default is
1 pixel.
* `ymin`, `ymax` - Minimum and maximum values for the Y axis. This is
normally calculated automatically, but can be explicitly specified to get
the same values for multiple related graphs.
* `featurepoint` - Adds a circular marker to a line graph, with optional
text. This can be used to label significant points.
The value is a comma-delimited list of parameters specifying the feature
point: X value, Y value, color name, circle diameter, text (optional),
and text location (optional). Example: `featurepoint="3,5,blue,3"`
Available values for the text location are: "top", "right", "bottom", and
"left".
|