sparklines 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,564 @@
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>Module: Sparklines</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="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Module</strong></td>
53
+ <td class="class-name-in-header">Sparklines</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../files/sparklines_rb.html">
59
+ sparklines.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ </table>
66
+ </div>
67
+ <!-- banner header -->
68
+
69
+ <div id="bodyContent">
70
+
71
+
72
+
73
+ <div id="contextContent">
74
+
75
+ <div id="description">
76
+ <p>
77
+ A library (in Ruby!) for generating sparklines.
78
+ </p>
79
+ <p>
80
+ Can be used to write to a file or make a web service with Rails or other
81
+ Ruby CGI apps.
82
+ </p>
83
+ <p>
84
+ Idea and much of the outline for the source lifted directly from <a
85
+ href="http://bitworking.org/projects/sparklines">Joe Gregorio's Python
86
+ Sparklines web service script</a>.
87
+ </p>
88
+ <p>
89
+ Requires the RMagick image library.
90
+ </p>
91
+ <h2>Authors</h2>
92
+ <p>
93
+ <a href="mailto:nugend@gmail.com">Dan Nugent</a> Original port from Python
94
+ <a href="Sparklines.html">Sparklines</a> library.
95
+ </p>
96
+ <p>
97
+ <a href="mailto:boss@topfunky.com">Geoffrey Grosenbach</a> &#8212; <a
98
+ href="http://nubyonrails.topfunky.com">nubyonrails.topfunky.com</a> &#8212;
99
+ Conversion to module and addition of functions for using with Rails. Also
100
+ changed functions to use Rails-style option hashes for parameters.
101
+ </p>
102
+ <h3>Tangent regarding RMagick</h3>
103
+ <p>
104
+ I had a heck of a time getting RMagick to work on my system so in the
105
+ interests of saving other people the trouble here&#8217;s a little set of
106
+ instructions on how to get RMagick working properly and with the right
107
+ image formats.
108
+ </p>
109
+ <ol>
110
+ <li>Install the <a href="http://www.libpng.org/pub/png/libpng.html">zlib</a>
111
+ library
112
+
113
+ </li>
114
+ <li>With zlib in the same directory as the <a
115
+ href="http://www.libpng.org/pub/png/libpng.html">libpng</a> library,
116
+ install libpng
117
+
118
+ </li>
119
+ <li>Option step: Install the <a
120
+ href="ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz">jpeg library</a>
121
+ (You need it to use jpegs and you might want to have it)
122
+
123
+ </li>
124
+ <li>Install ImageMagick from <b><a
125
+ href="http://www.imagemagick.org/script/install-source.php">source</a></b>.
126
+ RMagick requires the ImageMagick headers, so this is important.
127
+
128
+ </li>
129
+ <li>Install RMagick from <a
130
+ href="http://rubyforge.org/projects/rmagick/">source</a>. The gem is not
131
+ reliable.
132
+
133
+ </li>
134
+ <li>Edit Magick-conf if necessary. I had to remove -lcms and -ltiff since I
135
+ didn&#8217;t want those to be built and the libraries weren&#8217;t on my
136
+ system.
137
+
138
+ </li>
139
+ </ol>
140
+ <p>
141
+ Please keep in mind that these were only the steps that made RMagick work
142
+ on my machine. This is a tricky library to get working. Consider using Joe
143
+ Gregorio&#8217;s version for Python if the installation proves to be too
144
+ cumbersome.
145
+ </p>
146
+ <h2>General Usage and Defaults</h2>
147
+ <p>
148
+ To use in a script:
149
+ </p>
150
+ <pre>
151
+ require 'rubygems'
152
+ require 'sparklines'
153
+ Sparklines.plot([1,25,33,46,89,90,85,77,42], :type =&gt; 'discrete', :height =&gt; 20)
154
+ </pre>
155
+ <p>
156
+ An image blob will be returned which you can print, write to STDOUT, etc.
157
+ </p>
158
+ <p>
159
+ In Rails,
160
+ </p>
161
+ <ul>
162
+ <li>Install the &#8216;sparklines_generator&#8217; gem (&#8216;gem install
163
+ sparklines_generator&#8217;)
164
+
165
+ </li>
166
+ <li>Call &#8216;ruby script/generate sparklines&#8217;. This will copy the <a
167
+ href="Sparklines.html">Sparklines</a> controller and helper to your rails
168
+ directories
169
+
170
+ </li>
171
+ <li>Add &quot;require &#8216;sparklines&#8217;&quot; to the bottom of your
172
+ config/environment.rb
173
+
174
+ </li>
175
+ <li>Restart your fcgi&#8217;s or your WEBrick if necessary
176
+
177
+ </li>
178
+ </ul>
179
+ <p>
180
+ And finally, add this to the controller whose view will be using
181
+ sparklines:
182
+ </p>
183
+ <pre>
184
+ helper :sparklines
185
+ </pre>
186
+ <p>
187
+ In your view, call it like this:
188
+ </p>
189
+ <p>
190
+ &lt;%= sparkline_tag [1,2,3,4,5,6] %&gt; &lt;!&#8212; Gives you a smooth
191
+ graph &#8212;&gt;
192
+ </p>
193
+ <p>
194
+ Or specify details:
195
+ </p>
196
+ <p>
197
+ &lt;%= sparkline_tag [1,2,3,4,5,6], :type =&gt; &#8216;discrete&#8217;,
198
+ :height =&gt; 10, :upper =&gt; 80, :above_color =&gt; &#8216;green&#8217;,
199
+ :below_color =&gt; &#8216;blue&#8217; %&gt;
200
+ </p>
201
+ <p>
202
+ Graph types:
203
+ </p>
204
+ <pre>
205
+ area
206
+ discrete
207
+ pie
208
+ smooth
209
+ </pre>
210
+ <p>
211
+ General Defaults:
212
+ </p>
213
+ <pre>
214
+ :type =&gt; 'smooth'
215
+ :height =&gt; 14px
216
+ :upper =&gt; 50
217
+ :above_color =&gt; 'red'
218
+ :below_color =&gt; 'grey'
219
+ :background_color =&gt; 'white'
220
+ :line_color =&gt; 'lightgrey'
221
+ </pre>
222
+ <h2>License</h2>
223
+ <p>
224
+ Licensed under the MIT license.
225
+ </p>
226
+
227
+ </div>
228
+
229
+
230
+ </div>
231
+
232
+ <div id="method-list">
233
+ <h3 class="section-bar">Methods</h3>
234
+
235
+ <div class="name-list">
236
+ <a href="#M000005">area</a>&nbsp;&nbsp;
237
+ <a href="#M000004">discrete</a>&nbsp;&nbsp;
238
+ <a href="#M000007">my_polyline</a>&nbsp;&nbsp;
239
+ <a href="#M000003">pie</a>&nbsp;&nbsp;
240
+ <a href="#M000001">plot</a>&nbsp;&nbsp;
241
+ <a href="#M000008">plot_error</a>&nbsp;&nbsp;
242
+ <a href="#M000002">plot_to_file</a>&nbsp;&nbsp;
243
+ <a href="#M000006">smooth</a>&nbsp;&nbsp;
244
+ </div>
245
+ </div>
246
+
247
+ </div>
248
+
249
+
250
+ <!-- if includes -->
251
+
252
+ <div id="section">
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+ <!-- if method_list -->
262
+ <div id="methods">
263
+ <h3 class="section-bar">Public Class methods</h3>
264
+
265
+ <div id="method-M000005" class="method-detail">
266
+ <a name="M000005"></a>
267
+
268
+ <div class="method-heading">
269
+ <a href="Sparklines.src/M000005.html" target="Code" class="method-signature"
270
+ onclick="popupCode('Sparklines.src/M000005.html');return false;">
271
+ <span class="method-name">area</span><span class="method-args">(results=[], options={})</span>
272
+ </a>
273
+ </div>
274
+
275
+ <div class="method-description">
276
+ <p>
277
+ Creates a continuous area sparkline
278
+ </p>
279
+ <ul>
280
+ <li>results is an array of integer values between 0 and 100 inclusive
281
+
282
+ </li>
283
+ <li>options is a hash that takes 4 parameters:
284
+
285
+ </li>
286
+ </ul>
287
+ <p>
288
+ :step - An integer that determines the distance between each point on the
289
+ sparkline. Defaults to 2.
290
+ </p>
291
+ <p>
292
+ :height - An integer that determines what the height of the sparkline will
293
+ be. Defaults to 14
294
+ </p>
295
+ <p>
296
+ :upper - An ineger that determines the threshold for colorization purposes.
297
+ Any value less than upper will be colored using below_color, anything above
298
+ and equal to upper will use above_color. Defaults to 50.
299
+ </p>
300
+ <p>
301
+ :has_min - Determines whether a dot will be drawn at the lowest value or
302
+ not. Defaulst to false.
303
+ </p>
304
+ <p>
305
+ :has_max - Determines whether a dot will be drawn at the highest value or
306
+ not. Defaulst to false.
307
+ </p>
308
+ <p>
309
+ :has_last - Determines whether a dot will be drawn at the last value or
310
+ not. Defaulst to false.
311
+ </p>
312
+ <p>
313
+ :min_color - A string or color code representing the color that the dot
314
+ drawn at the smallest value will be displayed as. Defaults to blue.
315
+ </p>
316
+ <p>
317
+ :max_color - A string or color code representing the color that the dot
318
+ drawn at the largest value will be displayed as. Defaults to green.
319
+ </p>
320
+ <p>
321
+ :last_color - A string or color code representing the color that the dot
322
+ drawn at the last value will be displayed as. Defaults to red.
323
+ </p>
324
+ <p>
325
+ :above_color - A string or color code representing the color to draw values
326
+ above or equal the upper value. Defaults to red.
327
+ </p>
328
+ <p>
329
+ :below_color - A string or color code representing the color to draw values
330
+ below the upper value. Defaults to gray.
331
+ </p>
332
+ </div>
333
+ </div>
334
+
335
+ <div id="method-M000004" class="method-detail">
336
+ <a name="M000004"></a>
337
+
338
+ <div class="method-heading">
339
+ <a href="Sparklines.src/M000004.html" target="Code" class="method-signature"
340
+ onclick="popupCode('Sparklines.src/M000004.html');return false;">
341
+ <span class="method-name">discrete</span><span class="method-args">(results=[], options = {})</span>
342
+ </a>
343
+ </div>
344
+
345
+ <div class="method-description">
346
+ <p>
347
+ Creates a discretized sparkline
348
+ </p>
349
+ <ul>
350
+ <li>results is an array of integer values between 0 and 100 inclusive
351
+
352
+ </li>
353
+ <li>options is a hash that takes 4 parameters:
354
+
355
+ </li>
356
+ </ul>
357
+ <p>
358
+ :height - An integer that determines what the height of the sparkline will
359
+ be. Defaults to 14
360
+ </p>
361
+ <p>
362
+ :upper - An integer that determines the threshold for colorization
363
+ purposes. Any value less than upper will be colored using below_color,
364
+ anything above and equal to upper will use above_color. Defaults to 50.
365
+ </p>
366
+ <p>
367
+ :above_color - A string or color code representing the color to draw values
368
+ above or equal the upper value. Defaults to red.
369
+ </p>
370
+ <p>
371
+ :below_color - A string or color code representing the color to draw values
372
+ below the upper value. Defaults to gray.
373
+ </p>
374
+ </div>
375
+ </div>
376
+
377
+ <div id="method-M000007" class="method-detail">
378
+ <a name="M000007"></a>
379
+
380
+ <div class="method-heading">
381
+ <a href="Sparklines.src/M000007.html" target="Code" class="method-signature"
382
+ onclick="popupCode('Sparklines.src/M000007.html');return false;">
383
+ <span class="method-name">my_polyline</span><span class="method-args">(draw, arr)</span>
384
+ </a>
385
+ </div>
386
+
387
+ <div class="method-description">
388
+ <p>
389
+ This is a function to replace the RMagick polyline function because it
390
+ doesn&#8217;t seem to work properly.
391
+ </p>
392
+ <ul>
393
+ <li>draw - a RMagick::Draw object.
394
+
395
+ </li>
396
+ <li>arr - an array of points (represented as two element arrays)
397
+
398
+ </li>
399
+ </ul>
400
+ </div>
401
+ </div>
402
+
403
+ <div id="method-M000003" class="method-detail">
404
+ <a name="M000003"></a>
405
+
406
+ <div class="method-heading">
407
+ <a href="Sparklines.src/M000003.html" target="Code" class="method-signature"
408
+ onclick="popupCode('Sparklines.src/M000003.html');return false;">
409
+ <span class="method-name">pie</span><span class="method-args">(results=[],options={})</span>
410
+ </a>
411
+ </div>
412
+
413
+ <div class="method-description">
414
+ <p>
415
+ Creates a pie-chart sparkline
416
+ </p>
417
+ <ul>
418
+ <li>results - an array of integer values between 0 and 100 inclusive. Only the
419
+ first integer will be accepted. It will be used to determine the percentage
420
+ of the pie that is filled by the share_color
421
+
422
+ </li>
423
+ <li>options - a hash that takes parameters:
424
+
425
+ </li>
426
+ </ul>
427
+ <p>
428
+ :diameter - An integer that determines what the size of the sparkline will
429
+ be. Defaults to 20
430
+ </p>
431
+ <p>
432
+ :share_color - A string or color code representing the color to draw the
433
+ share of the pie represented by percent. Defaults to blue.
434
+ </p>
435
+ <p>
436
+ :remain_color - A string or color code representing the color to draw the
437
+ pie not taken by the share color. Defaults to lightgrey.
438
+ </p>
439
+ </div>
440
+ </div>
441
+
442
+ <div id="method-M000001" class="method-detail">
443
+ <a name="M000001"></a>
444
+
445
+ <div class="method-heading">
446
+ <a href="Sparklines.src/M000001.html" target="Code" class="method-signature"
447
+ onclick="popupCode('Sparklines.src/M000001.html');return false;">
448
+ <span class="method-name">plot</span><span class="method-args">(results=[], options={})</span>
449
+ </a>
450
+ </div>
451
+
452
+ <div class="method-description">
453
+ <p>
454
+ Does the actually plotting of the graph. Calls the appropriate function
455
+ based on the :type value passed. Defaults to &#8216;smooth.&#8217;
456
+ </p>
457
+ </div>
458
+ </div>
459
+
460
+ <div id="method-M000008" class="method-detail">
461
+ <a name="M000008"></a>
462
+
463
+ <div class="method-heading">
464
+ <a href="Sparklines.src/M000008.html" target="Code" class="method-signature"
465
+ onclick="popupCode('Sparklines.src/M000008.html');return false;">
466
+ <span class="method-name">plot_error</span><span class="method-args">(options={})</span>
467
+ </a>
468
+ </div>
469
+
470
+ <div class="method-description">
471
+ <p>
472
+ Draw the error Sparkline. Not implemented yet.
473
+ </p>
474
+ </div>
475
+ </div>
476
+
477
+ <div id="method-M000002" class="method-detail">
478
+ <a name="M000002"></a>
479
+
480
+ <div class="method-heading">
481
+ <a href="Sparklines.src/M000002.html" target="Code" class="method-signature"
482
+ onclick="popupCode('Sparklines.src/M000002.html');return false;">
483
+ <span class="method-name">plot_to_file</span><span class="method-args">(filename=&quot;sparklines.png&quot;, results=[], options={})</span>
484
+ </a>
485
+ </div>
486
+
487
+ <div class="method-description">
488
+ <p>
489
+ Writes a graph to disk with the specified filename, or
490
+ &quot;Sparklines.png&quot;
491
+ </p>
492
+ </div>
493
+ </div>
494
+
495
+ <div id="method-M000006" class="method-detail">
496
+ <a name="M000006"></a>
497
+
498
+ <div class="method-heading">
499
+ <a href="Sparklines.src/M000006.html" target="Code" class="method-signature"
500
+ onclick="popupCode('Sparklines.src/M000006.html');return false;">
501
+ <span class="method-name">smooth</span><span class="method-args">(results, options)</span>
502
+ </a>
503
+ </div>
504
+
505
+ <div class="method-description">
506
+ <p>
507
+ Creates a smooth sparkline
508
+ </p>
509
+ <ul>
510
+ <li>results - an array of integer values between 0 and 100 inclusive
511
+
512
+ </li>
513
+ <li>options - a hash that takes these optional parameters:
514
+
515
+ </li>
516
+ </ul>
517
+ <p>
518
+ :step - An integer that determines the distance between each point on the
519
+ sparkline. Defaults to 2.
520
+ </p>
521
+ <p>
522
+ :height - An integer that determines what the height of the sparkline will
523
+ be. Defaults to 14
524
+ </p>
525
+ <p>
526
+ :has_min - Determines whether a dot will be drawn at the lowest value or
527
+ not. Defaulst to false.
528
+ </p>
529
+ <p>
530
+ :has_max - Determines whether a dot will be drawn at the highest value or
531
+ not. Defaulst to false.
532
+ </p>
533
+ <p>
534
+ :has_last - Determines whether a dot will be drawn at the last value or
535
+ not. Defaulst to false.
536
+ </p>
537
+ <p>
538
+ :min_color - A string or color code representing the color that the dot
539
+ drawn at the smallest value will be displayed as. Defaults to blue.
540
+ </p>
541
+ <p>
542
+ :max_color - A string or color code representing the color that the dot
543
+ drawn at the largest value will be displayed as. Defaults to green.
544
+ </p>
545
+ <p>
546
+ :last_color - A string or color code representing the color that the dot
547
+ drawn at the last value will be displayed as. Defaults to red.
548
+ </p>
549
+ </div>
550
+ </div>
551
+
552
+
553
+ </div>
554
+
555
+
556
+ </div>
557
+
558
+
559
+ <div id="validator-badges">
560
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
561
+ </div>
562
+
563
+ </body>
564
+ </html>
@@ -0,0 +1,59 @@
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">&gt;</span> <span class="ruby-value str">'smooth'</span>,
16
+ <span class="ruby-identifier">:height</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">14</span>,
17
+ <span class="ruby-identifier">:upper</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">50</span>,
18
+ <span class="ruby-identifier">:diameter</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">20</span>,
19
+ <span class="ruby-identifier">:step</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">2</span>,
20
+ <span class="ruby-identifier">:line_color</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'lightgrey'</span>,
21
+
22
+ <span class="ruby-identifier">:above_color</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'red'</span>,
23
+ <span class="ruby-identifier">:below_color</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'grey'</span>,
24
+ <span class="ruby-identifier">:background_color</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'white'</span>,
25
+ <span class="ruby-identifier">:share_color</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'blue'</span>,
26
+ <span class="ruby-identifier">:remain_color</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'lightgrey'</span>,
27
+ <span class="ruby-identifier">:min_color</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'blue'</span>,
28
+ <span class="ruby-identifier">:max_color</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'green'</span>,
29
+ <span class="ruby-identifier">:last_color</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'red'</span>,
30
+
31
+ <span class="ruby-identifier">:has_min</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">false</span>,
32
+ <span class="ruby-identifier">:has_max</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">false</span>,
33
+ <span class="ruby-identifier">:has_last</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">false</span>
34
+ }
35
+
36
+ <span class="ruby-comment cmt"># This symbol-&gt;string-&gt;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>
@@ -0,0 +1,20 @@
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">&quot;sparklines.png&quot;</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">&lt;&lt;</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>
@@ -0,0 +1,61 @@
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">&quot;PNG&quot;</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">#Okay, this part is as confusing as hell, so pay attention:
32
+ <span class="ruby-comment cmt">#This line determines the horizontal portion of the point on the circle where the X-Axis
33
+ <span class="ruby-comment cmt">#should end. It's caculated by taking the center of the on-image circle and adding that
34
+ <span class="ruby-comment cmt">#to the radius multiplied by the formula for determinig the point on a unit circle that a
35
+ <span class="ruby-comment cmt">#angle corresponds to. 3.6 * percent gives us that angle, but it's in degrees, so we need to
36
+ <span class="ruby-comment cmt">#convert, hence the muliplication by Pi over 180
37
+ <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>)))
38
+
39
+ <span class="ruby-comment cmt">#The same goes for here, except it's the vertical point instead of the horizontal one
40
+ <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>)))
41
+
42
+ <span class="ruby-comment cmt">#Because the SVG path format is seriously screwy, we need to set the large-arc-flag to 1
43
+ <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.
44
+ <span class="ruby-identifier">percent</span> <span class="ruby-operator">&gt;</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>
45
+
46
+ <span class="ruby-comment cmt">#This is also confusing
47
+ <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
48
+ <span class="ruby-comment cmt">#h tells us to move to a relative point. We're moving to the right edge of the circle.
49
+ <span class="ruby-comment cmt">#A tells us to start an absolute elliptical arc. The first two values are the radii of the ellipse
50
+ <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
51
+ <span class="ruby-comment cmt">#with randomizing that maybe), the fourth value is our large-arc-flag, the fifth is the sweep-flag,
52
+ <span class="ruby-comment cmt">#(again, confusing), the sixth and seventh values are the end point of the arc which we calculated previously
53
+ <span class="ruby-comment cmt">#More info on the SVG path string format at: http://www.w3.org/TR/SVG/paths.html
54
+ <span class="ruby-identifier">path</span> = <span class="ruby-node">&quot;M#{r + 2},#{r + 2} h#{r} A#{r},#{r} 0 #{large_arc_flag},1 #{arc_end_x},#{arc_end_y} z&quot;</span>
55
+ <span class="ruby-identifier">draw</span>.<span class="ruby-identifier">path</span>(<span class="ruby-identifier">path</span>)
56
+
57
+ <span class="ruby-identifier">draw</span>.<span class="ruby-identifier">draw</span>(<span class="ruby-identifier">img</span>)
58
+ <span class="ruby-identifier">img</span>.<span class="ruby-identifier">to_blob</span>
59
+ <span class="ruby-keyword kw">end</span></pre>
60
+ </body>
61
+ </html>
@@ -0,0 +1,37 @@
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 217</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">&quot;PNG&quot;</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">&gt;=</span> <span class="ruby-identifier">upper</span>) <span class="ruby-operator">&amp;&amp;</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>
@@ -0,0 +1,88 @@
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 267</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">&quot;PNG&quot;</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>
@@ -0,0 +1,60 @@
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 362</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">&quot;PNG&quot;</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>
@@ -0,0 +1,22 @@
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 414</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">&lt;</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>
@@ -0,0 +1,26 @@
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 423</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">&quot;PNG&quot;</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 CHANGED
@@ -1 +1 @@
1
- Mon Aug 01 14:48:02 PDT 2005
1
+ Mon Aug 01 20:19:02 PDT 2005
@@ -0,0 +1,109 @@
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>Mon Aug 01 20:18:57 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&nbsp;&nbsp;
77
+ mathn&nbsp;&nbsp;
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>
data/lib/sparklines.rb CHANGED
@@ -57,11 +57,11 @@ And finally, add this to the controller whose view will be using sparklines:
57
57
 
