sparklines 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.txt +5 -0
- data/lib/sparklines.rb +59 -23
- data/samples/area-high.png +0 -0
- data/samples/area.png +0 -0
- data/samples/discrete.png +0 -0
- data/samples/pie-large.png +0 -0
- data/samples/pie.png +0 -0
- data/samples/pie0.png +0 -0
- data/samples/pie1.png +0 -0
- data/samples/pie100.png +0 -0
- data/samples/pie45.png +0 -0
- data/samples/pie95.png +0 -0
- data/samples/pie99.png +0 -0
- data/samples/smooth-colored.png +0 -0
- data/samples/smooth.png +0 -0
- data/test/output/area-high.png +0 -0
- data/test/output/area.png +0 -0
- data/test/output/bar-extreme-values.png +0 -0
- data/test/output/bar-string.png +0 -0
- data/test/output/bar-tall.png +0 -0
- data/test/output/bar-wide.png +0 -0
- data/test/output/bar.png +0 -0
- data/test/output/discrete-wide.png +0 -0
- data/test/output/discrete.png +0 -0
- data/test/output/pie-large.png +0 -0
- data/test/output/pie.png +0 -0
- data/test/output/pie0.png +0 -0
- data/test/output/pie1.png +0 -0
- data/test/output/pie100.png +0 -0
- data/test/output/pie45.png +0 -0
- data/test/output/pie95.png +0 -0
- data/test/output/pie99.png +0 -0
- data/test/output/smooth-colored.png +0 -0
- data/test/output/smooth.png +0 -0
- data/test/test.rb +77 -0
- metadata +39 -23
- data/docs/classes/Sparklines.html +0 -564
- data/docs/classes/Sparklines.src/M000001.html +0 -59
- data/docs/classes/Sparklines.src/M000002.html +0 -20
- data/docs/classes/Sparklines.src/M000003.html +0 -73
- data/docs/classes/Sparklines.src/M000004.html +0 -37
- data/docs/classes/Sparklines.src/M000005.html +0 -88
- data/docs/classes/Sparklines.src/M000006.html +0 -60
- data/docs/classes/Sparklines.src/M000007.html +0 -22
- data/docs/classes/Sparklines.src/M000008.html +0 -26
- data/docs/created.rid +0 -1
- data/docs/files/sparklines_rb.html +0 -109
- data/docs/fr_class_index.html +0 -27
- data/docs/fr_file_index.html +0 -27
- data/docs/fr_method_index.html +0 -34
- data/docs/index.html +0 -24
- data/docs/rdoc-style.css +0 -208
- data/samples/sparklinestest.rb +0 -33
@@ -1,59 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html>
|
7
|
-
<head>
|
8
|
-
<title>plot (Sparklines)</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
-
</head>
|
12
|
-
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File sparklines.rb, line 94</span>
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">Sparklines</span>.<span class="ruby-identifier">plot</span>(<span class="ruby-identifier">results</span>=[], <span class="ruby-identifier">options</span>={})
|
15
|
-
<span class="ruby-identifier">defaults</span> = { <span class="ruby-identifier">:type</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'smooth'</span>,
|
16
|
-
<span class="ruby-identifier">:height</span> =<span class="ruby-operator">></span> <span class="ruby-value">14</span>,
|
17
|
-
<span class="ruby-identifier">:upper</span> =<span class="ruby-operator">></span> <span class="ruby-value">50</span>,
|
18
|
-
<span class="ruby-identifier">:diameter</span> =<span class="ruby-operator">></span> <span class="ruby-value">20</span>,
|
19
|
-
<span class="ruby-identifier">:step</span> =<span class="ruby-operator">></span> <span class="ruby-value">2</span>,
|
20
|
-
<span class="ruby-identifier">:line_color</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'lightgrey'</span>,
|
21
|
-
|
22
|
-
<span class="ruby-identifier">:above_color</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'red'</span>,
|
23
|
-
<span class="ruby-identifier">:below_color</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'grey'</span>,
|
24
|
-
<span class="ruby-identifier">:background_color</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'white'</span>,
|
25
|
-
<span class="ruby-identifier">:share_color</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'blue'</span>,
|
26
|
-
<span class="ruby-identifier">:remain_color</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'lightgrey'</span>,
|
27
|
-
<span class="ruby-identifier">:min_color</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'blue'</span>,
|
28
|
-
<span class="ruby-identifier">:max_color</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'green'</span>,
|
29
|
-
<span class="ruby-identifier">:last_color</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'red'</span>,
|
30
|
-
|
31
|
-
<span class="ruby-identifier">:has_min</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">false</span>,
|
32
|
-
<span class="ruby-identifier">:has_max</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">false</span>,
|
33
|
-
<span class="ruby-identifier">:has_last</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">false</span>
|
34
|
-
}
|
35
|
-
|
36
|
-
<span class="ruby-comment cmt"># This symbol->string->symbol is kind of awkward. Is there a more elegant way?</span>
|
37
|
-
|
38
|
-
<span class="ruby-comment cmt"># Convert all symbol keys to strings</span>
|
39
|
-
<span class="ruby-identifier">defaults</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">reverse</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
|
40
|
-
<span class="ruby-identifier">defaults</span>[<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>] = <span class="ruby-identifier">defaults</span>[<span class="ruby-identifier">key</span>]
|
41
|
-
<span class="ruby-keyword kw">end</span>
|
42
|
-
<span class="ruby-identifier">options</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">reverse</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
|
43
|
-
<span class="ruby-identifier">options</span>[<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>] = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">key</span>]
|
44
|
-
<span class="ruby-keyword kw">end</span>
|
45
|
-
|
46
|
-
<span class="ruby-identifier">options</span> = <span class="ruby-identifier">defaults</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">options</span>)
|
47
|
-
|
48
|
-
<span class="ruby-comment cmt"># Convert options string keys back to symbols</span>
|
49
|
-
<span class="ruby-identifier">options</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">reverse</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
|
50
|
-
<span class="ruby-identifier">options</span>[<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_sym</span>] = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">key</span>]
|
51
|
-
<span class="ruby-keyword kw">end</span>
|
52
|
-
|
53
|
-
|
54
|
-
<span class="ruby-comment cmt"># Call the appropriate function for actual plotting</span>
|
55
|
-
<span class="ruby-comment cmt">#self.send('smooth', results, options)</span>
|
56
|
-
<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:type</span>], <span class="ruby-identifier">results</span>, <span class="ruby-identifier">options</span>)
|
57
|
-
<span class="ruby-keyword kw">end</span></pre>
|
58
|
-
</body>
|
59
|
-
</html>
|
@@ -1,20 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html>
|
7
|
-
<head>
|
8
|
-
<title>plot_to_file (Sparklines)</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
-
</head>
|
12
|
-
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File sparklines.rb, line 140</span>
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">Sparklines</span>.<span class="ruby-identifier">plot_to_file</span>(<span class="ruby-identifier">filename</span>=<span class="ruby-value str">"sparklines.png"</span>, <span class="ruby-identifier">results</span>=[], <span class="ruby-identifier">options</span>={})
|
15
|
-
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>( <span class="ruby-identifier">filename</span>, <span class="ruby-value str">'wb'</span> ) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">png</span><span class="ruby-operator">|</span>
|
16
|
-
<span class="ruby-identifier">png</span> <span class="ruby-operator"><<</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">plot</span>( <span class="ruby-identifier">results</span>, <span class="ruby-identifier">options</span>)
|
17
|
-
<span class="ruby-keyword kw">end</span>
|
18
|
-
<span class="ruby-keyword kw">end</span></pre>
|
19
|
-
</body>
|
20
|
-
</html>
|
@@ -1,73 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html>
|
7
|
-
<head>
|
8
|
-
<title>pie (Sparklines)</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
-
</head>
|
12
|
-
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File sparklines.rb, line 157</span>
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">pie</span>(<span class="ruby-identifier">results</span>=[],<span class="ruby-identifier">options</span>={})
|
15
|
-
|
16
|
-
<span class="ruby-identifier">diameter</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:diameter</span>].<span class="ruby-identifier">to_i</span>
|
17
|
-
<span class="ruby-identifier">share_color</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:share_color</span>]
|
18
|
-
<span class="ruby-identifier">remain_color</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:remain_color</span>]
|
19
|
-
<span class="ruby-identifier">percent</span> = <span class="ruby-identifier">results</span>[<span class="ruby-value">0</span>]
|
20
|
-
|
21
|
-
<span class="ruby-identifier">img</span> = <span class="ruby-constant">Magick</span><span class="ruby-operator">::</span><span class="ruby-constant">Image</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">diameter</span> , <span class="ruby-identifier">diameter</span>) {<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">background_color</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:background_color</span>]}
|
22
|
-
<span class="ruby-identifier">img</span>.<span class="ruby-identifier">format</span> = <span class="ruby-value str">"PNG"</span>
|
23
|
-
<span class="ruby-identifier">draw</span> = <span class="ruby-constant">Magick</span><span class="ruby-operator">::</span><span class="ruby-constant">Draw</span>.<span class="ruby-identifier">new</span>
|
24
|
-
|
25
|
-
<span class="ruby-comment cmt">#Adjust the radius so there's some edge left n the pie
|
26
|
-
<span class="ruby-identifier">r</span> = <span class="ruby-identifier">diameter</span><span class="ruby-operator">/</span><span class="ruby-value">2.0</span> <span class="ruby-operator">-</span> <span class="ruby-value">2</span>
|
27
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">fill</span>(<span class="ruby-identifier">remain_color</span>)
|
28
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">ellipse</span>(<span class="ruby-identifier">r</span> <span class="ruby-operator">+</span> <span class="ruby-value">2</span>, <span class="ruby-identifier">r</span> <span class="ruby-operator">+</span> <span class="ruby-value">2</span>, <span class="ruby-identifier">r</span> , <span class="ruby-identifier">r</span> , <span class="ruby-value">0</span>, <span class="ruby-value">360</span>)
|
29
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">fill</span>(<span class="ruby-identifier">share_color</span>)
|
30
|
-
|
31
|
-
<span class="ruby-comment cmt"># Special exceptions</span>
|
32
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">percent</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
|
33
|
-
<span class="ruby-comment cmt"># For 0% return blank</span>
|
34
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">draw</span>(<span class="ruby-identifier">img</span>)
|
35
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">img</span>.<span class="ruby-identifier">to_blob</span>
|
36
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">percent</span> <span class="ruby-operator">==</span> <span class="ruby-value">100</span>
|
37
|
-
<span class="ruby-comment cmt"># For 100% just draw a full circle</span>
|
38
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">ellipse</span>(<span class="ruby-identifier">r</span> <span class="ruby-operator">+</span> <span class="ruby-value">2</span>, <span class="ruby-identifier">r</span> <span class="ruby-operator">+</span> <span class="ruby-value">2</span>, <span class="ruby-identifier">r</span> , <span class="ruby-identifier">r</span> , <span class="ruby-value">0</span>, <span class="ruby-value">360</span>)
|
39
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">draw</span>(<span class="ruby-identifier">img</span>)
|
40
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">img</span>.<span class="ruby-identifier">to_blob</span>
|
41
|
-
<span class="ruby-keyword kw">end</span>
|
42
|
-
|
43
|
-
<span class="ruby-comment cmt">#Okay, this part is as confusing as hell, so pay attention:
|
44
|
-
<span class="ruby-comment cmt">#This line determines the horizontal portion of the point on the circle where the X-Axis
|
45
|
-
<span class="ruby-comment cmt">#should end. It's caculated by taking the center of the on-image circle and adding that
|
46
|
-
<span class="ruby-comment cmt">#to the radius multiplied by the formula for determinig the point on a unit circle that a
|
47
|
-
<span class="ruby-comment cmt">#angle corresponds to. 3.6 * percent gives us that angle, but it's in degrees, so we need to
|
48
|
-
<span class="ruby-comment cmt">#convert, hence the muliplication by Pi over 180
|
49
|
-
<span class="ruby-identifier">arc_end_x</span> = <span class="ruby-identifier">r</span> <span class="ruby-operator">+</span> <span class="ruby-value">2</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">r</span> <span class="ruby-operator">*</span> <span class="ruby-constant">Math</span>.<span class="ruby-identifier">cos</span>((<span class="ruby-value">3.6</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">percent</span>)<span class="ruby-operator">*</span>(<span class="ruby-constant">Math</span><span class="ruby-operator">::</span><span class="ruby-constant">PI</span><span class="ruby-operator">/</span><span class="ruby-value">180</span>)))
|
50
|
-
|
51
|
-
<span class="ruby-comment cmt">#The same goes for here, except it's the vertical point instead of the horizontal one
|
52
|
-
<span class="ruby-identifier">arc_end_y</span> = <span class="ruby-identifier">r</span> <span class="ruby-operator">+</span> <span class="ruby-value">2</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">r</span> <span class="ruby-operator">*</span> <span class="ruby-constant">Math</span>.<span class="ruby-identifier">sin</span>((<span class="ruby-value">3.6</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">percent</span>)<span class="ruby-operator">*</span>(<span class="ruby-constant">Math</span><span class="ruby-operator">::</span><span class="ruby-constant">PI</span><span class="ruby-operator">/</span><span class="ruby-value">180</span>)))
|
53
|
-
|
54
|
-
<span class="ruby-comment cmt">#Because the SVG path format is seriously screwy, we need to set the large-arc-flag to 1
|
55
|
-
<span class="ruby-comment cmt">#if the angle of an arc is greater than 180 degrees. I have no idea why this is, but it is.
|
56
|
-
<span class="ruby-identifier">percent</span> <span class="ruby-operator">></span> <span class="ruby-value">50</span><span class="ruby-operator">?</span> <span class="ruby-identifier">large_arc_flag</span> = <span class="ruby-value">1</span><span class="ruby-operator">:</span> <span class="ruby-identifier">large_arc_flag</span> = <span class="ruby-value">0</span>
|
57
|
-
|
58
|
-
<span class="ruby-comment cmt">#This is also confusing
|
59
|
-
<span class="ruby-comment cmt">#M tells us to move to an absolute point on the image. We're moving to the center of the pie
|
60
|
-
<span class="ruby-comment cmt">#h tells us to move to a relative point. We're moving to the right edge of the circle.
|
61
|
-
<span class="ruby-comment cmt">#A tells us to start an absolute elliptical arc. The first two values are the radii of the ellipse
|
62
|
-
<span class="ruby-comment cmt">#the third value is the x-axis-rotation (how to rotate the ellipse if we wanted to [could have some fun
|
63
|
-
<span class="ruby-comment cmt">#with randomizing that maybe), the fourth value is our large-arc-flag, the fifth is the sweep-flag,
|
64
|
-
<span class="ruby-comment cmt">#(again, confusing), the sixth and seventh values are the end point of the arc which we calculated previously
|
65
|
-
<span class="ruby-comment cmt">#More info on the SVG path string format at: http://www.w3.org/TR/SVG/paths.html
|
66
|
-
<span class="ruby-identifier">path</span> = <span class="ruby-node">"M#{r + 2},#{r + 2} h#{r} A#{r},#{r} 0 #{large_arc_flag},1 #{arc_end_x},#{arc_end_y} z"</span>
|
67
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">path</span>(<span class="ruby-identifier">path</span>)
|
68
|
-
|
69
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">draw</span>(<span class="ruby-identifier">img</span>)
|
70
|
-
<span class="ruby-identifier">img</span>.<span class="ruby-identifier">to_blob</span>
|
71
|
-
<span class="ruby-keyword kw">end</span></pre>
|
72
|
-
</body>
|
73
|
-
</html>
|
@@ -1,37 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html>
|
7
|
-
<head>
|
8
|
-
<title>discrete (Sparklines)</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
-
</head>
|
12
|
-
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File sparklines.rb, line 229</span>
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">discrete</span>(<span class="ruby-identifier">results</span>=[], <span class="ruby-identifier">options</span> = {})
|
15
|
-
|
16
|
-
<span class="ruby-identifier">height</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:height</span>].<span class="ruby-identifier">to_i</span>
|
17
|
-
<span class="ruby-identifier">upper</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:upper</span>].<span class="ruby-identifier">to_i</span>
|
18
|
-
<span class="ruby-identifier">below_color</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:below_color</span>]
|
19
|
-
<span class="ruby-identifier">above_color</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:above_color</span>]
|
20
|
-
|
21
|
-
<span class="ruby-identifier">img</span> = <span class="ruby-constant">Magick</span><span class="ruby-operator">::</span><span class="ruby-constant">Image</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">results</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">*</span> <span class="ruby-value">2</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>, <span class="ruby-identifier">height</span>) {<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">background_color</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:background_color</span>]}
|
22
|
-
<span class="ruby-identifier">img</span>.<span class="ruby-identifier">format</span> = <span class="ruby-value str">"PNG"</span>
|
23
|
-
<span class="ruby-identifier">draw</span> = <span class="ruby-constant">Magick</span><span class="ruby-operator">::</span><span class="ruby-constant">Draw</span>.<span class="ruby-identifier">new</span>
|
24
|
-
|
25
|
-
<span class="ruby-identifier">i</span>=<span class="ruby-value">0</span>
|
26
|
-
<span class="ruby-identifier">results</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
|
27
|
-
<span class="ruby-identifier">color</span> = (<span class="ruby-identifier">r</span> <span class="ruby-operator">>=</span> <span class="ruby-identifier">upper</span>) <span class="ruby-operator">&&</span> <span class="ruby-identifier">above_color</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">below_color</span>
|
28
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">stroke</span>(<span class="ruby-identifier">color</span>)
|
29
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">line</span>(<span class="ruby-identifier">i</span>, (<span class="ruby-identifier">img</span>.<span class="ruby-identifier">rows</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">r</span><span class="ruby-operator">/</span>(<span class="ruby-value">101.0</span><span class="ruby-operator">/</span>(<span class="ruby-identifier">height</span><span class="ruby-operator">-</span><span class="ruby-value">4</span>))<span class="ruby-operator">-</span><span class="ruby-value">4</span>).<span class="ruby-identifier">to_i</span>,<span class="ruby-identifier">i</span>,(<span class="ruby-identifier">img</span>.<span class="ruby-identifier">rows</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">r</span><span class="ruby-operator">/</span>(<span class="ruby-value">101.0</span><span class="ruby-operator">/</span>(<span class="ruby-identifier">height</span><span class="ruby-operator">-</span><span class="ruby-value">4</span>))).<span class="ruby-identifier">to_i</span>)
|
30
|
-
<span class="ruby-identifier">i</span><span class="ruby-operator">+=</span><span class="ruby-value">2</span>
|
31
|
-
<span class="ruby-keyword kw">end</span>
|
32
|
-
|
33
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">draw</span>(<span class="ruby-identifier">img</span>)
|
34
|
-
<span class="ruby-identifier">img</span>.<span class="ruby-identifier">to_blob</span>
|
35
|
-
<span class="ruby-keyword kw">end</span></pre>
|
36
|
-
</body>
|
37
|
-
</html>
|
@@ -1,88 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html>
|
7
|
-
<head>
|
8
|
-
<title>area (Sparklines)</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
-
</head>
|
12
|
-
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File sparklines.rb, line 279</span>
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">area</span>(<span class="ruby-identifier">results</span>=[], <span class="ruby-identifier">options</span>={})
|
15
|
-
|
16
|
-
<span class="ruby-identifier">step</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:step</span>].<span class="ruby-identifier">to_i</span>
|
17
|
-
<span class="ruby-identifier">height</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:height</span>].<span class="ruby-identifier">to_i</span>
|
18
|
-
<span class="ruby-identifier">upper</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:upper</span>].<span class="ruby-identifier">to_i</span>
|
19
|
-
|
20
|
-
<span class="ruby-identifier">has_min</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:has_min</span>]
|
21
|
-
<span class="ruby-identifier">has_max</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:has_max</span>]
|
22
|
-
<span class="ruby-identifier">has_last</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:has_last</span>]
|
23
|
-
|
24
|
-
<span class="ruby-identifier">min_color</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:min_color</span>]
|
25
|
-
<span class="ruby-identifier">max_color</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:max_color</span>]
|
26
|
-
<span class="ruby-identifier">last_color</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:last_color</span>]
|
27
|
-
<span class="ruby-identifier">below_color</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:below_color</span>]
|
28
|
-
<span class="ruby-identifier">above_color</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:above_color</span>]
|
29
|
-
|
30
|
-
<span class="ruby-identifier">img</span> = <span class="ruby-constant">Magick</span><span class="ruby-operator">::</span><span class="ruby-constant">Image</span>.<span class="ruby-identifier">new</span>((<span class="ruby-identifier">results</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>) <span class="ruby-operator">*</span> <span class="ruby-identifier">step</span> <span class="ruby-operator">+</span> <span class="ruby-value">4</span>, <span class="ruby-identifier">height</span>) {<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">background_color</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:background_color</span>]}
|
31
|
-
<span class="ruby-identifier">img</span>.<span class="ruby-identifier">format</span> = <span class="ruby-value str">"PNG"</span>
|
32
|
-
<span class="ruby-identifier">draw</span> = <span class="ruby-constant">Magick</span><span class="ruby-operator">::</span><span class="ruby-constant">Draw</span>.<span class="ruby-identifier">new</span>
|
33
|
-
|
34
|
-
<span class="ruby-identifier">coords</span> = [[<span class="ruby-value">0</span>,(<span class="ruby-identifier">height</span> <span class="ruby-operator">-</span> <span class="ruby-value">3</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">upper</span><span class="ruby-operator">/</span>(<span class="ruby-value">101.0</span><span class="ruby-operator">/</span>(<span class="ruby-identifier">height</span><span class="ruby-operator">-</span><span class="ruby-value">4</span>)))]]
|
35
|
-
<span class="ruby-identifier">i</span>=<span class="ruby-value">0</span>
|
36
|
-
<span class="ruby-identifier">results</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
|
37
|
-
<span class="ruby-identifier">coords</span>.<span class="ruby-identifier">push</span> [(<span class="ruby-value">2</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">i</span>), (<span class="ruby-identifier">height</span> <span class="ruby-operator">-</span> <span class="ruby-value">3</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">r</span><span class="ruby-operator">/</span>(<span class="ruby-value">101.0</span><span class="ruby-operator">/</span>(<span class="ruby-identifier">height</span><span class="ruby-operator">-</span><span class="ruby-value">4</span>)))]
|
38
|
-
<span class="ruby-identifier">i</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">step</span>
|
39
|
-
<span class="ruby-keyword kw">end</span>
|
40
|
-
<span class="ruby-identifier">coords</span>.<span class="ruby-identifier">push</span> [(<span class="ruby-identifier">results</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>) <span class="ruby-operator">*</span> <span class="ruby-identifier">step</span> <span class="ruby-operator">+</span> <span class="ruby-value">4</span>, (<span class="ruby-identifier">height</span> <span class="ruby-operator">-</span> <span class="ruby-value">3</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">upper</span><span class="ruby-operator">/</span>(<span class="ruby-value">101.0</span><span class="ruby-operator">/</span>(<span class="ruby-identifier">height</span><span class="ruby-operator">-</span><span class="ruby-value">4</span>)))]
|
41
|
-
|
42
|
-
<span class="ruby-comment cmt">#Block off the bottom half of the image and draw the sparkline</span>
|
43
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">fill</span>(<span class="ruby-identifier">above_color</span>)
|
44
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">define_clip_path</span>(<span class="ruby-value str">'top'</span>) <span class="ruby-keyword kw">do</span>
|
45
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">rectangle</span>(<span class="ruby-value">0</span>,<span class="ruby-value">0</span>,(<span class="ruby-identifier">results</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>) <span class="ruby-operator">*</span> <span class="ruby-identifier">step</span> <span class="ruby-operator">+</span> <span class="ruby-value">4</span>,(<span class="ruby-identifier">height</span> <span class="ruby-operator">-</span> <span class="ruby-value">3</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">upper</span><span class="ruby-operator">/</span>(<span class="ruby-value">101.0</span><span class="ruby-operator">/</span>(<span class="ruby-identifier">height</span><span class="ruby-operator">-</span><span class="ruby-value">4</span>))))
|
46
|
-
<span class="ruby-keyword kw">end</span>
|
47
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">clip_path</span>(<span class="ruby-value str">'top'</span>)
|
48
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">polygon</span> <span class="ruby-operator">*</span><span class="ruby-identifier">coords</span>.<span class="ruby-identifier">flatten</span>
|
49
|
-
|
50
|
-
<span class="ruby-comment cmt">#Block off the top half of the image and draw the sparkline</span>
|
51
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">fill</span>(<span class="ruby-identifier">below_color</span>)
|
52
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">define_clip_path</span>(<span class="ruby-value str">'bottom'</span>) <span class="ruby-keyword kw">do</span>
|
53
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">rectangle</span>(<span class="ruby-value">0</span>,(<span class="ruby-identifier">height</span> <span class="ruby-operator">-</span> <span class="ruby-value">3</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">upper</span><span class="ruby-operator">/</span>(<span class="ruby-value">101.0</span><span class="ruby-operator">/</span>(<span class="ruby-identifier">height</span><span class="ruby-operator">-</span><span class="ruby-value">4</span>))),(<span class="ruby-identifier">results</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>) <span class="ruby-operator">*</span> <span class="ruby-identifier">step</span> <span class="ruby-operator">+</span> <span class="ruby-value">4</span>,<span class="ruby-identifier">height</span>)
|
54
|
-
<span class="ruby-keyword kw">end</span>
|
55
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">clip_path</span>(<span class="ruby-value str">'bottom'</span>)
|
56
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">polygon</span> <span class="ruby-operator">*</span><span class="ruby-identifier">coords</span>.<span class="ruby-identifier">flatten</span>
|
57
|
-
|
58
|
-
<span class="ruby-comment cmt">#The sparkline looks kinda nasty if either the above_color or below_color gets the center line</span>
|
59
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">fill</span>(<span class="ruby-value str">'black'</span>)
|
60
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">line</span>(<span class="ruby-value">0</span>,(<span class="ruby-identifier">height</span> <span class="ruby-operator">-</span> <span class="ruby-value">3</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">upper</span><span class="ruby-operator">/</span>(<span class="ruby-value">101.0</span><span class="ruby-operator">/</span>(<span class="ruby-identifier">height</span><span class="ruby-operator">-</span><span class="ruby-value">4</span>))),(<span class="ruby-identifier">results</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>) <span class="ruby-operator">*</span> <span class="ruby-identifier">step</span> <span class="ruby-operator">+</span> <span class="ruby-value">4</span>,(<span class="ruby-identifier">height</span> <span class="ruby-operator">-</span> <span class="ruby-value">3</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">upper</span><span class="ruby-operator">/</span>(<span class="ruby-value">101.0</span><span class="ruby-operator">/</span>(<span class="ruby-identifier">height</span><span class="ruby-operator">-</span><span class="ruby-value">4</span>))))
|
61
|
-
|
62
|
-
<span class="ruby-comment cmt">#After the parts have been masked, we need to let the whole canvas be drawable again</span>
|
63
|
-
<span class="ruby-comment cmt">#so a max dot can be displayed</span>
|
64
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">define_clip_path</span>(<span class="ruby-value str">'all'</span>) <span class="ruby-keyword kw">do</span>
|
65
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">rectangle</span>(<span class="ruby-value">0</span>,<span class="ruby-value">0</span>,<span class="ruby-identifier">img</span>.<span class="ruby-identifier">columns</span>,<span class="ruby-identifier">img</span>.<span class="ruby-identifier">rows</span>)
|
66
|
-
<span class="ruby-keyword kw">end</span>
|
67
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">clip_path</span>(<span class="ruby-value str">'all'</span>)
|
68
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">has_min</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'true'</span>
|
69
|
-
<span class="ruby-identifier">min_pt</span> = <span class="ruby-identifier">coords</span>[<span class="ruby-identifier">results</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">results</span>.<span class="ruby-identifier">min</span>)<span class="ruby-operator">+</span><span class="ruby-value">1</span>]
|
70
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">fill</span>(<span class="ruby-identifier">min_color</span>)
|
71
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">rectangle</span>(<span class="ruby-identifier">min_pt</span>[<span class="ruby-value">0</span>]<span class="ruby-operator">-</span><span class="ruby-value">1</span>, <span class="ruby-identifier">min_pt</span>[<span class="ruby-value">1</span>]<span class="ruby-operator">-</span><span class="ruby-value">1</span>, <span class="ruby-identifier">min_pt</span>[<span class="ruby-value">0</span>]<span class="ruby-operator">+</span><span class="ruby-value">1</span>, <span class="ruby-identifier">min_pt</span>[<span class="ruby-value">1</span>]<span class="ruby-operator">+</span><span class="ruby-value">1</span>)
|
72
|
-
<span class="ruby-keyword kw">end</span>
|
73
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">has_max</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'true'</span>
|
74
|
-
<span class="ruby-identifier">max_pt</span> = <span class="ruby-identifier">coords</span>[<span class="ruby-identifier">results</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">results</span>.<span class="ruby-identifier">max</span>)<span class="ruby-operator">+</span><span class="ruby-value">1</span>]
|
75
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">fill</span>(<span class="ruby-identifier">max_color</span>)
|
76
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">rectangle</span>(<span class="ruby-identifier">max_pt</span>[<span class="ruby-value">0</span>]<span class="ruby-operator">-</span><span class="ruby-value">1</span>, <span class="ruby-identifier">max_pt</span>[<span class="ruby-value">1</span>]<span class="ruby-operator">-</span><span class="ruby-value">1</span>, <span class="ruby-identifier">max_pt</span>[<span class="ruby-value">0</span>]<span class="ruby-operator">+</span><span class="ruby-value">1</span>, <span class="ruby-identifier">max_pt</span>[<span class="ruby-value">1</span>]<span class="ruby-operator">+</span><span class="ruby-value">1</span>)
|
77
|
-
<span class="ruby-keyword kw">end</span>
|
78
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">has_last</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'true'</span>
|
79
|
-
<span class="ruby-identifier">last_pt</span> = <span class="ruby-identifier">coords</span>[<span class="ruby-value">-2</span>]
|
80
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">fill</span>(<span class="ruby-identifier">last_color</span>)
|
81
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">rectangle</span>(<span class="ruby-identifier">last_pt</span>[<span class="ruby-value">0</span>]<span class="ruby-operator">-</span><span class="ruby-value">1</span>, <span class="ruby-identifier">last_pt</span>[<span class="ruby-value">1</span>]<span class="ruby-operator">-</span><span class="ruby-value">1</span>, <span class="ruby-identifier">last_pt</span>[<span class="ruby-value">0</span>]<span class="ruby-operator">+</span><span class="ruby-value">1</span>, <span class="ruby-identifier">last_pt</span>[<span class="ruby-value">1</span>]<span class="ruby-operator">+</span><span class="ruby-value">1</span>)
|
82
|
-
<span class="ruby-keyword kw">end</span>
|
83
|
-
|
84
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">draw</span>(<span class="ruby-identifier">img</span>)
|
85
|
-
<span class="ruby-identifier">img</span>.<span class="ruby-identifier">to_blob</span>
|
86
|
-
<span class="ruby-keyword kw">end</span></pre>
|
87
|
-
</body>
|
88
|
-
</html>
|
@@ -1,60 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html>
|
7
|
-
<head>
|
8
|
-
<title>smooth (Sparklines)</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
-
</head>
|
12
|
-
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File sparklines.rb, line 374</span>
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">smooth</span>(<span class="ruby-identifier">results</span>, <span class="ruby-identifier">options</span>)
|
15
|
-
|
16
|
-
<span class="ruby-identifier">step</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:step</span>].<span class="ruby-identifier">to_i</span>
|
17
|
-
<span class="ruby-identifier">height</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:height</span>].<span class="ruby-identifier">to_i</span>
|
18
|
-
<span class="ruby-identifier">min_color</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:min_color</span>]
|
19
|
-
<span class="ruby-identifier">max_color</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:max_color</span>]
|
20
|
-
<span class="ruby-identifier">last_color</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:last_color</span>]
|
21
|
-
<span class="ruby-identifier">has_min</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:has_min</span>]
|
22
|
-
<span class="ruby-identifier">has_max</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:has_max</span>]
|
23
|
-
<span class="ruby-identifier">has_last</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:has_last</span>]
|
24
|
-
<span class="ruby-identifier">line_color</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:line_color</span>]
|
25
|
-
|
26
|
-
<span class="ruby-identifier">img</span> = <span class="ruby-constant">Magick</span><span class="ruby-operator">::</span><span class="ruby-constant">Image</span>.<span class="ruby-identifier">new</span>((<span class="ruby-identifier">results</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>) <span class="ruby-operator">*</span> <span class="ruby-identifier">step</span> <span class="ruby-operator">+</span> <span class="ruby-value">4</span>, <span class="ruby-identifier">height</span>.<span class="ruby-identifier">to_i</span>) {<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">background_color</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:background_color</span>]}
|
27
|
-
<span class="ruby-identifier">img</span>.<span class="ruby-identifier">format</span> = <span class="ruby-value str">"PNG"</span>
|
28
|
-
<span class="ruby-identifier">draw</span> = <span class="ruby-constant">Magick</span><span class="ruby-operator">::</span><span class="ruby-constant">Draw</span>.<span class="ruby-identifier">new</span>
|
29
|
-
|
30
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">stroke</span>(<span class="ruby-identifier">line_color</span>)
|
31
|
-
<span class="ruby-identifier">coords</span> = []
|
32
|
-
<span class="ruby-identifier">i</span>=<span class="ruby-value">0</span>
|
33
|
-
<span class="ruby-identifier">results</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
|
34
|
-
<span class="ruby-identifier">coords</span>.<span class="ruby-identifier">push</span> [ <span class="ruby-value">2</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">i</span>, (<span class="ruby-identifier">height</span> <span class="ruby-operator">-</span> <span class="ruby-value">3</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">r</span><span class="ruby-operator">/</span>(<span class="ruby-value">101.0</span><span class="ruby-operator">/</span>(<span class="ruby-identifier">height</span><span class="ruby-operator">-</span><span class="ruby-value">4</span>))) ]
|
35
|
-
<span class="ruby-identifier">i</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">step</span>
|
36
|
-
<span class="ruby-keyword kw">end</span>
|
37
|
-
|
38
|
-
<span class="ruby-identifier">my_polyline</span>(<span class="ruby-identifier">draw</span>, <span class="ruby-identifier">coords</span>)
|
39
|
-
|
40
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">has_min</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span>
|
41
|
-
<span class="ruby-identifier">min_pt</span> = <span class="ruby-identifier">coords</span>[<span class="ruby-identifier">results</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">results</span>.<span class="ruby-identifier">min</span>)]
|
42
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">fill</span>(<span class="ruby-identifier">min_color</span>)
|
43
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">rectangle</span>(<span class="ruby-identifier">min_pt</span>[<span class="ruby-value">0</span>]<span class="ruby-operator">-</span><span class="ruby-value">2</span>, <span class="ruby-identifier">min_pt</span>[<span class="ruby-value">1</span>]<span class="ruby-operator">-</span><span class="ruby-value">2</span>, <span class="ruby-identifier">min_pt</span>[<span class="ruby-value">0</span>]<span class="ruby-operator">+</span><span class="ruby-value">2</span>, <span class="ruby-identifier">min_pt</span>[<span class="ruby-value">1</span>]<span class="ruby-operator">+</span><span class="ruby-value">2</span>)
|
44
|
-
<span class="ruby-keyword kw">end</span>
|
45
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">has_max</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span>
|
46
|
-
<span class="ruby-identifier">max_pt</span> = <span class="ruby-identifier">coords</span>[<span class="ruby-identifier">results</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">results</span>.<span class="ruby-identifier">max</span>)]
|
47
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">fill</span>(<span class="ruby-identifier">max_color</span>)
|
48
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">rectangle</span>(<span class="ruby-identifier">max_pt</span>[<span class="ruby-value">0</span>]<span class="ruby-operator">-</span><span class="ruby-value">2</span>, <span class="ruby-identifier">max_pt</span>[<span class="ruby-value">1</span>]<span class="ruby-operator">-</span><span class="ruby-value">2</span>, <span class="ruby-identifier">max_pt</span>[<span class="ruby-value">0</span>]<span class="ruby-operator">+</span><span class="ruby-value">2</span>, <span class="ruby-identifier">max_pt</span>[<span class="ruby-value">1</span>]<span class="ruby-operator">+</span><span class="ruby-value">2</span>)
|
49
|
-
<span class="ruby-keyword kw">end</span>
|
50
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">has_last</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span>
|
51
|
-
<span class="ruby-identifier">last_pt</span> = <span class="ruby-identifier">coords</span>[<span class="ruby-value">-1</span>]
|
52
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">fill</span>(<span class="ruby-identifier">last_color</span>)
|
53
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">rectangle</span>(<span class="ruby-identifier">last_pt</span>[<span class="ruby-value">0</span>]<span class="ruby-operator">-</span><span class="ruby-value">2</span>, <span class="ruby-identifier">last_pt</span>[<span class="ruby-value">1</span>]<span class="ruby-operator">-</span><span class="ruby-value">2</span>, <span class="ruby-identifier">last_pt</span>[<span class="ruby-value">0</span>]<span class="ruby-operator">+</span><span class="ruby-value">2</span>, <span class="ruby-identifier">last_pt</span>[<span class="ruby-value">1</span>]<span class="ruby-operator">+</span><span class="ruby-value">2</span>)
|
54
|
-
<span class="ruby-keyword kw">end</span>
|
55
|
-
|
56
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">draw</span>(<span class="ruby-identifier">img</span>)
|
57
|
-
<span class="ruby-identifier">img</span>.<span class="ruby-identifier">to_blob</span>
|
58
|
-
<span class="ruby-keyword kw">end</span></pre>
|
59
|
-
</body>
|
60
|
-
</html>
|
@@ -1,22 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html>
|
7
|
-
<head>
|
8
|
-
<title>my_polyline (Sparklines)</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
-
</head>
|
12
|
-
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File sparklines.rb, line 426</span>
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">my_polyline</span> (<span class="ruby-identifier">draw</span>, <span class="ruby-identifier">arr</span>)
|
15
|
-
<span class="ruby-identifier">i</span> = <span class="ruby-value">0</span>
|
16
|
-
<span class="ruby-keyword kw">while</span> <span class="ruby-identifier">i</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">arr</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>
|
17
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">line</span>(<span class="ruby-identifier">arr</span>[<span class="ruby-identifier">i</span>][<span class="ruby-value">0</span>], <span class="ruby-identifier">arr</span>[<span class="ruby-identifier">i</span>][<span class="ruby-value">1</span>], <span class="ruby-identifier">arr</span>[<span class="ruby-identifier">i</span><span class="ruby-operator">+</span><span class="ruby-value">1</span>][<span class="ruby-value">0</span>], <span class="ruby-identifier">arr</span>[<span class="ruby-identifier">i</span><span class="ruby-operator">+</span><span class="ruby-value">1</span>][<span class="ruby-value">1</span>])
|
18
|
-
<span class="ruby-identifier">i</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
19
|
-
<span class="ruby-keyword kw">end</span>
|
20
|
-
<span class="ruby-keyword kw">end</span></pre>
|
21
|
-
</body>
|
22
|
-
</html>
|
@@ -1,26 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html>
|
7
|
-
<head>
|
8
|
-
<title>plot_error (Sparklines)</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
-
</head>
|
12
|
-
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File sparklines.rb, line 435</span>
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">plot_error</span>(<span class="ruby-identifier">options</span>={})
|
15
|
-
<span class="ruby-identifier">img</span> = <span class="ruby-constant">Magick</span><span class="ruby-operator">::</span><span class="ruby-constant">Image</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">40</span>,<span class="ruby-value">15</span>) {<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">background_color</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:background_color</span>]}
|
16
|
-
<span class="ruby-identifier">img</span>.<span class="ruby-identifier">format</span> = <span class="ruby-value str">"PNG"</span>
|
17
|
-
<span class="ruby-identifier">draw</span> = <span class="ruby-constant">Magick</span><span class="ruby-operator">::</span><span class="ruby-constant">Draw</span>.<span class="ruby-identifier">new</span>
|
18
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">fill</span>(<span class="ruby-value str">'red'</span>)
|
19
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">line</span>(<span class="ruby-value">0</span>,<span class="ruby-value">0</span>,<span class="ruby-value">40</span>,<span class="ruby-value">15</span>)
|
20
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">line</span>(<span class="ruby-value">0</span>,<span class="ruby-value">15</span>,<span class="ruby-value">40</span>,<span class="ruby-value">0</span>)
|
21
|
-
<span class="ruby-identifier">draw</span>.<span class="ruby-identifier">draw</span>(<span class="ruby-identifier">img</span>)
|
22
|
-
|
23
|
-
<span class="ruby-identifier">img</span>.<span class="ruby-identifier">to_blob</span>
|
24
|
-
<span class="ruby-keyword kw">end</span></pre>
|
25
|
-
</body>
|
26
|
-
</html>
|
data/docs/created.rid
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Tue Aug 09 12:33:45 PDT 2005
|
@@ -1,109 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
-
<head>
|
8
|
-
<title>File: sparklines.rb</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
-
<script type="text/javascript">
|
13
|
-
// <![CDATA[
|
14
|
-
|
15
|
-
function popupCode( url ) {
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
-
}
|
18
|
-
|
19
|
-
function toggleCode( id ) {
|
20
|
-
if ( document.getElementById )
|
21
|
-
elem = document.getElementById( id );
|
22
|
-
else if ( document.all )
|
23
|
-
elem = eval( "document.all." + id );
|
24
|
-
else
|
25
|
-
return false;
|
26
|
-
|
27
|
-
elemStyle = elem.style;
|
28
|
-
|
29
|
-
if ( elemStyle.display != "block" ) {
|
30
|
-
elemStyle.display = "block"
|
31
|
-
} else {
|
32
|
-
elemStyle.display = "none"
|
33
|
-
}
|
34
|
-
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Make codeblocks hidden by default
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
-
|
41
|
-
// ]]>
|
42
|
-
</script>
|
43
|
-
|
44
|
-
</head>
|
45
|
-
<body>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<div id="fileHeader">
|
50
|
-
<h1>sparklines.rb</h1>
|
51
|
-
<table class="header-table">
|
52
|
-
<tr class="top-aligned-row">
|
53
|
-
<td><strong>Path:</strong></td>
|
54
|
-
<td>sparklines.rb
|
55
|
-
</td>
|
56
|
-
</tr>
|
57
|
-
<tr class="top-aligned-row">
|
58
|
-
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>Tue Aug 02 11:24:32 PDT 2005</td>
|
60
|
-
</tr>
|
61
|
-
</table>
|
62
|
-
</div>
|
63
|
-
<!-- banner header -->
|
64
|
-
|
65
|
-
<div id="bodyContent">
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
<div id="contextContent">
|
70
|
-
|
71
|
-
|
72
|
-
<div id="requires-list">
|
73
|
-
<h3 class="section-bar">Required files</h3>
|
74
|
-
|
75
|
-
<div class="name-list">
|
76
|
-
RMagick
|
77
|
-
mathn
|
78
|
-
</div>
|
79
|
-
</div>
|
80
|
-
|
81
|
-
</div>
|
82
|
-
|
83
|
-
|
84
|
-
</div>
|
85
|
-
|
86
|
-
|
87
|
-
<!-- if includes -->
|
88
|
-
|
89
|
-
<div id="section">
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
<!-- if method_list -->
|
99
|
-
|
100
|
-
|
101
|
-
</div>
|
102
|
-
|
103
|
-
|
104
|
-
<div id="validator-badges">
|
105
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
106
|
-
</div>
|
107
|
-
|
108
|
-
</body>
|
109
|
-
</html>
|