contour 1.1.1 → 1.1.2.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +11 -0
- data/app/assets/images/twitter-bootstrap/v2.2.1/glyphicons-halflings-white.png +0 -0
- data/app/assets/images/twitter-bootstrap/v2.2.1/glyphicons-halflings.png +0 -0
- data/app/assets/javascripts/contour.js +3 -3
- data/app/assets/javascripts/external/{exporting-2.1.9.src.js → exporting-2.3.3.src.js} +736 -758
- data/app/assets/javascripts/external/highcharts-2.3.3.src.js +15111 -0
- data/app/assets/javascripts/twitter-bootstrap/{v2.1.1 → v2.2.1}/bootstrap.js +105 -107
- data/app/assets/stylesheets/bootstrap-base-overrides.css +6 -6
- data/app/assets/stylesheets/contour.css +2 -2
- data/app/assets/stylesheets/twitter-bootstrap/{v2.1.1 → v2.2.1}/bootstrap-responsive.css +33 -3
- data/app/assets/stylesheets/twitter-bootstrap/{v2.1.1 → v2.2.1}/bootstrap.css +377 -258
- data/app/views/contour/layouts/_per_page.html.erb +1 -1
- data/app/views/kaminari/contour-large/_first_page.html.erb +11 -0
- data/app/views/kaminari/contour-large/_gap.html.erb +8 -0
- data/app/views/kaminari/contour-large/_last_page.html.erb +11 -0
- data/app/views/kaminari/contour-large/_next_page.html.erb +11 -0
- data/app/views/kaminari/contour-large/_page.html.erb +12 -0
- data/app/views/kaminari/contour-large/_paginator.html.erb +25 -0
- data/app/views/kaminari/contour-large/_prev_page.html.erb +11 -0
- data/app/views/kaminari/contour-mini/_first_page.html.erb +11 -0
- data/app/views/kaminari/contour-mini/_gap.html.erb +8 -0
- data/app/views/kaminari/contour-mini/_last_page.html.erb +11 -0
- data/app/views/kaminari/contour-mini/_next_page.html.erb +11 -0
- data/app/views/kaminari/contour-mini/_page.html.erb +12 -0
- data/app/views/kaminari/contour-mini/_paginator.html.erb +25 -0
- data/app/views/kaminari/contour-mini/_prev_page.html.erb +11 -0
- data/app/views/kaminari/contour-small/_first_page.html.erb +11 -0
- data/app/views/kaminari/contour-small/_gap.html.erb +8 -0
- data/app/views/kaminari/contour-small/_last_page.html.erb +11 -0
- data/app/views/kaminari/contour-small/_next_page.html.erb +11 -0
- data/app/views/kaminari/contour-small/_page.html.erb +12 -0
- data/app/views/kaminari/contour-small/_paginator.html.erb +25 -0
- data/app/views/kaminari/contour-small/_prev_page.html.erb +11 -0
- data/app/views/kaminari/contour/_first_page.html.erb +11 -0
- data/app/views/kaminari/contour/_gap.html.erb +8 -0
- data/app/views/kaminari/contour/_last_page.html.erb +11 -0
- data/app/views/kaminari/contour/_next_page.html.erb +11 -0
- data/app/views/kaminari/contour/_page.html.erb +12 -0
- data/app/views/kaminari/contour/_paginator.html.erb +25 -0
- data/app/views/kaminari/contour/_prev_page.html.erb +11 -0
- data/contour.gemspec +4 -4
- data/lib/contour/version.rb +2 -2
- data/lib/generators/contour/scaffold/templates/_paginate.html.erb +1 -1
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +714 -0
- metadata +48 -18
- data/app/assets/javascripts/external/highcharts-2.1.9.src.js +0 -11454
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
== 1.1.2
|
2
|
+
|
3
|
+
* Enhancements
|
4
|
+
* Recommended Ruby bumped to 1.9.3-p327
|
5
|
+
* Updated Twitter Bootstrap to 2.2.1
|
6
|
+
* Updated HighCharts to 2.3.3
|
7
|
+
* Kaminari Pagination styling now provided, available themes:
|
8
|
+
* <%= paginate @items, theme: "contour[-large|-small|-mini]" %>
|
9
|
+
* Update Gem Dependencies
|
10
|
+
* rails 3.2.9, jquery-rails 2.1.4, omniauth-cas 1.0.0, omniauth-twitter 0.0.14
|
11
|
+
|
1
12
|
== 1.1.1
|
2
13
|
|
3
14
|
* Bug Fix
|
Binary file
|
@@ -7,12 +7,12 @@
|
|
7
7
|
//= require external/jquery-ui-1.8.22.custom.min.js
|
8
8
|
//= require external/jquery.qtip.min.js
|
9
9
|
//
|
10
|
-
//= require twitter-bootstrap/v2.
|
10
|
+
//= require twitter-bootstrap/v2.2.1/bootstrap
|
11
11
|
//
|
12
12
|
//= require twitter-bootstrap/bootstrap-scroll-modal
|
13
13
|
//= require twitter-bootstrap/bootstrap
|
14
14
|
//
|
15
|
-
//= require external/highcharts-2.
|
16
|
-
//= require external/exporting-2.
|
15
|
+
//= require external/highcharts-2.3.3.src.js
|
16
|
+
//= require external/exporting-2.3.3.src.js
|
17
17
|
//
|
18
18
|
//= require_tree .
|
@@ -1,758 +1,736 @@
|
|
1
|
-
/**
|
2
|
-
* @license Highcharts JS v2.
|
3
|
-
* Exporting module
|
4
|
-
*
|
5
|
-
* (c) 2010-2011 Torstein Hønsi
|
6
|
-
*
|
7
|
-
* License: www.highcharts.com/license
|
8
|
-
*/
|
9
|
-
|
10
|
-
// JSLint options:
|
11
|
-
/*global Highcharts, document, window, Math, setTimeout */
|
12
|
-
|
13
|
-
(function () { // encapsulate
|
14
|
-
|
15
|
-
// create shortcuts
|
16
|
-
var HC = Highcharts,
|
17
|
-
Chart = HC.Chart,
|
18
|
-
addEvent = HC.addEvent,
|
19
|
-
removeEvent = HC.removeEvent,
|
20
|
-
createElement = HC.createElement,
|
21
|
-
discardElement = HC.discardElement,
|
22
|
-
css = HC.css,
|
23
|
-
merge = HC.merge,
|
24
|
-
each = HC.each,
|
25
|
-
extend = HC.extend,
|
26
|
-
math = Math,
|
27
|
-
mathMax = math.max,
|
28
|
-
doc = document,
|
29
|
-
win = window,
|
30
|
-
hasTouch = doc.documentElement.ontouchstart !== undefined,
|
31
|
-
M = 'M',
|
32
|
-
L = 'L',
|
33
|
-
DIV = 'div',
|
34
|
-
HIDDEN = 'hidden',
|
35
|
-
NONE = 'none',
|
36
|
-
PREFIX = 'highcharts-',
|
37
|
-
ABSOLUTE = 'absolute',
|
38
|
-
PX = 'px',
|
39
|
-
UNDEFINED,
|
40
|
-
defaultOptions = HC.getOptions();
|
41
|
-
|
42
|
-
// Add language
|
43
|
-
extend(defaultOptions.lang, {
|
44
|
-
downloadPNG: 'Download PNG image',
|
45
|
-
downloadJPEG: 'Download JPEG image',
|
46
|
-
downloadPDF: 'Download PDF document',
|
47
|
-
downloadSVG: 'Download SVG vector image',
|
48
|
-
exportButtonTitle: 'Export to raster or vector image',
|
49
|
-
printButtonTitle: 'Print the chart'
|
50
|
-
});
|
51
|
-
|
52
|
-
// Buttons and menus are collected in a separate config option set called 'navigation'.
|
53
|
-
// This can be extended later to add control buttons like zoom and pan right click menus.
|
54
|
-
defaultOptions.navigation = {
|
55
|
-
menuStyle: {
|
56
|
-
border: '1px solid #A0A0A0',
|
57
|
-
background: '#FFFFFF'
|
58
|
-
},
|
59
|
-
menuItemStyle: {
|
60
|
-
padding: '0 5px',
|
61
|
-
background: NONE,
|
62
|
-
color: '#303030',
|
63
|
-
fontSize: hasTouch ? '14px' : '11px'
|
64
|
-
},
|
65
|
-
menuItemHoverStyle: {
|
66
|
-
background: '#4572A5',
|
67
|
-
color: '#FFFFFF'
|
68
|
-
},
|
69
|
-
|
70
|
-
buttonOptions: {
|
71
|
-
align: 'right',
|
72
|
-
backgroundColor: {
|
73
|
-
linearGradient: [0, 0, 0, 20],
|
74
|
-
stops: [
|
75
|
-
[0.4, '#F7F7F7'],
|
76
|
-
[0.6, '#E3E3E3']
|
77
|
-
]
|
78
|
-
},
|
79
|
-
borderColor: '#B0B0B0',
|
80
|
-
borderRadius: 3,
|
81
|
-
borderWidth: 1,
|
82
|
-
//enabled: true,
|
83
|
-
height: 20,
|
84
|
-
hoverBorderColor: '#909090',
|
85
|
-
hoverSymbolFill: '#81A7CF',
|
86
|
-
hoverSymbolStroke: '#4572A5',
|
87
|
-
symbolFill: '#E0E0E0',
|
88
|
-
//symbolSize: 12,
|
89
|
-
symbolStroke: '#A0A0A0',
|
90
|
-
//symbolStrokeWidth: 1,
|
91
|
-
symbolX: 11.5,
|
92
|
-
symbolY: 10.5,
|
93
|
-
verticalAlign: 'top',
|
94
|
-
width: 24,
|
95
|
-
y: 10
|
96
|
-
}
|
97
|
-
};
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
// Add the export related options
|
102
|
-
defaultOptions.exporting = {
|
103
|
-
//enabled: true,
|
104
|
-
//filename: 'chart',
|
105
|
-
type: 'image/png',
|
106
|
-
url: 'http://export.highcharts.com/',
|
107
|
-
width: 800,
|
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
|
-
seriesOptions
|
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
|
-
.replace(
|
298
|
-
|
299
|
-
.replace(/
|
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
|
-
buttonWidth
|
546
|
-
buttonHeight
|
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
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
}
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
// Create the
|
690
|
-
HC.Renderer.prototype.symbols.
|
691
|
-
return [
|
692
|
-
M, // the
|
693
|
-
x
|
694
|
-
L,
|
695
|
-
x +
|
696
|
-
x +
|
697
|
-
x
|
698
|
-
'Z',
|
699
|
-
M, // the
|
700
|
-
x, y +
|
701
|
-
L,
|
702
|
-
x
|
703
|
-
x
|
704
|
-
x
|
705
|
-
|
706
|
-
|
707
|
-
x +
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
};
|
737
|
-
|
738
|
-
|
739
|
-
// Add the buttons on chart load
|
740
|
-
Chart.prototype.callbacks.push(function (chart) {
|
741
|
-
var n,
|
742
|
-
exportingOptions = chart.options.exporting,
|
743
|
-
buttons = exportingOptions.buttons;
|
744
|
-
|
745
|
-
if (exportingOptions.enabled !== false) {
|
746
|
-
|
747
|
-
for (n in buttons) {
|
748
|
-
chart.addButton(buttons[n]);
|
749
|
-
}
|
750
|
-
|
751
|
-
// Destroy the export elements at chart destroy
|
752
|
-
addEvent(chart, 'destroy', chart.destroyExport);
|
753
|
-
}
|
754
|
-
|
755
|
-
});
|
756
|
-
|
757
|
-
|
758
|
-
}());
|
1
|
+
/**
|
2
|
+
* @license Highcharts JS v2.3.3 (2012-10-04)
|
3
|
+
* Exporting module
|
4
|
+
*
|
5
|
+
* (c) 2010-2011 Torstein Hønsi
|
6
|
+
*
|
7
|
+
* License: www.highcharts.com/license
|
8
|
+
*/
|
9
|
+
|
10
|
+
// JSLint options:
|
11
|
+
/*global Highcharts, document, window, Math, setTimeout */
|
12
|
+
|
13
|
+
(function () { // encapsulate
|
14
|
+
|
15
|
+
// create shortcuts
|
16
|
+
var HC = Highcharts,
|
17
|
+
Chart = HC.Chart,
|
18
|
+
addEvent = HC.addEvent,
|
19
|
+
removeEvent = HC.removeEvent,
|
20
|
+
createElement = HC.createElement,
|
21
|
+
discardElement = HC.discardElement,
|
22
|
+
css = HC.css,
|
23
|
+
merge = HC.merge,
|
24
|
+
each = HC.each,
|
25
|
+
extend = HC.extend,
|
26
|
+
math = Math,
|
27
|
+
mathMax = math.max,
|
28
|
+
doc = document,
|
29
|
+
win = window,
|
30
|
+
hasTouch = doc.documentElement.ontouchstart !== undefined,
|
31
|
+
M = 'M',
|
32
|
+
L = 'L',
|
33
|
+
DIV = 'div',
|
34
|
+
HIDDEN = 'hidden',
|
35
|
+
NONE = 'none',
|
36
|
+
PREFIX = 'highcharts-',
|
37
|
+
ABSOLUTE = 'absolute',
|
38
|
+
PX = 'px',
|
39
|
+
UNDEFINED,
|
40
|
+
defaultOptions = HC.getOptions();
|
41
|
+
|
42
|
+
// Add language
|
43
|
+
extend(defaultOptions.lang, {
|
44
|
+
downloadPNG: 'Download PNG image',
|
45
|
+
downloadJPEG: 'Download JPEG image',
|
46
|
+
downloadPDF: 'Download PDF document',
|
47
|
+
downloadSVG: 'Download SVG vector image',
|
48
|
+
exportButtonTitle: 'Export to raster or vector image',
|
49
|
+
printButtonTitle: 'Print the chart'
|
50
|
+
});
|
51
|
+
|
52
|
+
// Buttons and menus are collected in a separate config option set called 'navigation'.
|
53
|
+
// This can be extended later to add control buttons like zoom and pan right click menus.
|
54
|
+
defaultOptions.navigation = {
|
55
|
+
menuStyle: {
|
56
|
+
border: '1px solid #A0A0A0',
|
57
|
+
background: '#FFFFFF'
|
58
|
+
},
|
59
|
+
menuItemStyle: {
|
60
|
+
padding: '0 5px',
|
61
|
+
background: NONE,
|
62
|
+
color: '#303030',
|
63
|
+
fontSize: hasTouch ? '14px' : '11px'
|
64
|
+
},
|
65
|
+
menuItemHoverStyle: {
|
66
|
+
background: '#4572A5',
|
67
|
+
color: '#FFFFFF'
|
68
|
+
},
|
69
|
+
|
70
|
+
buttonOptions: {
|
71
|
+
align: 'right',
|
72
|
+
backgroundColor: {
|
73
|
+
linearGradient: [0, 0, 0, 20],
|
74
|
+
stops: [
|
75
|
+
[0.4, '#F7F7F7'],
|
76
|
+
[0.6, '#E3E3E3']
|
77
|
+
]
|
78
|
+
},
|
79
|
+
borderColor: '#B0B0B0',
|
80
|
+
borderRadius: 3,
|
81
|
+
borderWidth: 1,
|
82
|
+
//enabled: true,
|
83
|
+
height: 20,
|
84
|
+
hoverBorderColor: '#909090',
|
85
|
+
hoverSymbolFill: '#81A7CF',
|
86
|
+
hoverSymbolStroke: '#4572A5',
|
87
|
+
symbolFill: '#E0E0E0',
|
88
|
+
//symbolSize: 12,
|
89
|
+
symbolStroke: '#A0A0A0',
|
90
|
+
//symbolStrokeWidth: 1,
|
91
|
+
symbolX: 11.5,
|
92
|
+
symbolY: 10.5,
|
93
|
+
verticalAlign: 'top',
|
94
|
+
width: 24,
|
95
|
+
y: 10
|
96
|
+
}
|
97
|
+
};
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
// Add the export related options
|
102
|
+
defaultOptions.exporting = {
|
103
|
+
//enabled: true,
|
104
|
+
//filename: 'chart',
|
105
|
+
type: 'image/png',
|
106
|
+
url: 'http://export.highcharts.com/',
|
107
|
+
width: 800,
|
108
|
+
buttons: {
|
109
|
+
exportButton: {
|
110
|
+
//enabled: true,
|
111
|
+
symbol: 'exportIcon',
|
112
|
+
x: -10,
|
113
|
+
symbolFill: '#A8BF77',
|
114
|
+
hoverSymbolFill: '#768F3E',
|
115
|
+
_id: 'exportButton',
|
116
|
+
_titleKey: 'exportButtonTitle',
|
117
|
+
menuItems: [{
|
118
|
+
textKey: 'downloadPNG',
|
119
|
+
onclick: function () {
|
120
|
+
this.exportChart();
|
121
|
+
}
|
122
|
+
}, {
|
123
|
+
textKey: 'downloadJPEG',
|
124
|
+
onclick: function () {
|
125
|
+
this.exportChart({
|
126
|
+
type: 'image/jpeg'
|
127
|
+
});
|
128
|
+
}
|
129
|
+
}, {
|
130
|
+
textKey: 'downloadPDF',
|
131
|
+
onclick: function () {
|
132
|
+
this.exportChart({
|
133
|
+
type: 'application/pdf'
|
134
|
+
});
|
135
|
+
}
|
136
|
+
}, {
|
137
|
+
textKey: 'downloadSVG',
|
138
|
+
onclick: function () {
|
139
|
+
this.exportChart({
|
140
|
+
type: 'image/svg+xml'
|
141
|
+
});
|
142
|
+
}
|
143
|
+
}
|
144
|
+
// Enable this block to add "View SVG" to the dropdown menu
|
145
|
+
/*
|
146
|
+
,{
|
147
|
+
|
148
|
+
text: 'View SVG',
|
149
|
+
onclick: function () {
|
150
|
+
var svg = this.getSVG()
|
151
|
+
.replace(/</g, '\n<')
|
152
|
+
.replace(/>/g, '>');
|
153
|
+
|
154
|
+
doc.body.innerHTML = '<pre>' + svg + '</pre>';
|
155
|
+
}
|
156
|
+
} // */
|
157
|
+
]
|
158
|
+
|
159
|
+
},
|
160
|
+
printButton: {
|
161
|
+
//enabled: true,
|
162
|
+
symbol: 'printIcon',
|
163
|
+
x: -36,
|
164
|
+
symbolFill: '#B5C9DF',
|
165
|
+
hoverSymbolFill: '#779ABF',
|
166
|
+
_id: 'printButton',
|
167
|
+
_titleKey: 'printButtonTitle',
|
168
|
+
onclick: function () {
|
169
|
+
this.print();
|
170
|
+
}
|
171
|
+
}
|
172
|
+
}
|
173
|
+
};
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
extend(Chart.prototype, {
|
178
|
+
/**
|
179
|
+
* Return an SVG representation of the chart
|
180
|
+
*
|
181
|
+
* @param additionalOptions {Object} Additional chart options for the generated SVG representation
|
182
|
+
*/
|
183
|
+
getSVG: function (additionalOptions) {
|
184
|
+
var chart = this,
|
185
|
+
chartCopy,
|
186
|
+
sandbox,
|
187
|
+
svg,
|
188
|
+
seriesOptions,
|
189
|
+
options = merge(chart.options, additionalOptions); // copy the options and add extra options
|
190
|
+
|
191
|
+
// IE compatibility hack for generating SVG content that it doesn't really understand
|
192
|
+
if (!doc.createElementNS) {
|
193
|
+
/*jslint unparam: true*//* allow unused parameter ns in function below */
|
194
|
+
doc.createElementNS = function (ns, tagName) {
|
195
|
+
return doc.createElement(tagName);
|
196
|
+
};
|
197
|
+
/*jslint unparam: false*/
|
198
|
+
}
|
199
|
+
|
200
|
+
// create a sandbox where a new chart will be generated
|
201
|
+
sandbox = createElement(DIV, null, {
|
202
|
+
position: ABSOLUTE,
|
203
|
+
top: '-9999em',
|
204
|
+
width: chart.chartWidth + PX,
|
205
|
+
height: chart.chartHeight + PX
|
206
|
+
}, doc.body);
|
207
|
+
|
208
|
+
// override some options
|
209
|
+
extend(options.chart, {
|
210
|
+
renderTo: sandbox,
|
211
|
+
forExport: true
|
212
|
+
});
|
213
|
+
options.exporting.enabled = false; // hide buttons in print
|
214
|
+
options.chart.plotBackgroundImage = null; // the converter doesn't handle images
|
215
|
+
|
216
|
+
// prepare for replicating the chart
|
217
|
+
options.series = [];
|
218
|
+
each(chart.series, function (serie) {
|
219
|
+
seriesOptions = merge(serie.options, {
|
220
|
+
animation: false, // turn off animation
|
221
|
+
showCheckbox: false,
|
222
|
+
visible: serie.visible
|
223
|
+
});
|
224
|
+
|
225
|
+
if (!seriesOptions.isInternal) { // used for the navigator series that has its own option set
|
226
|
+
|
227
|
+
// remove image markers
|
228
|
+
if (seriesOptions && seriesOptions.marker && /^url\(/.test(seriesOptions.marker.symbol)) {
|
229
|
+
seriesOptions.marker.symbol = 'circle';
|
230
|
+
}
|
231
|
+
|
232
|
+
options.series.push(seriesOptions);
|
233
|
+
}
|
234
|
+
});
|
235
|
+
|
236
|
+
// generate the chart copy
|
237
|
+
chartCopy = new Highcharts.Chart(options);
|
238
|
+
|
239
|
+
// reflect axis extremes in the export
|
240
|
+
each(['xAxis', 'yAxis'], function (axisType) {
|
241
|
+
each(chart[axisType], function (axis, i) {
|
242
|
+
var axisCopy = chartCopy[axisType][i],
|
243
|
+
extremes = axis.getExtremes(),
|
244
|
+
userMin = extremes.userMin,
|
245
|
+
userMax = extremes.userMax;
|
246
|
+
|
247
|
+
if (userMin !== UNDEFINED || userMax !== UNDEFINED) {
|
248
|
+
axisCopy.setExtremes(userMin, userMax, true, false);
|
249
|
+
}
|
250
|
+
});
|
251
|
+
});
|
252
|
+
|
253
|
+
// get the SVG from the container's innerHTML
|
254
|
+
svg = chartCopy.container.innerHTML;
|
255
|
+
|
256
|
+
// free up memory
|
257
|
+
options = null;
|
258
|
+
chartCopy.destroy();
|
259
|
+
discardElement(sandbox);
|
260
|
+
|
261
|
+
// sanitize
|
262
|
+
svg = svg
|
263
|
+
.replace(/zIndex="[^"]+"/g, '')
|
264
|
+
.replace(/isShadow="[^"]+"/g, '')
|
265
|
+
.replace(/symbolName="[^"]+"/g, '')
|
266
|
+
.replace(/jQuery[0-9]+="[^"]+"/g, '')
|
267
|
+
.replace(/isTracker="[^"]+"/g, '')
|
268
|
+
.replace(/url\([^#]+#/g, 'url(#')
|
269
|
+
.replace(/<svg /, '<svg xmlns:xlink="http://www.w3.org/1999/xlink" ')
|
270
|
+
.replace(/ href=/g, ' xlink:href=')
|
271
|
+
.replace(/\n/, ' ')
|
272
|
+
.replace(/<\/svg>.*?$/, '</svg>') // any HTML added to the container after the SVG (#894)
|
273
|
+
/* This fails in IE < 8
|
274
|
+
.replace(/([0-9]+)\.([0-9]+)/g, function(s1, s2, s3) { // round off to save weight
|
275
|
+
return s2 +'.'+ s3[0];
|
276
|
+
})*/
|
277
|
+
|
278
|
+
// Replace HTML entities, issue #347
|
279
|
+
.replace(/ /g, '\u00A0') // no-break space
|
280
|
+
.replace(/­/g, '\u00AD') // soft hyphen
|
281
|
+
|
282
|
+
// IE specific
|
283
|
+
.replace(/<IMG /g, '<image ')
|
284
|
+
.replace(/height=([^" ]+)/g, 'height="$1"')
|
285
|
+
.replace(/width=([^" ]+)/g, 'width="$1"')
|
286
|
+
.replace(/hc-svg-href="([^"]+)">/g, 'xlink:href="$1"/>')
|
287
|
+
.replace(/id=([^" >]+)/g, 'id="$1"')
|
288
|
+
.replace(/class=([^" ]+)/g, 'class="$1"')
|
289
|
+
.replace(/ transform /g, ' ')
|
290
|
+
.replace(/:(path|rect)/g, '$1')
|
291
|
+
.replace(/style="([^"]+)"/g, function (s) {
|
292
|
+
return s.toLowerCase();
|
293
|
+
});
|
294
|
+
|
295
|
+
// IE9 beta bugs with innerHTML. Test again with final IE9.
|
296
|
+
svg = svg.replace(/(url\(#highcharts-[0-9]+)"/g, '$1')
|
297
|
+
.replace(/"/g, "'");
|
298
|
+
if (svg.match(/ xmlns="/g).length === 2) {
|
299
|
+
svg = svg.replace(/xmlns="[^"]+"/, '');
|
300
|
+
}
|
301
|
+
|
302
|
+
return svg;
|
303
|
+
},
|
304
|
+
|
305
|
+
/**
|
306
|
+
* Submit the SVG representation of the chart to the server
|
307
|
+
* @param {Object} options Exporting options. Possible members are url, type and width.
|
308
|
+
* @param {Object} chartOptions Additional chart options for the SVG representation of the chart
|
309
|
+
*/
|
310
|
+
exportChart: function (options, chartOptions) {
|
311
|
+
var form,
|
312
|
+
chart = this,
|
313
|
+
svg = chart.getSVG(merge(chart.options.exporting.chartOptions, chartOptions)); // docs
|
314
|
+
|
315
|
+
// merge the options
|
316
|
+
options = merge(chart.options.exporting, options);
|
317
|
+
|
318
|
+
// create the form
|
319
|
+
form = createElement('form', {
|
320
|
+
method: 'post',
|
321
|
+
action: options.url,
|
322
|
+
enctype: 'multipart/form-data'
|
323
|
+
}, {
|
324
|
+
display: NONE
|
325
|
+
}, doc.body);
|
326
|
+
|
327
|
+
// add the values
|
328
|
+
each(['filename', 'type', 'width', 'svg'], function (name) {
|
329
|
+
createElement('input', {
|
330
|
+
type: HIDDEN,
|
331
|
+
name: name,
|
332
|
+
value: {
|
333
|
+
filename: options.filename || 'chart',
|
334
|
+
type: options.type,
|
335
|
+
width: options.width,
|
336
|
+
svg: svg
|
337
|
+
}[name]
|
338
|
+
}, null, form);
|
339
|
+
});
|
340
|
+
|
341
|
+
// submit
|
342
|
+
form.submit();
|
343
|
+
|
344
|
+
// clean up
|
345
|
+
discardElement(form);
|
346
|
+
},
|
347
|
+
|
348
|
+
/**
|
349
|
+
* Print the chart
|
350
|
+
*/
|
351
|
+
print: function () {
|
352
|
+
|
353
|
+
var chart = this,
|
354
|
+
container = chart.container,
|
355
|
+
origDisplay = [],
|
356
|
+
origParent = container.parentNode,
|
357
|
+
body = doc.body,
|
358
|
+
childNodes = body.childNodes;
|
359
|
+
|
360
|
+
if (chart.isPrinting) { // block the button while in printing mode
|
361
|
+
return;
|
362
|
+
}
|
363
|
+
|
364
|
+
chart.isPrinting = true;
|
365
|
+
|
366
|
+
// hide all body content
|
367
|
+
each(childNodes, function (node, i) {
|
368
|
+
if (node.nodeType === 1) {
|
369
|
+
origDisplay[i] = node.style.display;
|
370
|
+
node.style.display = NONE;
|
371
|
+
}
|
372
|
+
});
|
373
|
+
|
374
|
+
// pull out the chart
|
375
|
+
body.appendChild(container);
|
376
|
+
|
377
|
+
// print
|
378
|
+
win.print();
|
379
|
+
|
380
|
+
// allow the browser to prepare before reverting
|
381
|
+
setTimeout(function () {
|
382
|
+
|
383
|
+
// put the chart back in
|
384
|
+
origParent.appendChild(container);
|
385
|
+
|
386
|
+
// restore all body content
|
387
|
+
each(childNodes, function (node, i) {
|
388
|
+
if (node.nodeType === 1) {
|
389
|
+
node.style.display = origDisplay[i];
|
390
|
+
}
|
391
|
+
});
|
392
|
+
|
393
|
+
chart.isPrinting = false;
|
394
|
+
|
395
|
+
}, 1000);
|
396
|
+
|
397
|
+
},
|
398
|
+
|
399
|
+
/**
|
400
|
+
* Display a popup menu for choosing the export type
|
401
|
+
*
|
402
|
+
* @param {String} name An identifier for the menu
|
403
|
+
* @param {Array} items A collection with text and onclicks for the items
|
404
|
+
* @param {Number} x The x position of the opener button
|
405
|
+
* @param {Number} y The y position of the opener button
|
406
|
+
* @param {Number} width The width of the opener button
|
407
|
+
* @param {Number} height The height of the opener button
|
408
|
+
*/
|
409
|
+
contextMenu: function (name, items, x, y, width, height) {
|
410
|
+
var chart = this,
|
411
|
+
navOptions = chart.options.navigation,
|
412
|
+
menuItemStyle = navOptions.menuItemStyle,
|
413
|
+
chartWidth = chart.chartWidth,
|
414
|
+
chartHeight = chart.chartHeight,
|
415
|
+
cacheName = 'cache-' + name,
|
416
|
+
menu = chart[cacheName],
|
417
|
+
menuPadding = mathMax(width, height), // for mouse leave detection
|
418
|
+
boxShadow = '3px 3px 10px #888',
|
419
|
+
innerMenu,
|
420
|
+
hide,
|
421
|
+
menuStyle;
|
422
|
+
|
423
|
+
// create the menu only the first time
|
424
|
+
if (!menu) {
|
425
|
+
|
426
|
+
// create a HTML element above the SVG
|
427
|
+
chart[cacheName] = menu = createElement(DIV, {
|
428
|
+
className: PREFIX + name
|
429
|
+
}, {
|
430
|
+
position: ABSOLUTE,
|
431
|
+
zIndex: 1000,
|
432
|
+
padding: menuPadding + PX
|
433
|
+
}, chart.container);
|
434
|
+
|
435
|
+
innerMenu = createElement(DIV, null,
|
436
|
+
extend({
|
437
|
+
MozBoxShadow: boxShadow,
|
438
|
+
WebkitBoxShadow: boxShadow,
|
439
|
+
boxShadow: boxShadow
|
440
|
+
}, navOptions.menuStyle), menu);
|
441
|
+
|
442
|
+
// hide on mouse out
|
443
|
+
hide = function () {
|
444
|
+
css(menu, { display: NONE });
|
445
|
+
};
|
446
|
+
|
447
|
+
addEvent(menu, 'mouseleave', hide);
|
448
|
+
|
449
|
+
|
450
|
+
// create the items
|
451
|
+
each(items, function (item) {
|
452
|
+
if (item) {
|
453
|
+
var div = createElement(DIV, {
|
454
|
+
onmouseover: function () {
|
455
|
+
css(this, navOptions.menuItemHoverStyle);
|
456
|
+
},
|
457
|
+
onmouseout: function () {
|
458
|
+
css(this, menuItemStyle);
|
459
|
+
},
|
460
|
+
innerHTML: item.text || chart.options.lang[item.textKey]
|
461
|
+
}, extend({
|
462
|
+
cursor: 'pointer'
|
463
|
+
}, menuItemStyle), innerMenu);
|
464
|
+
|
465
|
+
div[hasTouch ? 'ontouchstart' : 'onclick'] = function () {
|
466
|
+
hide();
|
467
|
+
item.onclick.apply(chart, arguments);
|
468
|
+
};
|
469
|
+
|
470
|
+
// Keep references to menu divs to be able to destroy them
|
471
|
+
chart.exportDivElements.push(div);
|
472
|
+
}
|
473
|
+
});
|
474
|
+
|
475
|
+
// Keep references to menu and innerMenu div to be able to destroy them
|
476
|
+
chart.exportDivElements.push(innerMenu, menu);
|
477
|
+
|
478
|
+
chart.exportMenuWidth = menu.offsetWidth;
|
479
|
+
chart.exportMenuHeight = menu.offsetHeight;
|
480
|
+
}
|
481
|
+
|
482
|
+
menuStyle = { display: 'block' };
|
483
|
+
|
484
|
+
// if outside right, right align it
|
485
|
+
if (x + chart.exportMenuWidth > chartWidth) {
|
486
|
+
menuStyle.right = (chartWidth - x - width - menuPadding) + PX;
|
487
|
+
} else {
|
488
|
+
menuStyle.left = (x - menuPadding) + PX;
|
489
|
+
}
|
490
|
+
// if outside bottom, bottom align it
|
491
|
+
if (y + height + chart.exportMenuHeight > chartHeight) {
|
492
|
+
menuStyle.bottom = (chartHeight - y - menuPadding) + PX;
|
493
|
+
} else {
|
494
|
+
menuStyle.top = (y + height - menuPadding) + PX;
|
495
|
+
}
|
496
|
+
|
497
|
+
css(menu, menuStyle);
|
498
|
+
},
|
499
|
+
|
500
|
+
/**
|
501
|
+
* Add the export button to the chart
|
502
|
+
*/
|
503
|
+
addButton: function (options) {
|
504
|
+
var chart = this,
|
505
|
+
renderer = chart.renderer,
|
506
|
+
btnOptions = merge(chart.options.navigation.buttonOptions, options),
|
507
|
+
onclick = btnOptions.onclick,
|
508
|
+
menuItems = btnOptions.menuItems,
|
509
|
+
buttonWidth = btnOptions.width,
|
510
|
+
buttonHeight = btnOptions.height,
|
511
|
+
box,
|
512
|
+
symbol,
|
513
|
+
button,
|
514
|
+
borderWidth = btnOptions.borderWidth,
|
515
|
+
boxAttr = {
|
516
|
+
stroke: btnOptions.borderColor
|
517
|
+
|
518
|
+
},
|
519
|
+
symbolAttr = {
|
520
|
+
stroke: btnOptions.symbolStroke,
|
521
|
+
fill: btnOptions.symbolFill
|
522
|
+
},
|
523
|
+
symbolSize = btnOptions.symbolSize || 12;
|
524
|
+
|
525
|
+
// Keeps references to the button elements
|
526
|
+
if (!chart.exportDivElements) {
|
527
|
+
chart.exportDivElements = [];
|
528
|
+
chart.exportSVGElements = [];
|
529
|
+
}
|
530
|
+
|
531
|
+
if (btnOptions.enabled === false) {
|
532
|
+
return;
|
533
|
+
}
|
534
|
+
|
535
|
+
// element to capture the click
|
536
|
+
function revert() {
|
537
|
+
symbol.attr(symbolAttr);
|
538
|
+
box.attr(boxAttr);
|
539
|
+
}
|
540
|
+
|
541
|
+
// the box border
|
542
|
+
box = renderer.rect(
|
543
|
+
0,
|
544
|
+
0,
|
545
|
+
buttonWidth,
|
546
|
+
buttonHeight,
|
547
|
+
btnOptions.borderRadius,
|
548
|
+
borderWidth
|
549
|
+
)
|
550
|
+
//.translate(buttonLeft, buttonTop) // to allow gradients
|
551
|
+
.align(btnOptions, true)
|
552
|
+
.attr(extend({
|
553
|
+
fill: btnOptions.backgroundColor,
|
554
|
+
'stroke-width': borderWidth,
|
555
|
+
zIndex: 19
|
556
|
+
}, boxAttr)).add();
|
557
|
+
|
558
|
+
// the invisible element to track the clicks
|
559
|
+
button = renderer.rect(
|
560
|
+
0,
|
561
|
+
0,
|
562
|
+
buttonWidth,
|
563
|
+
buttonHeight,
|
564
|
+
0
|
565
|
+
)
|
566
|
+
.align(btnOptions)
|
567
|
+
.attr({
|
568
|
+
id: btnOptions._id,
|
569
|
+
fill: 'rgba(255, 255, 255, 0.001)',
|
570
|
+
title: chart.options.lang[btnOptions._titleKey],
|
571
|
+
zIndex: 21
|
572
|
+
}).css({
|
573
|
+
cursor: 'pointer'
|
574
|
+
})
|
575
|
+
.on('mouseover', function () {
|
576
|
+
symbol.attr({
|
577
|
+
stroke: btnOptions.hoverSymbolStroke,
|
578
|
+
fill: btnOptions.hoverSymbolFill
|
579
|
+
});
|
580
|
+
box.attr({
|
581
|
+
stroke: btnOptions.hoverBorderColor
|
582
|
+
});
|
583
|
+
})
|
584
|
+
.on('mouseout', revert)
|
585
|
+
.on('click', revert)
|
586
|
+
.add();
|
587
|
+
|
588
|
+
// add the click event
|
589
|
+
if (menuItems) {
|
590
|
+
onclick = function () {
|
591
|
+
revert();
|
592
|
+
var bBox = button.getBBox();
|
593
|
+
chart.contextMenu('export-menu', menuItems, bBox.x, bBox.y, buttonWidth, buttonHeight);
|
594
|
+
};
|
595
|
+
}
|
596
|
+
/*addEvent(button.element, 'click', function() {
|
597
|
+
onclick.apply(chart, arguments);
|
598
|
+
});*/
|
599
|
+
button.on('click', function () {
|
600
|
+
onclick.apply(chart, arguments);
|
601
|
+
});
|
602
|
+
|
603
|
+
// the icon
|
604
|
+
symbol = renderer.symbol(
|
605
|
+
btnOptions.symbol,
|
606
|
+
btnOptions.symbolX - (symbolSize / 2),
|
607
|
+
btnOptions.symbolY - (symbolSize / 2),
|
608
|
+
symbolSize,
|
609
|
+
symbolSize
|
610
|
+
)
|
611
|
+
.align(btnOptions, true)
|
612
|
+
.attr(extend(symbolAttr, {
|
613
|
+
'stroke-width': btnOptions.symbolStrokeWidth || 1,
|
614
|
+
zIndex: 20
|
615
|
+
})).add();
|
616
|
+
|
617
|
+
// Keep references to the renderer element so to be able to destroy them later.
|
618
|
+
chart.exportSVGElements.push(box, button, symbol);
|
619
|
+
},
|
620
|
+
|
621
|
+
/**
|
622
|
+
* Destroy the buttons.
|
623
|
+
*/
|
624
|
+
destroyExport: function () {
|
625
|
+
var i,
|
626
|
+
chart = this,
|
627
|
+
elem;
|
628
|
+
|
629
|
+
// Destroy the extra buttons added
|
630
|
+
for (i = 0; i < chart.exportSVGElements.length; i++) {
|
631
|
+
elem = chart.exportSVGElements[i];
|
632
|
+
// Destroy and null the svg/vml elements
|
633
|
+
elem.onclick = elem.ontouchstart = null;
|
634
|
+
chart.exportSVGElements[i] = elem.destroy();
|
635
|
+
}
|
636
|
+
|
637
|
+
// Destroy the divs for the menu
|
638
|
+
for (i = 0; i < chart.exportDivElements.length; i++) {
|
639
|
+
elem = chart.exportDivElements[i];
|
640
|
+
|
641
|
+
// Remove the event handler
|
642
|
+
removeEvent(elem, 'mouseleave');
|
643
|
+
|
644
|
+
// Remove inline events
|
645
|
+
chart.exportDivElements[i] = elem.onmouseout = elem.onmouseover = elem.ontouchstart = elem.onclick = null;
|
646
|
+
|
647
|
+
// Destroy the div by moving to garbage bin
|
648
|
+
discardElement(elem);
|
649
|
+
}
|
650
|
+
}
|
651
|
+
});
|
652
|
+
|
653
|
+
/**
|
654
|
+
* Crisp for 1px stroke width, which is default. In the future, consider a smarter,
|
655
|
+
* global function.
|
656
|
+
*/
|
657
|
+
function crisp(arr) {
|
658
|
+
var i = arr.length;
|
659
|
+
while (i--) {
|
660
|
+
if (typeof arr[i] === 'number') {
|
661
|
+
arr[i] = Math.round(arr[i]) - 0.5;
|
662
|
+
}
|
663
|
+
}
|
664
|
+
return arr;
|
665
|
+
}
|
666
|
+
|
667
|
+
// Create the export icon
|
668
|
+
HC.Renderer.prototype.symbols.exportIcon = function (x, y, width, height) {
|
669
|
+
return crisp([
|
670
|
+
M, // the disk
|
671
|
+
x, y + width,
|
672
|
+
L,
|
673
|
+
x + width, y + height,
|
674
|
+
x + width, y + height * 0.8,
|
675
|
+
x, y + height * 0.8,
|
676
|
+
'Z',
|
677
|
+
M, // the arrow
|
678
|
+
x + width * 0.5, y + height * 0.8,
|
679
|
+
L,
|
680
|
+
x + width * 0.8, y + height * 0.4,
|
681
|
+
x + width * 0.4, y + height * 0.4,
|
682
|
+
x + width * 0.4, y,
|
683
|
+
x + width * 0.6, y,
|
684
|
+
x + width * 0.6, y + height * 0.4,
|
685
|
+
x + width * 0.2, y + height * 0.4,
|
686
|
+
'Z'
|
687
|
+
]);
|
688
|
+
};
|
689
|
+
// Create the print icon
|
690
|
+
HC.Renderer.prototype.symbols.printIcon = function (x, y, width, height) {
|
691
|
+
return crisp([
|
692
|
+
M, // the printer
|
693
|
+
x, y + height * 0.7,
|
694
|
+
L,
|
695
|
+
x + width, y + height * 0.7,
|
696
|
+
x + width, y + height * 0.4,
|
697
|
+
x, y + height * 0.4,
|
698
|
+
'Z',
|
699
|
+
M, // the upper sheet
|
700
|
+
x + width * 0.2, y + height * 0.4,
|
701
|
+
L,
|
702
|
+
x + width * 0.2, y,
|
703
|
+
x + width * 0.8, y,
|
704
|
+
x + width * 0.8, y + height * 0.4,
|
705
|
+
'Z',
|
706
|
+
M, // the lower sheet
|
707
|
+
x + width * 0.2, y + height * 0.7,
|
708
|
+
L,
|
709
|
+
x, y + height,
|
710
|
+
x + width, y + height,
|
711
|
+
x + width * 0.8, y + height * 0.7,
|
712
|
+
'Z'
|
713
|
+
]);
|
714
|
+
};
|
715
|
+
|
716
|
+
|
717
|
+
// Add the buttons on chart load
|
718
|
+
Chart.prototype.callbacks.push(function (chart) {
|
719
|
+
var n,
|
720
|
+
exportingOptions = chart.options.exporting,
|
721
|
+
buttons = exportingOptions.buttons;
|
722
|
+
|
723
|
+
if (exportingOptions.enabled !== false) {
|
724
|
+
|
725
|
+
for (n in buttons) {
|
726
|
+
chart.addButton(buttons[n]);
|
727
|
+
}
|
728
|
+
|
729
|
+
// Destroy the export elements at chart destroy
|
730
|
+
addEvent(chart, 'destroy', chart.destroyExport);
|
731
|
+
}
|
732
|
+
|
733
|
+
});
|
734
|
+
|
735
|
+
|
736
|
+
}());
|