58
58
  In your view, call it like this:
59
59
 
60
- <%= sparklines_tag [1,2,3,4,5,6] %> <!-- Gives you a smooth graph -->
60
+ <%= sparkline_tag [1,2,3,4,5,6] %> <!-- Gives you a smooth graph -->
61
61
 
62
62
  Or specify details:
63
63
 
64
- <%= sparklines_tag [1,2,3,4,5,6], :type => 'discrete', :height => 10, :upper => 80, :above_color => 'green', :below_color => 'blue' %>
64
+ <%= sparkline_tag [1,2,3,4,5,6], :type => 'discrete', :height => 10, :upper => 80, :above_color => 'green', :below_color => 'blue' %>
65
65
 
66
66
 
67
67
  Graph types:
@@ -88,7 +88,7 @@ Licensed under the MIT license.
88
88
  =end
89
89
 
90
90
  module Sparklines
91
- $VERSION = '0.2.1'
91
+ $VERSION = '0.2.2'
92
92
 
93
93
  # Does the actually plotting of the graph. Calls the appropriate function based on the :type value passed. Defaults to 'smooth.'
94
94
  def Sparklines.plot(results=[], options={})
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.8.10
3
3
  specification_version: 1
4
4
  name: sparklines
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.2.1
6
+ version: 0.2.2
7
7
  date: 2005-08-01
