]> sipb.mit.edu Git - ikiwiki.git/blob - underlays/basewiki/directive/sparkline.mdwn
move example back
[ikiwiki.git] / underlays / basewiki / directive / sparkline.mdwn
1 The `sparkline` directive is supplied by the [[!iki plugins/sparkline]] plugin.
2
3 This directive allows for embedding sparklines into wiki pages. A
4 sparkline is a small word-size graphic chart, that is designed to be
5 inlined alongside text.
6
7 # examples
8
9         \[[!sparkline 1 3 5 -3 10 0 width=40 height=16
10         featurepoint="4,-3,red,3" featurepoint="5,10,green,3"]]
11
12 This creates a simple line graph, graphing several points.
13 [[!if test="enabled(sparkline)" then="""
14 [[!sparkline 1 3 5 -3 10 0 width=40 height=16
15 featurepoint="4,-3,red,3" featurepoint="5,10,green,3"]]
16 """]]
17 It will be drawn 40 pixels wide and 16 pixels high. The high point in the
18 line has a green marker, and the low point has a red marker.
19
20         \[[!sparkline 1 -1(red) 1 -1(red) 1 1 1 -1(red) -1(red) style=bar barwidth=2
21         barspacing=1 height=13]]
22
23 This more complex example generates a bar graph. 
24 [[!if test="enabled(sparkline)" then="""
25 [[!sparkline 1 -1(red) 1 -1(red) 1 1 1 -1(red) -1(red)
26 style=bar barwidth=2 barspacing=1 height=13]]
27 """]]
28 The bars are 2 pixels wide, and separated by one pixel, and the graph is 13
29 pixels tall. Width is determined automatically for bar graphs. The points
30 with negative values are colored red, instead of the default black.
31
32 # usage
33
34 The form for the data points is "x,y", or just "y" if the x values don't
35 matter. Bar graphs can also add "(color)" to specify a color for that bar.
36
37 The following named parameters are recognised. Most of these are the same
38 as those used by the underlying sparkline library, which is documented in
39 more detail in [its wiki](http://sparkline.wikispaces.com/usage).
40
41 * `style` - Either "line" (the default) or "bar".
42 * `width` - Width of the graph in pixels. Only needed for line graphs.
43 * `height` - Height of the graph in pixels. Defaults to 16.
44 * `barwidth` - Width of bars in a bar graph. Default is 1 pixel.
45 * `barspacing` - Spacing between bars in a bar graph, in pixels. Default is
46   1 pixel.
47 * `ymin`, `ymax` - Minimum and maximum values for the Y axis. This is
48   normally calculated automatically, but can be explicitly specified to get
49   the same values for multiple related graphs.
50 * `featurepoint` - Adds a circular marker to a line graph, with optional
51   text. This can be used to label significant points.
52   
53   The value is a comma-delimited list of parameters specifying the feature
54   point: X value, Y value, color name, circle diameter, text (optional),
55   and text location (optional). Example: `featurepoint="3,5,blue,3"`
56   
57   Available values for the text location are: "top", "right", "bottom", and
58   "left".