forked from wes/Beautiful-Analytics-Chart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
520 lines (467 loc) · 12.4 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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Raphaël Line Charts Plugin</title>
<meta charset=check"utf-8">
<link rel="stylesheet" type="text/css" href="css/demo.css" media="screen">
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
<script type="text/javascript" src="http://ajax.cdnjs.com/ajax/libs/raphael/1.5.2/raphael-min.js"></script>
<script type="text/javascript" src="js/raphael_linechart.js"></script>
<script type="text/javascript">
window.onload = function(){
var w = 840;
var h1 = Raphael('chart1', w, 250);
var h1_source = 'd1';
var h2 = Raphael('chart2', w, 250);
var h3 = Raphael('chart3', w, 250);
var h4 = Raphael('chart4', w, 250);
h1.lineChart({
data_holder: h1_source,
width: w,
show_area: true,
mouse_coords: 'rect',
x_labels_step: 3,
y_labels_count: 5,
colors: {
master: '#d90000'
}
});
h2.lineChart({
data_holder: 'd2',
width: w,
show_area: true,
mouse_coords: 'circle',
colors: {
master: '#01A8F0'
}
});
h2.lineChart({
data_holder: 'd1',
width: w,
show_area: true,
mouse_coords: 'circle',
colors: {
master: '#8fd100'
}
});
h3.lineChart({
data_holder: 'd2',
width: w,
show_area: false,
x_labels_step: 3,
y_labels_count: 5,
mouse_coords: 'rect',
colors: {
master: '#d90000'
}
});
h4.lineChart({
data_holder: 'd1',
width: w,
show_area: false,
colors: {
master: '#cacaca'
}
});
h4.lineChart({
data_holder: 'd2',
width: w,
show_area: false,
colors: {
master: '#989898'
}
});
change_h1 = function() {
h1_source = h1_source == 'd1' ? 'd2' : 'd1';
h1.lineChart('setDataHolder', h1_source);
}
}
</script>
</head>
<body>
<div id="main">
<div>
<h1>Raphaël Line Charts Plugin</h1>
<p>
This plugin is a result of frustration from current client-side charting solutions.<br/>
I needed something simple that would draw a line chart in SVG based on a table in a page,
be customizable enough and allow me to change the data set on demand.
I couldn't find one.<br/>
So here goes.
</p>
<p>
This plugin relies heavily on the wonderful <a href="http://raphaeljs.com/">Raphaël</a>
JavaScript SVG library.<br/>
It is also a (quite extensive) fork of
<a href="https://github.com/wes/Beautiful-Analytics-Chart">we's Beautiful Analytics Chart</a> project.
</p>
<p>
To download and contribute (please do!), check out the
<a href="https://github.com/n0nick/raphael-linechart">project on GitHub</a>.
</p>
</div>
<div class="box">
<div class="inner">
<div id="chart1"></div>
<button onclick="change_h1()">Change data source</button>
</div>
</div>
<div>
<h2>Features</h2>
<p>
The concept for the code is dervied from the Raphaël
<a href="http://raphaeljs.com/analytics.html">Analytics example</a>.<br/>
<ul>
<li>Draws a line chart with custom design for a given set of data.</li>
<li>Framework agnostic (only requirement is Raphaël).</li>
<li>Semantic use of the document: data is loaded from a table element.</li>
<li>Ability to change data source (updating the chart).</li>
<li>Custom display of X & Y axis labels.</li>
</ul>
</p>
<h2>Requirements</h2>
<p>
<ul>
<li>Raphaël - <a href="http://raphaeljs.com">http://raphaeljs.com</a></li>
</ul>
</p>
</div>
<div class="box">
<div class="inner">
<div id="chart2"></div>
</div>
</div>
<div>
<h2>Usage</h2>
<h3>Include it.</h3>
<script src="https://gist.github.com/986722.js?file=gistfile1.html"></script>
<h3>Give it data.</h3>
<p>
Future versions will allow more flexible ways of passing data, either by different
types of elements or by directly passing an array.
</p>
<script src="https://gist.github.com/986725.js?file=gistfile1.html"></script>
<h3>Call it.</h3>
<script src="https://gist.github.com/986726.js?file=gistfile1.html"></script>
</div>
<div class="box">
<div class="inner">
<div id="chart3"></div>
</div>
</div>
<div>
<a name="drawline"></a>
<h2>Documentation</h2>
<p>The lineChart() plugin will accept a list of arguments in a json style format.</p>
<script src="https://gist.github.com/986727.js?file=gistfile1.js"></script>
</div>
<div>
<a name="drawline"></a>
<h2>Download</h2>
<p>
Check out <a href="https://github.com/n0nick/raphael-linechart">the project page on GitHub</a>
to download the source and example files.
</p>
</div>
<div class="box">
<div class="inner">
<div id="chart4"></div>
</div>
</div>
<div>
<h2>Thanks!</h2>
<p>
This page is mostly a rip-off of the original
<a href="http://joedesigns.com/labs/Beautiful-Analytics-Chart/">Beautiful Analytics Chart</a>
code, which my plugin is a fork of.<br/>
So credit is due to <a href="http://joedesigns.com/">Joe Designs</a> for the initial work and <a href="http://raphaeljs.com/">Dmitry Baranovskiy</a> for Raphaël JS.
</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/n0nick/raphael-linechart" id="fork_me"><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>