8
8
  summary: Sparklines generates tiny little graphs for use alongside tables or inline with text. Rails helpers are also available for easy use in web pages.
9
9
  require_paths:
@@ -29,13 +29,6 @@ authors:
29
29
  - Dan Nugent
30
30
  files:
31
31
  - lib/sparklines.rb
32
- - samples/area-high.png
33
- - samples/area.png
34
- - samples/discrete.png
35
- - samples/pie-large.png
36
- - samples/pie.png
37
- - samples/smooth-colored.png
38
- - samples/smooth.png
39
32
  - samples/sparklinestest.rb
40
33
  - docs/classes
41
34
  - docs/created.rid
@@ -45,6 +38,17 @@ files:
45
38
  - docs/fr_method_index.html
46
39
  - docs/index.html
47
40
  - docs/rdoc-style.css
41
+ - docs/classes/Sparklines.html
42
+ - docs/classes/Sparklines.src
43
+ - docs/classes/Sparklines.src/M000001.html
44
+ - docs/classes/Sparklines.src/M000002.html
45
+ - docs/classes/Sparklines.src/M000003.html
46
+ - docs/classes/Sparklines.src/M000004.html
47
+ - docs/classes/Sparklines.src/M000005.html
48
+ - docs/classes/Sparklines.src/M000006.html
49
+ - docs/classes/Sparklines.src/M000007.html
50
+ - docs/classes/Sparklines.src/M000008.html
51
+ - docs/files/sparklines_rb.html
48
52
  - README.txt
49
53
  test_files: []
50
54
  rdoc_options: []
Binary file
data/samples/area.png DELETED
Binary file
data/samples/discrete.png DELETED
Binary file
Binary file
data/samples/pie.png DELETED
Binary file
Binary file
data/samples/smooth.png DELETED
Binary file