-
Notifications
You must be signed in to change notification settings - Fork 15
/
index.html
623 lines (560 loc) · 17.8 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
<html>
<head>
<title>Beautiful Analytics Chart</title>
<link rel="stylesheet" href="css/demo.css" type="text/css" media="screen" title="Demo Stylesheet" charset="utf-8">
<script type='text/javascript' src='js/lib/prototype.js'></script>
<script type='text/javascript' src='js/lib/raphael.js'></script>
<script type='text/javascript' src='js/lib/highlight.js'></script>
<script type='text/javascript' src='js/analytics.js'></script>
<script type='text/javascript'>
Element.observe(window,'load', function(){
var w = 840;
var h1 = Raphael('beautiful-line-chart1', w, 250);
var h2 = Raphael('beautiful-line-chart2', w, 250);
var h3 = Raphael('beautiful-line-chart3', w, 250);
var h4 = Raphael('beautiful-line-chart4', w, 250);
drawLine({
holder: h1,
data_holder: 'd2',
mastercolor: '#01A8F0',
spewidth: w,
showarea: true,
mousecoords: 'circle',
nodot: true
});
drawLine({
holder: h1,
data_holder: 'd1',
mastercolor: '#666',
spewidth: w,
showarea: true,
mousecoords: 'circle',
});
drawLine({
holder: h2,
data_holder: 'd2',
mastercolor: '#555',
spewidth: w,
showarea: false,
mousecoords: 'circle',
gridcolor: '#333333',
nodot: true
});
drawLine({
holder: h2,
data_holder: 'd1',
mastercolor: '#8dd916',
spewidth: w,
showarea: true,
mousecoords: 'circle',
gridcolor: '#333333',
dotcolor: '#333333'
});
drawLine({
holder: h3,
data_holder: 'd2',
mastercolor: '#d90000',
spewidth: w,
showarea: false,
mousecoords: 'rect'
});
drawLine({
holder: h4,
data_holder: 'd2',
mastercolor: '#ccc',
spewidth: w,
showarea: false,
nodot: true // hide dots
});
drawLine({
holder: h4,
data_holder: 'd1',
mastercolor: '#eb2682',
spewidth: w,
showarea: true,
nodot: true // hide dots
});
});
// Just used in the code highlighter
hljs.tabReplace = ' ';
hljs.initHighlightingOnLoad();
</script>
</head>
<body>
<div id='main'>
<div class='typography'>
<h1>Beautiful Analytics Chart</h1>
<p class='s3'>Ever wanted a really great line chart that is simple and unobtrusive?<br />There are many options out there, this is just another option.</p>
<p>Leave your comment on the <a href='http://joedesigns.com/v22/index.php?page=scripts_widgets&id=83#comments'>blog post</a>.</p>
<p>Check out the <a href='https://github.com/wes/Beautiful-Analytics-Chart' target='new'>project on github</a>.</p>
</div>
<div class='box rotate_r'>
<div class='inner'>
<div id='beautiful-line-chart1'></div>
</div>
</div>
<div class='typography'>
<h2>About</h2>
<p class='s1'>This is derived from a <a href='http://raphaeljs.com/analytics.html'>raphael example</a>, rewritten to use prototype and support a few more configurations. My overall goal with this line chart was to create a simple and easy to use library that can create great looking line charts. After seeing raphael's example, I knew this was the perfect place to start.</p>
<hr />
<h2>Requirements</h2>
<p>
<ul>
<li>Prototype JS - <a href='http://prototypejs.org'>http://prototypejs.org</a></li>
<li>Raphael - <a href='http://raphaeljs.com'>http://raphaeljs.com</a></li>
</ul>
</p>
</div>
<div class='box rotate_l dark'>
<div class='inner'>
<div id='beautiful-line-chart2'></div>
</div>
</div>
<div class='typography'>
<h2>Installation and Usage</h2>
<p>
<b>Step 1.</b><br />
You must first include prototype, raphael and the <a href='js/analytics.js'>analytics</a> library.
</p>
<pre>
<code class='html'>
<script type='text/javascript' src='js/lib/prototype.js'></script>
<script type='text/javascript' src='js/lib/raphael.js'></script>
<script type='text/javascript' src='js/analytics.js'></script>
</code>
</pre>
<p>
<b>Step 2.</b><br />
Create your holding div and table data templates as below or see example <a href='#download'>download</a>.
</p>
<pre>
<code class='html'>
<div id='line-chart-holder'></div>
<table id="d1" style='display: none;'>
<tfoot>
<tr>
<th>3/02</th>
<th>3/03</th>
<th>3/09</th>
<th>3/16</th>
</tr>
</tfoot>
<tbody class='data'>
<tr>
<td>70</td>
<td>70</td>
<td>210</td>
<td>490</td>
</tr>
</tbody>
<tbody class='line1'>
<tr>
<td>70 Views</td>
<td>70 Views</td>
<td>210 Views</td>
<td>490 Views</td>
</tr>
</tbody>
<tbody class='line2'>
<tr>
<td>Mar 2nd 2011</td>
<td>Mar 3rd 2011</td>
<td>Mar 9th 2011</td>
<td>Mar 16th 2011</td>
</tr>
</tbody>
</table>
</code>
</pre>
<p>
<b>Step 3.</b><br />
Call the <a href='#drawline'>drawLine()</a> function to create your line chart.
</p>
<pre>
<code class='html'>
<script type='text/javascript'>
Element.observe(window,'load', function(){
var w = 840; // you can make this dynamic so it fits as you would like
var linechart = Raphael('line-chart', w, 250); // init the raphael obj and give it a width plus height
drawLine({ // call the drawLine function
holder: linechart, // pass through the raphael obj
data_holder: 'd2', // find the table data source by id
mastercolor: '#01A8F0', // set the line color
spewidth: w, // pass in the same width
showarea: true, // show the area
mousecoords: 'rect' // rect (uses blanket mode) | circle (pinpoints the points)
});
});
</script>
</code>
</pre>
</div>
<div class='box rotate_r'>
<div class='inner'>
<div id='beautiful-line-chart3'></div>
</div>
</div>
<div class='typography'>
<a name='drawline'></a>
<h2>Documentation</h2>
<p>The drawLine() function will accept a list of arguments in a json style format.</p>
<pre>
<code class='javascript'>
var opts = {
holder: '', // id of div holder
data_holder: '', // id of table data holder
mastercolor: '', // line color ex: #ff0000
spewidth: '', // width in pixels
showarea: '', // bool to show the area of the line
linecolor1: '', // color of the line1 in popup
linecolor2: '', // color of the line2 in popup
mousecoords: '', // selection of mouseover | rect (default), circle
nogrid: '' // bool hide grid override.. grid be drawn once for every line chart holder
}
drawLine(opts); // draw the line chart
</code>
</pre>
</div>
<div class='typography'>
<a name='drawline'></a>
<h2>Download</h2>
<p class='s3'>Download <a href='js/analytics.js'>Analytics JS File</a> (8kb) Min</p>
<p class='s3'>Download <a href='http://joedesigns.com/download_file.php?f=https%3A%2F%2Fgithub.com%2Fwes%2FBeautiful-Analytics-Chart%2Fzipball%2Fmaster'>Full Example</a> (225kb) Zipped</p>
</div>
<div class='box rotate_l'>
<div class='inner'>
<div id='beautiful-line-chart4'></div>
</div>
</div>
<div class='typography'>
<a name='drawline'></a>
<h2>Extras</h2>
<p>You can add a little css to give the charts depth and page like feel.</p>
<pre>
<code class='css'>
.box {
margin: 0;
padding: 0;
clear: both;
overflow: hidden;
}
.rotate_r { -webkit-transform: rotate(-2deg); -moz-transform: rotate(-2deg); }
.rotate_l { -webkit-transform: rotate(2deg); -moz-transform: rotate(2deg); }
.box .inner {
list-style-type: none;
margin: 0 30px 30px 0;
padding: 14px 0 0 15px;
width: 850px;
height: 250px;
border: 0;
position: relative;
float: left;
background: #fafafa;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.27), 0 0 40px rgba(0, 0, 0, 0.06) inset;
-webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.27), 0 0 60px rgba(100, 100, 0, 0.1) inset;
-moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.27), 0 0 40px rgba(0, 0, 0, 0.06) inset; }
</code>
</pre>
<p>Then make sure it has some html wrapping the holding container.</p>
<pre>
<code class='html'>
<div class='box rotate_l'>
<div class='inner'>
<div id='line-chart'></div>
</div>
</div>
</code>
</pre>
<h2>Thanks!</h2>
<p>
I just wanted to say thanks to Dmitry Baranovskiy at <a href='http://raphaeljs.com'>Raphael JS</a>, for supplying such an awesome example. Also Nic Knight for helping me test and abstract the changes overall.
</p>
</div>
</div>
<table id="d1" style='display: none;'>
<tfoot>
<tr>
<th>3/02</th>
<th>3/03</th>
<th>3/09</th>
<th>3/16</th>
<th>3/18</th>
<th>3/21</th>
<th>3/22</th>
<th>3/28</th>
<th>3/29</th>
<th>3/30</th>
<th>3/31</th>
<th>4/01</th>
<th>4/02</th>
<th>4/04</th>
<th>4/05</th>
<th>4/06</th>
<th>4/07</th>
<th>4/08</th>
<th>4/09</th>
<th>4/10</th>
<th>4/12</th>
<th>4/13</th>
<th>4/14</th>
<th>4/15</th>
<th>4/16</th>
<th>4/17</th>
<th>4/18</th>
<th>4/19</th>
<th>4/20</th>
<th>4/21</th>
<th>4/22</th>
</tr>
</tfoot>
<tbody class='data'>
<tr>
<td>70</td>
<td>70</td>
<td>210</td>
<td>490</td>
<td>105</td>
<td>70</td>
<td>0</td>
<td>105</td>
<td>0</td>
<td>210</td>
<td>0</td>
<td>70</td>
<td>0</td>
<td>70</td>
<td>245</td>
<td>350</td>
<td>0</td>
<td>280</td>
<td>175</td>
<td>210</td>
<td>140</td>
<td>210</td>
<td>210</td>
<td>420</td>
<td>70</td>
<td>140</td>
<td>70</td>
<td>1085</td>
<td>875</td>
<td>350</td>
<td>175</td>
</tr>
</tbody>
<tbody class='line1'>
<tr>
<td>70 Views</td>
<td>70 Views</td>
<td>210 Views</td>
<td>490 Views</td>
<td>105 Views</td>
<td>70 Views</td>
<td>0 Views</td>
<td>105 Views</td>
<td>0 Views</td>
<td>210 Views</td>
<td>0 Views</td>
<td>70 Views</td>
<td>0 Views</td>
<td>70 Views</td>
<td>245 Views</td>
<td>350 Views</td>
<td>0 Views</td>
<td>280 Views</td>
<td>175 Views</td>
<td>210 Views</td>
<td>140 Views</td>
<td>210 Views</td>
<td>210 Views</td>
<td>420 Views</td>
<td>70 Views</td>
<td>140 Views</td>
<td>70 Views</td>
<td>1,085 Views</td>
<td>875 Views</td>
<td>350 Views</td>
<td>175 Views</td>
</tr>
</tbody>
<tbody class='line2'>
<tr>
<td>Mar 2nd 2011</td>
<td>Mar 3rd 2011</td>
<td>Mar 9th 2011</td>
<td>Mar 16th 2011</td>
<td>Mar 18th 2011</td>
<td>Mar 21st 2011</td>
<td>Mar 22nd 2011</td>
<td>Mar 28th 2011</td>
<td>Mar 29th 2011</td>
<td>Mar 30th 2011</td>
<td>Mar 31st 2011</td>
<td>Apr 1st 2011</td>
<td>Apr 2nd 2011</td>
<td>Apr 4th 2011</td>
<td>Apr 5th 2011</td>
<td>Apr 6th 2011</td>
<td>Apr 7th 2011</td>
<td>Apr 8th 2011</td>
<td>Apr 9th 2011</td>
<td>Apr 10th 2011</td>
<td>Apr 12th 2011</td>
<td>Apr 13th 2011</td>
<td>Apr 14th 2011</td>
<td>Apr 15th 2011</td>
<td>Apr 16th 2011</td>
<td>Apr 17th 2011</td>
<td>Apr 18th 2011</td>
<td>Apr 19th 2011</td>
<td>Apr 20th 2011</td>
<td>Apr 21st 2011</td>
<td>Apr 22nd 2011</td>
</tr>
</tbody>
</table>
<table id="d2" style='display: none;'>
<tfoot>
<tr>
<th>3/02</th>
<th>3/03</th>
<th>3/09</th>
<th>3/16</th>
<th>3/18</th>
<th>3/21</th>
<th>3/22</th>
<th>3/28</th>
<th>3/29</th>
<th>3/30</th>
<th>3/31</th>
<th>4/01</th>
<th>4/02</th>
<th>4/04</th>
<th>4/05</th>
<th>4/06</th>
<th>4/07</th>
<th>4/08</th>
<th>4/09</th>
<th>4/10</th>
<th>4/12</th>
<th>4/13</th>
<th>4/14</th>
<th>4/15</th>
<th>4/16</th>
<th>4/17</th>
<th>4/18</th>
<th>4/19</th>
<th>4/20</th>
<th>4/21</th>
<th>4/22</th>
</tr>
</tfoot>
<tbody class='data'>
<tr>
<td>70</td>
<td>140</td>
<td>350</td>
<td>840</td>
<td>945</td>
<td>1015</td>
<td>1015</td>
<td>1120</td>
<td>1120</td>
<td>1330</td>
<td>1330</td>
<td>1400</td>
<td>1400</td>
<td>1470</td>
<td>1715</td>
<td>2065</td>
<td>2065</td>
<td>2345</td>
<td>2520</td>
<td>2730</td>
<td>2870</td>
<td>3080</td>
<td>3290</td>
<td>3710</td>
<td>3780</td>
<td>3920</td>
<td>3990</td>
<td>5075</td>
<td>5950</td>
<td>6300</td>
<td>6475</td>
</tr>
</tbody>
<tbody class='line1'>
<tr>
<td>70 Users</td>
<td>140 Users</td>
<td>350 Users</td>
<td>840 Users</td>
<td>945 Users</td>
<td>1,015 Users</td>
<td>1,015 Users</td>
<td>1,120 Users</td>
<td>1,120 Users</td>
<td>1,330 Users</td>
<td>1,330 Users</td>
<td>1,400 Users</td>
<td>1,400 Users</td>
<td>1,470 Users</td>
<td>1,715 Users</td>
<td>2,065 Users</td>
<td>2,065 Users</td>
<td>2,345 Users</td>
<td>2,520 Users</td>
<td>2,730 Users</td>
<td>2,870 Users</td>
<td>3,080 Users</td>
<td>3,290 Users</td>
<td>3,710 Users</td>
<td>3,780 Users</td>
<td>3,920 Users</td>
<td>3,990 Users</td>
<td>5,075 Users</td>
<td>5,950 Users</td>
<td>6,300 Users</td>
<td>6,475 Users</td>
</tr>
</tbody>
<tbody class='line2'>
<tr>
<td>Mar 2nd 2011</td>
<td>Mar 3rd 2011</td>
<td>Mar 9th 2011</td>
<td>Mar 16th 2011</td>
<td>Mar 18th 2011</td>
<td>Mar 21st 2011</td>
<td>Mar 22nd 2011</td>
<td>Mar 28th 2011</td>
<td>Mar 29th 2011</td>
<td>Mar 30th 2011</td>
<td>Mar 31st 2011</td>
<td>Apr 1st 2011</td>
<td>Apr 2nd 2011</td>
<td>Apr 4th 2011</td>
<td>Apr 5th 2011</td>
<td>Apr 6th 2011</td>
<td>Apr 7th 2011</td>
<td>Apr 8th 2011</td>
<td>Apr 9th 2011</td>
<td>Apr 10th 2011</td>
<td>Apr 12th 2011</td>
<td>Apr 13th 2011</td>
<td>Apr 14th 2011</td>
<td>Apr 15th 2011</td>
<td>Apr 16th 2011</td>
<td>Apr 17th 2011</td>
<td>Apr 18th 2011</td>
<td>Apr 19th 2011</td>
<td>Apr 20th 2011</td>
<td>Apr 21st 2011</td>
<td>Apr 22nd 2011</td>
</tr>
</tbody>
</table>
<a href="http://github.com/wes/Beautiful-Analytics-Chart" id="fork_me" style="display:none;"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a>
</body>
</html>