highcharts-rails 4.2.7 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +34 -0
- data/Gemfile +4 -0
- data/Rakefile +53 -32
- data/app/assets/javascripts/highcharts.js +18775 -17176
- data/app/assets/javascripts/highcharts/highcharts-3d.js +1849 -1563
- data/app/assets/javascripts/highcharts/highcharts-more.js +2162 -1988
- data/app/assets/javascripts/highcharts/modules/accessibility.js +1005 -0
- data/app/assets/javascripts/highcharts/modules/annotations.js +408 -401
- data/app/assets/javascripts/highcharts/modules/boost.js +561 -546
- data/app/assets/javascripts/highcharts/modules/broken-axis.js +330 -324
- data/app/assets/javascripts/highcharts/modules/data.js +973 -965
- data/app/assets/javascripts/highcharts/modules/drilldown.js +783 -723
- data/app/assets/javascripts/highcharts/modules/exporting.js +864 -785
- data/app/assets/javascripts/highcharts/modules/funnel.js +290 -306
- data/app/assets/javascripts/highcharts/modules/heatmap.js +701 -645
- data/app/assets/javascripts/highcharts/modules/no-data-to-display.js +150 -132
- data/app/assets/javascripts/highcharts/modules/offline-exporting.js +414 -355
- data/app/assets/javascripts/highcharts/modules/overlapping-datalabels.js +164 -0
- data/app/assets/javascripts/highcharts/modules/series-label.js +473 -448
- data/app/assets/javascripts/highcharts/modules/solid-gauge.js +279 -271
- data/app/assets/javascripts/highcharts/modules/treemap.js +921 -886
- data/app/assets/javascripts/highcharts/themes/dark-blue.js +307 -244
- data/app/assets/javascripts/highcharts/themes/dark-green.js +303 -244
- data/app/assets/javascripts/highcharts/themes/dark-unica.js +231 -201
- data/app/assets/javascripts/highcharts/themes/gray.js +314 -245
- data/app/assets/javascripts/highcharts/themes/grid-light.js +91 -66
- data/app/assets/javascripts/highcharts/themes/grid.js +124 -96
- data/app/assets/javascripts/highcharts/themes/sand-signika.js +119 -94
- data/app/assets/javascripts/highcharts/themes/skies.js +108 -85
- data/lib/highcharts/version.rb +1 -1
- metadata +13 -14
- data/app/assets/javascripts/highcharts/adapters/standalone-framework.js +0 -1
- data/app/assets/javascripts/highcharts/modules/canvas-tools.js +0 -3115
- data/app/assets/javascripts/highcharts/modules/map.js +0 -2117
@@ -1,798 +1,877 @@
|
|
1
1
|
/**
|
2
|
-
* @license Highcharts JS
|
2
|
+
* @license Highcharts JS v5.0.0 (2016-09-29)
|
3
3
|
* Exporting module
|
4
4
|
*
|
5
5
|
* (c) 2010-2016 Torstein Honsi
|
6
6
|
*
|
7
7
|
* License: www.highcharts.com/license
|
8
8
|
*/
|
9
|
-
|
10
|
-
/* eslint indent:0 */
|
11
|
-
(function (factory) {
|
9
|
+
(function(factory) {
|
12
10
|
if (typeof module === 'object' && module.exports) {
|
13
11
|
module.exports = factory;
|
14
12
|
} else {
|
15
13
|
factory(Highcharts);
|
16
14
|
}
|
17
|
-
}(function
|
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
|
-
|
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
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
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
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
15
|
+
}(function(Highcharts) {
|
16
|
+
(function(H) {
|
17
|
+
/**
|
18
|
+
* Exporting module
|
19
|
+
*
|
20
|
+
* (c) 2010-2016 Torstein Honsi
|
21
|
+
*
|
22
|
+
* License: www.highcharts.com/license
|
23
|
+
*/
|
24
|
+
|
25
|
+
/* eslint indent:0 */
|
26
|
+
'use strict';
|
27
|
+
|
28
|
+
// create shortcuts
|
29
|
+
var defaultOptions = H.defaultOptions,
|
30
|
+
doc = H.doc,
|
31
|
+
Chart = H.Chart,
|
32
|
+
addEvent = H.addEvent,
|
33
|
+
removeEvent = H.removeEvent,
|
34
|
+
fireEvent = H.fireEvent,
|
35
|
+
createElement = H.createElement,
|
36
|
+
discardElement = H.discardElement,
|
37
|
+
css = H.css,
|
38
|
+
merge = H.merge,
|
39
|
+
pick = H.pick,
|
40
|
+
each = H.each,
|
41
|
+
extend = H.extend,
|
42
|
+
splat = H.splat,
|
43
|
+
isTouchDevice = H.isTouchDevice,
|
44
|
+
win = H.win,
|
45
|
+
SVGRenderer = H.SVGRenderer;
|
46
|
+
|
47
|
+
var symbols = H.Renderer.prototype.symbols;
|
48
|
+
|
49
|
+
// Add language
|
50
|
+
extend(defaultOptions.lang, {
|
51
|
+
printChart: 'Print chart',
|
52
|
+
downloadPNG: 'Download PNG image',
|
53
|
+
downloadJPEG: 'Download JPEG image',
|
54
|
+
downloadPDF: 'Download PDF document',
|
55
|
+
downloadSVG: 'Download SVG vector image',
|
56
|
+
contextButtonTitle: 'Chart context menu'
|
57
|
+
});
|
58
|
+
|
59
|
+
// Buttons and menus are collected in a separate config option set called 'navigation'.
|
60
|
+
// This can be extended later to add control buttons like zoom and pan right click menus.
|
61
|
+
defaultOptions.navigation = {
|
62
|
+
buttonOptions: {
|
63
|
+
theme: {},
|
64
|
+
symbolSize: 14,
|
65
|
+
symbolX: 12.5,
|
66
|
+
symbolY: 10.5,
|
67
|
+
align: 'right',
|
68
|
+
buttonSpacing: 3,
|
69
|
+
height: 22,
|
70
|
+
// text: null,
|
71
|
+
verticalAlign: 'top',
|
72
|
+
width: 24
|
73
|
+
}
|
74
|
+
};
|
75
|
+
|
76
|
+
|
77
|
+
// Presentational attributes
|
78
|
+
merge(true, defaultOptions.navigation, {
|
79
|
+
menuStyle: {
|
80
|
+
border: '1px solid #999999',
|
81
|
+
background: '#ffffff',
|
82
|
+
padding: '5px 0'
|
83
|
+
},
|
84
|
+
menuItemStyle: {
|
85
|
+
padding: '0.5em 1em',
|
86
|
+
background: 'none',
|
87
|
+
color: '#333333',
|
88
|
+
fontSize: isTouchDevice ? '14px' : '11px',
|
89
|
+
transition: 'background 250ms, color 250ms'
|
90
|
+
},
|
91
|
+
menuItemHoverStyle: {
|
92
|
+
background: '#335cad',
|
93
|
+
color: '#ffffff'
|
94
|
+
},
|
95
|
+
buttonOptions: {
|
96
|
+
symbolFill: '#666666',
|
97
|
+
symbolStroke: '#666666',
|
98
|
+
symbolStrokeWidth: 3,
|
99
|
+
theme: {
|
100
|
+
fill: '#ffffff', // capture hover
|
101
|
+
stroke: 'none',
|
102
|
+
padding: 5
|
103
|
+
}
|
104
|
+
}
|
105
|
+
});
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
// Add the export related options
|
110
|
+
defaultOptions.exporting = {
|
111
|
+
//enabled: true,
|
112
|
+
//filename: 'chart',
|
113
|
+
type: 'image/png',
|
114
|
+
url: 'https://export.highcharts.com/',
|
115
|
+
//width: undefined,
|
116
|
+
printMaxWidth: 780,
|
117
|
+
scale: 2,
|
118
|
+
buttons: {
|
119
|
+
contextButton: {
|
120
|
+
className: 'highcharts-contextbutton',
|
121
|
+
menuClassName: 'highcharts-contextmenu',
|
122
|
+
//x: -10,
|
123
|
+
symbol: 'menu',
|
124
|
+
_titleKey: 'contextButtonTitle',
|
125
|
+
menuItems: [{
|
126
|
+
textKey: 'printChart',
|
127
|
+
onclick: function() {
|
128
|
+
this.print();
|
129
|
+
}
|
130
|
+
}, {
|
131
|
+
separator: true
|
132
|
+
}, {
|
133
|
+
textKey: 'downloadPNG',
|
134
|
+
onclick: function() {
|
135
|
+
this.exportChart();
|
136
|
+
}
|
137
|
+
}, {
|
138
|
+
textKey: 'downloadJPEG',
|
139
|
+
onclick: function() {
|
140
|
+
this.exportChart({
|
141
|
+
type: 'image/jpeg'
|
142
|
+
});
|
143
|
+
}
|
144
|
+
}, {
|
145
|
+
textKey: 'downloadPDF',
|
146
|
+
onclick: function() {
|
147
|
+
this.exportChart({
|
148
|
+
type: 'application/pdf'
|
149
|
+
});
|
150
|
+
}
|
151
|
+
}, {
|
152
|
+
textKey: 'downloadSVG',
|
153
|
+
onclick: function() {
|
154
|
+
this.exportChart({
|
155
|
+
type: 'image/svg+xml'
|
156
|
+
});
|
157
|
+
}
|
158
|
+
}
|
159
|
+
// Enable this block to add "View SVG" to the dropdown menu
|
160
|
+
/*
|
161
|
+
,{
|
162
|
+
|
163
|
+
text: 'View SVG',
|
164
|
+
onclick: function () {
|
165
|
+
var svg = this.getSVG()
|
166
|
+
.replace(/</g, '\n<')
|
167
|
+
.replace(/>/g, '>');
|
168
|
+
|
169
|
+
doc.body.innerHTML = '<pre>' + svg + '</pre>';
|
170
|
+
}
|
171
|
+
} // */
|
172
|
+
]
|
173
|
+
}
|
174
|
+
}
|
175
|
+
};
|
176
|
+
|
177
|
+
// Add the H.post utility
|
178
|
+
H.post = function(url, data, formAttributes) {
|
179
|
+
var name,
|
180
|
+
form;
|
181
|
+
|
182
|
+
// create the form
|
183
|
+
form = createElement('form', merge({
|
184
|
+
method: 'post',
|
185
|
+
action: url,
|
186
|
+
enctype: 'multipart/form-data'
|
187
|
+
}, formAttributes), {
|
188
|
+
display: 'none'
|
189
|
+
}, doc.body);
|
190
|
+
|
191
|
+
// add the data
|
192
|
+
for (name in data) {
|
193
|
+
createElement('input', {
|
194
|
+
type: 'hidden',
|
195
|
+
name: name,
|
196
|
+
value: data[name]
|
197
|
+
}, null, form);
|
198
|
+
}
|
199
|
+
|
200
|
+
// submit
|
201
|
+
form.submit();
|
202
|
+
|
203
|
+
// clean up
|
204
|
+
discardElement(form);
|
205
|
+
};
|
206
|
+
|
207
|
+
extend(Chart.prototype, {
|
208
|
+
|
209
|
+
/**
|
210
|
+
* A collection of regex fixes on the produces SVG to account for expando properties,
|
211
|
+
* browser bugs, VML problems and other. Returns a cleaned SVG.
|
212
|
+
*/
|
213
|
+
sanitizeSVG: function(svg) {
|
214
|
+
svg = svg
|
215
|
+
.replace(/zIndex="[^"]+"/g, '')
|
216
|
+
.replace(/isShadow="[^"]+"/g, '')
|
217
|
+
.replace(/symbolName="[^"]+"/g, '')
|
218
|
+
.replace(/jQuery[0-9]+="[^"]+"/g, '')
|
219
|
+
.replace(/url\(("|")(\S+)("|")\)/g, 'url($2)')
|
220
|
+
.replace(/url\([^#]+#/g, 'url(#')
|
221
|
+
.replace(/<svg /, '<svg xmlns:xlink="http://www.w3.org/1999/xlink" ')
|
222
|
+
.replace(/ (NS[0-9]+\:)?href=/g, ' xlink:href=') // #3567
|
223
|
+
.replace(/\n/, ' ')
|
224
|
+
// Any HTML added to the container after the SVG (#894)
|
225
|
+
.replace(/<\/svg>.*?$/, '</svg>')
|
226
|
+
// Batik doesn't support rgba fills and strokes (#3095)
|
227
|
+
.replace(/(fill|stroke)="rgba\(([ 0-9]+,[ 0-9]+,[ 0-9]+),([ 0-9\.]+)\)"/g, '$1="rgb($2)" $1-opacity="$3"')
|
228
|
+
/* This fails in IE < 8
|
229
|
+
.replace(/([0-9]+)\.([0-9]+)/g, function(s1, s2, s3) { // round off to save weight
|
230
|
+
return s2 +'.'+ s3[0];
|
231
|
+
})*/
|
232
|
+
|
233
|
+
// Replace HTML entities, issue #347
|
234
|
+
.replace(/ /g, '\u00A0') // no-break space
|
235
|
+
.replace(/­/g, '\u00AD'); // soft hyphen
|
236
|
+
|
237
|
+
|
238
|
+
// IE specific
|
239
|
+
svg = svg
|
240
|
+
.replace(/<IMG /g, '<image ')
|
241
|
+
.replace(/<(\/?)TITLE>/g, '<$1title>')
|
242
|
+
.replace(/height=([^" ]+)/g, 'height="$1"')
|
243
|
+
.replace(/width=([^" ]+)/g, 'width="$1"')
|
244
|
+
.replace(/hc-svg-href="([^"]+)">/g, 'xlink:href="$1"/>')
|
245
|
+
.replace(/ id=([^" >]+)/g, ' id="$1"') // #4003
|
246
|
+
.replace(/class=([^" >]+)/g, 'class="$1"')
|
247
|
+
.replace(/ transform /g, ' ')
|
248
|
+
.replace(/:(path|rect)/g, '$1')
|
249
|
+
.replace(/style="([^"]+)"/g, function(s) {
|
250
|
+
return s.toLowerCase();
|
251
|
+
});
|
252
|
+
|
253
|
+
|
254
|
+
return svg;
|
255
|
+
},
|
256
|
+
|
257
|
+
/**
|
258
|
+
* Return innerHTML of chart. Used as hook for plugins.
|
259
|
+
*/
|
260
|
+
getChartHTML: function() {
|
261
|
+
|
262
|
+
return this.container.innerHTML;
|
263
|
+
},
|
264
|
+
|
265
|
+
/**
|
266
|
+
* Return an SVG representation of the chart
|
267
|
+
*
|
268
|
+
* @param additionalOptions {Object} Additional chart options for the generated SVG representation
|
269
|
+
*/
|
270
|
+
getSVG: function(additionalOptions) {
|
271
|
+
var chart = this,
|
272
|
+
chartCopy,
|
273
|
+
sandbox,
|
274
|
+
svg,
|
275
|
+
seriesOptions,
|
276
|
+
sourceWidth,
|
277
|
+
sourceHeight,
|
278
|
+
cssWidth,
|
279
|
+
cssHeight,
|
280
|
+
html,
|
281
|
+
options = merge(chart.options, additionalOptions), // copy the options and add extra options
|
282
|
+
allowHTML = options.exporting.allowHTML;
|
283
|
+
|
284
|
+
|
285
|
+
// IE compatibility hack for generating SVG content that it doesn't really understand
|
286
|
+
if (!doc.createElementNS) {
|
287
|
+
doc.createElementNS = function(ns, tagName) {
|
288
|
+
return doc.createElement(tagName);
|
289
|
+
};
|
290
|
+
}
|
291
|
+
|
292
|
+
// create a sandbox where a new chart will be generated
|
293
|
+
sandbox = createElement('div', null, {
|
294
|
+
position: 'absolute',
|
295
|
+
top: '-9999em',
|
296
|
+
width: chart.chartWidth + 'px',
|
297
|
+
height: chart.chartHeight + 'px'
|
298
|
+
}, doc.body);
|
299
|
+
|
300
|
+
// get the source size
|
301
|
+
cssWidth = chart.renderTo.style.width;
|
302
|
+
cssHeight = chart.renderTo.style.height;
|
303
|
+
sourceWidth = options.exporting.sourceWidth ||
|
304
|
+
options.chart.width ||
|
305
|
+
(/px$/.test(cssWidth) && parseInt(cssWidth, 10)) ||
|
306
|
+
600;
|
307
|
+
sourceHeight = options.exporting.sourceHeight ||
|
308
|
+
options.chart.height ||
|
309
|
+
(/px$/.test(cssHeight) && parseInt(cssHeight, 10)) ||
|
310
|
+
400;
|
311
|
+
|
312
|
+
// override some options
|
313
|
+
extend(options.chart, {
|
314
|
+
animation: false,
|
315
|
+
renderTo: sandbox,
|
316
|
+
forExport: true,
|
317
|
+
renderer: 'SVGRenderer',
|
318
|
+
width: sourceWidth,
|
319
|
+
height: sourceHeight
|
320
|
+
});
|
321
|
+
options.exporting.enabled = false; // hide buttons in print
|
322
|
+
delete options.data; // #3004
|
323
|
+
|
324
|
+
// prepare for replicating the chart
|
325
|
+
options.series = [];
|
326
|
+
each(chart.series, function(serie) {
|
327
|
+
seriesOptions = merge(serie.userOptions, { // #4912
|
328
|
+
animation: false, // turn off animation
|
329
|
+
enableMouseTracking: false,
|
330
|
+
showCheckbox: false,
|
331
|
+
visible: serie.visible
|
332
|
+
});
|
333
|
+
|
334
|
+
if (!seriesOptions.isInternal) { // used for the navigator series that has its own option set
|
335
|
+
options.series.push(seriesOptions);
|
336
|
+
}
|
337
|
+
});
|
338
|
+
|
339
|
+
// Axis options must be merged in one by one, since it may be an array or an object (#2022, #3900)
|
340
|
+
if (additionalOptions) {
|
341
|
+
each(['xAxis', 'yAxis'], function(axisType) {
|
342
|
+
each(splat(additionalOptions[axisType]), function(axisOptions, i) {
|
343
|
+
options[axisType][i] = merge(options[axisType][i], axisOptions);
|
344
|
+
});
|
345
|
+
});
|
346
|
+
}
|
347
|
+
|
348
|
+
// generate the chart copy
|
349
|
+
chartCopy = new H.Chart(options, chart.callback);
|
350
|
+
|
351
|
+
// reflect axis extremes in the export
|
352
|
+
each(['xAxis', 'yAxis'], function(axisType) {
|
353
|
+
each(chart[axisType], function(axis, i) {
|
354
|
+
var axisCopy = chartCopy[axisType][i],
|
355
|
+
extremes = axis.getExtremes(),
|
356
|
+
userMin = extremes.userMin,
|
357
|
+
userMax = extremes.userMax;
|
358
|
+
|
359
|
+
if (axisCopy && (userMin !== undefined || userMax !== undefined)) {
|
360
|
+
axisCopy.setExtremes(userMin, userMax, true, false);
|
361
|
+
}
|
362
|
+
});
|
363
|
+
});
|
364
|
+
|
365
|
+
// get the SVG from the container's innerHTML
|
366
|
+
svg = chartCopy.getChartHTML();
|
367
|
+
|
368
|
+
// free up memory
|
369
|
+
options = null;
|
370
|
+
chartCopy.destroy();
|
371
|
+
discardElement(sandbox);
|
372
|
+
|
373
|
+
// Move HTML into a foreignObject
|
374
|
+
if (allowHTML) {
|
375
|
+
html = svg.match(/<\/svg>(.*?$)/);
|
376
|
+
if (html) {
|
377
|
+
html = '<foreignObject x="0" y="0" width="200" height="200">' +
|
378
|
+
'<body xmlns="http://www.w3.org/1999/xhtml">' +
|
379
|
+
html[1] +
|
380
|
+
'</body>' +
|
381
|
+
'</foreignObject>';
|
382
|
+
svg = svg.replace('</svg>', html + '</svg>');
|
383
|
+
}
|
384
|
+
}
|
385
|
+
|
386
|
+
// sanitize
|
387
|
+
svg = this.sanitizeSVG(svg);
|
388
|
+
|
389
|
+
// IE9 beta bugs with innerHTML. Test again with final IE9.
|
390
|
+
svg = svg.replace(/(url\(#highcharts-[0-9]+)"/g, '$1')
|
391
|
+
.replace(/"/g, '\'');
|
392
|
+
|
393
|
+
return svg;
|
394
|
+
},
|
395
|
+
|
396
|
+
getSVGForExport: function(options, chartOptions) {
|
397
|
+
var chartExportingOptions = this.options.exporting;
|
398
|
+
|
399
|
+
return this.getSVG(merge({
|
400
|
+
chart: {
|
401
|
+
borderRadius: 0
|
402
|
+
}
|
403
|
+
},
|
404
|
+
chartExportingOptions.chartOptions,
|
405
|
+
chartOptions, {
|
406
|
+
exporting: {
|
407
|
+
sourceWidth: (options && options.sourceWidth) || chartExportingOptions.sourceWidth,
|
408
|
+
sourceHeight: (options && options.sourceHeight) || chartExportingOptions.sourceHeight
|
409
|
+
}
|
410
|
+
}
|
411
|
+
));
|
412
|
+
},
|
413
|
+
|
414
|
+
/**
|
415
|
+
* Submit the SVG representation of the chart to the server
|
416
|
+
* @param {Object} options Exporting options. Possible members are url, type, width and formAttributes.
|
417
|
+
* @param {Object} chartOptions Additional chart options for the SVG representation of the chart
|
418
|
+
*/
|
419
|
+
exportChart: function(options, chartOptions) {
|
420
|
+
|
421
|
+
var svg = this.getSVGForExport(options, chartOptions);
|
422
|
+
|
423
|
+
// merge the options
|
424
|
+
options = merge(this.options.exporting, options);
|
425
|
+
|
426
|
+
// do the post
|
427
|
+
H.post(options.url, {
|
428
|
+
filename: options.filename || 'chart',
|
429
|
+
type: options.type,
|
430
|
+
width: options.width || 0, // IE8 fails to post undefined correctly, so use 0
|
431
|
+
scale: options.scale,
|
432
|
+
svg: svg
|
433
|
+
}, options.formAttributes);
|
434
|
+
|
435
|
+
},
|
436
|
+
|
437
|
+
/**
|
438
|
+
* Print the chart
|
439
|
+
*/
|
440
|
+
print: function() {
|
441
|
+
|
442
|
+
var chart = this,
|
443
|
+
container = chart.container,
|
444
|
+
origDisplay = [],
|
445
|
+
origParent = container.parentNode,
|
446
|
+
body = doc.body,
|
447
|
+
childNodes = body.childNodes,
|
448
|
+
printMaxWidth = chart.options.exporting.printMaxWidth,
|
449
|
+
resetParams,
|
450
|
+
handleMaxWidth;
|
451
|
+
|
452
|
+
if (chart.isPrinting) { // block the button while in printing mode
|
453
|
+
return;
|
454
|
+
}
|
455
|
+
|
456
|
+
chart.isPrinting = true;
|
457
|
+
chart.pointer.reset(null, 0);
|
458
|
+
|
459
|
+
fireEvent(chart, 'beforePrint');
|
460
|
+
|
461
|
+
// Handle printMaxWidth
|
462
|
+
handleMaxWidth = printMaxWidth && chart.chartWidth > printMaxWidth;
|
463
|
+
if (handleMaxWidth) {
|
464
|
+
resetParams = [chart.options.chart.width, undefined, false];
|
465
|
+
chart.setSize(printMaxWidth, undefined, false);
|
466
|
+
}
|
467
|
+
|
468
|
+
// hide all body content
|
469
|
+
each(childNodes, function(node, i) {
|
470
|
+
if (node.nodeType === 1) {
|
471
|
+
origDisplay[i] = node.style.display;
|
472
|
+
node.style.display = 'none';
|
473
|
+
}
|
474
|
+
});
|
475
|
+
|
476
|
+
// pull out the chart
|
477
|
+
body.appendChild(container);
|
478
|
+
|
479
|
+
// print
|
480
|
+
win.focus(); // #1510
|
481
|
+
win.print();
|
482
|
+
|
483
|
+
// allow the browser to prepare before reverting
|
484
|
+
setTimeout(function() {
|
485
|
+
|
486
|
+
// put the chart back in
|
487
|
+
origParent.appendChild(container);
|
488
|
+
|
489
|
+
// restore all body content
|
490
|
+
each(childNodes, function(node, i) {
|
491
|
+
if (node.nodeType === 1) {
|
492
|
+
node.style.display = origDisplay[i];
|
493
|
+
}
|
494
|
+
});
|
495
|
+
|
496
|
+
chart.isPrinting = false;
|
497
|
+
|
498
|
+
// Reset printMaxWidth
|
499
|
+
if (handleMaxWidth) {
|
500
|
+
chart.setSize.apply(chart, resetParams);
|
501
|
+
}
|
502
|
+
|
503
|
+
fireEvent(chart, 'afterPrint');
|
504
|
+
|
505
|
+
}, 1000);
|
506
|
+
|
507
|
+
},
|
508
|
+
|
509
|
+
/**
|
510
|
+
* Display a popup menu for choosing the export type
|
511
|
+
*
|
512
|
+
* @param {String} className An identifier for the menu
|
513
|
+
* @param {Array} items A collection with text and onclicks for the items
|
514
|
+
* @param {Number} x The x position of the opener button
|
515
|
+
* @param {Number} y The y position of the opener button
|
516
|
+
* @param {Number} width The width of the opener button
|
517
|
+
* @param {Number} height The height of the opener button
|
518
|
+
*/
|
519
|
+
contextMenu: function(className, items, x, y, width, height, button) {
|
520
|
+
var chart = this,
|
521
|
+
navOptions = chart.options.navigation,
|
522
|
+
chartWidth = chart.chartWidth,
|
523
|
+
chartHeight = chart.chartHeight,
|
524
|
+
cacheName = 'cache-' + className,
|
525
|
+
menu = chart[cacheName],
|
526
|
+
menuPadding = Math.max(width, height), // for mouse leave detection
|
527
|
+
innerMenu,
|
528
|
+
hide,
|
529
|
+
hideTimer,
|
530
|
+
menuStyle,
|
531
|
+
docMouseUpHandler = function(e) {
|
532
|
+
if (!chart.pointer.inClass(e.target, className)) {
|
533
|
+
hide();
|
534
|
+
}
|
535
|
+
};
|
536
|
+
|
537
|
+
// create the menu only the first time
|
538
|
+
if (!menu) {
|
539
|
+
|
540
|
+
// create a HTML element above the SVG
|
541
|
+
chart[cacheName] = menu = createElement('div', {
|
542
|
+
className: className
|
543
|
+
}, {
|
544
|
+
position: 'absolute',
|
545
|
+
zIndex: 1000,
|
546
|
+
padding: menuPadding + 'px'
|
547
|
+
}, chart.container);
|
548
|
+
|
549
|
+
innerMenu = createElement('div', {
|
550
|
+
className: 'highcharts-menu'
|
551
|
+
}, null, menu);
|
552
|
+
|
553
|
+
|
554
|
+
// Presentational CSS
|
555
|
+
css(innerMenu, extend({
|
556
|
+
MozBoxShadow: '3px 3px 10px #888',
|
557
|
+
WebkitBoxShadow: '3px 3px 10px #888',
|
558
|
+
boxShadow: '3px 3px 10px #888'
|
559
|
+
}, navOptions.menuStyle));
|
560
|
+
|
561
|
+
|
562
|
+
// hide on mouse out
|
563
|
+
hide = function() {
|
564
|
+
css(menu, {
|
565
|
+
display: 'none'
|
566
|
+
});
|
567
|
+
if (button) {
|
568
|
+
button.setState(0);
|
569
|
+
}
|
570
|
+
chart.openMenu = false;
|
571
|
+
};
|
572
|
+
|
573
|
+
// Hide the menu some time after mouse leave (#1357)
|
574
|
+
addEvent(menu, 'mouseleave', function() {
|
575
|
+
hideTimer = setTimeout(hide, 500);
|
576
|
+
});
|
577
|
+
addEvent(menu, 'mouseenter', function() {
|
578
|
+
clearTimeout(hideTimer);
|
579
|
+
});
|
580
|
+
|
581
|
+
|
582
|
+
// Hide it on clicking or touching outside the menu (#2258, #2335, #2407)
|
583
|
+
addEvent(doc, 'mouseup', docMouseUpHandler);
|
584
|
+
addEvent(chart, 'destroy', function() {
|
585
|
+
removeEvent(doc, 'mouseup', docMouseUpHandler);
|
586
|
+
});
|
587
|
+
|
588
|
+
|
589
|
+
// create the items
|
590
|
+
each(items, function(item) {
|
591
|
+
if (item) {
|
592
|
+
var element;
|
593
|
+
|
594
|
+
if (item.separator) {
|
595
|
+
element = createElement('hr', null, null, innerMenu);
|
596
|
+
|
597
|
+
} else {
|
598
|
+
element = createElement('div', {
|
599
|
+
className: 'highcharts-menu-item',
|
600
|
+
onclick: function(e) {
|
601
|
+
if (e) { // IE7
|
602
|
+
e.stopPropagation();
|
603
|
+
}
|
604
|
+
hide();
|
605
|
+
if (item.onclick) {
|
606
|
+
item.onclick.apply(chart, arguments);
|
607
|
+
}
|
608
|
+
},
|
609
|
+
innerHTML: item.text || chart.options.lang[item.textKey]
|
610
|
+
}, null, innerMenu);
|
611
|
+
|
612
|
+
|
613
|
+
element.onmouseover = function() {
|
614
|
+
css(this, navOptions.menuItemHoverStyle);
|
615
|
+
};
|
616
|
+
element.onmouseout = function() {
|
617
|
+
css(this, navOptions.menuItemStyle);
|
618
|
+
};
|
619
|
+
css(element, extend({
|
620
|
+
cursor: 'pointer'
|
621
|
+
}, navOptions.menuItemStyle));
|
622
|
+
|
623
|
+
}
|
624
|
+
|
625
|
+
// Keep references to menu divs to be able to destroy them
|
626
|
+
chart.exportDivElements.push(element);
|
627
|
+
}
|
628
|
+
});
|
629
|
+
|
630
|
+
// Keep references to menu and innerMenu div to be able to destroy them
|
631
|
+
chart.exportDivElements.push(innerMenu, menu);
|
632
|
+
|
633
|
+
chart.exportMenuWidth = menu.offsetWidth;
|
634
|
+
chart.exportMenuHeight = menu.offsetHeight;
|
635
|
+
}
|
636
|
+
|
637
|
+
menuStyle = {
|
638
|
+
display: 'block'
|
639
|
+
};
|
640
|
+
|
641
|
+
// if outside right, right align it
|
642
|
+
if (x + chart.exportMenuWidth > chartWidth) {
|
643
|
+
menuStyle.right = (chartWidth - x - width - menuPadding) + 'px';
|
644
|
+
} else {
|
645
|
+
menuStyle.left = (x - menuPadding) + 'px';
|
646
|
+
}
|
647
|
+
// if outside bottom, bottom align it
|
648
|
+
if (y + height + chart.exportMenuHeight > chartHeight && button.alignOptions.verticalAlign !== 'top') {
|
649
|
+
menuStyle.bottom = (chartHeight - y - menuPadding) + 'px';
|
650
|
+
} else {
|
651
|
+
menuStyle.top = (y + height - menuPadding) + 'px';
|
652
|
+
}
|
653
|
+
|
654
|
+
css(menu, menuStyle);
|
655
|
+
chart.openMenu = true;
|
656
|
+
},
|
657
|
+
|
658
|
+
/**
|
659
|
+
* Add the export button to the chart
|
660
|
+
*/
|
661
|
+
addButton: function(options) {
|
662
|
+
var chart = this,
|
663
|
+
renderer = chart.renderer,
|
664
|
+
btnOptions = merge(chart.options.navigation.buttonOptions, options),
|
665
|
+
onclick = btnOptions.onclick,
|
666
|
+
menuItems = btnOptions.menuItems,
|
667
|
+
symbol,
|
668
|
+
button,
|
669
|
+
symbolSize = btnOptions.symbolSize || 12;
|
670
|
+
if (!chart.btnCount) {
|
671
|
+
chart.btnCount = 0;
|
672
|
+
}
|
673
|
+
|
674
|
+
// Keeps references to the button elements
|
675
|
+
if (!chart.exportDivElements) {
|
676
|
+
chart.exportDivElements = [];
|
677
|
+
chart.exportSVGElements = [];
|
678
|
+
}
|
679
|
+
|
680
|
+
if (btnOptions.enabled === false) {
|
681
|
+
return;
|
682
|
+
}
|
683
|
+
|
684
|
+
|
685
|
+
var attr = btnOptions.theme,
|
686
|
+
states = attr.states,
|
687
|
+
hover = states && states.hover,
|
688
|
+
select = states && states.select,
|
689
|
+
callback;
|
690
|
+
|
691
|
+
delete attr.states;
|
692
|
+
|
693
|
+
if (onclick) {
|
694
|
+
callback = function(e) {
|
695
|
+
e.stopPropagation();
|
696
|
+
onclick.call(chart, e);
|
697
|
+
};
|
698
|
+
|
699
|
+
} else if (menuItems) {
|
700
|
+
callback = function() {
|
701
|
+
chart.contextMenu(
|
702
|
+
button.menuClassName,
|
703
|
+
menuItems,
|
704
|
+
button.translateX,
|
705
|
+
button.translateY,
|
706
|
+
button.width,
|
707
|
+
button.height,
|
708
|
+
button
|
709
|
+
);
|
710
|
+
button.setState(2);
|
711
|
+
};
|
712
|
+
}
|
713
|
+
|
714
|
+
|
715
|
+
if (btnOptions.text && btnOptions.symbol) {
|
716
|
+
attr.paddingLeft = pick(attr.paddingLeft, 25);
|
717
|
+
|
718
|
+
} else if (!btnOptions.text) {
|
719
|
+
extend(attr, {
|
720
|
+
width: btnOptions.width,
|
721
|
+
height: btnOptions.height,
|
722
|
+
padding: 0
|
723
|
+
});
|
724
|
+
}
|
725
|
+
|
726
|
+
button = renderer.button(btnOptions.text, 0, 0, callback, attr, hover, select)
|
727
|
+
.addClass(options.className)
|
728
|
+
.attr({
|
729
|
+
|
730
|
+
'stroke-linecap': 'round',
|
731
|
+
|
732
|
+
title: chart.options.lang[btnOptions._titleKey],
|
733
|
+
zIndex: 3 // #4955
|
734
|
+
});
|
735
|
+
button.menuClassName = options.menuClassName || 'highcharts-menu-' + chart.btnCount++;
|
736
|
+
|
737
|
+
if (btnOptions.symbol) {
|
738
|
+
symbol = renderer.symbol(
|
739
|
+
btnOptions.symbol,
|
740
|
+
btnOptions.symbolX - (symbolSize / 2),
|
741
|
+
btnOptions.symbolY - (symbolSize / 2),
|
742
|
+
symbolSize,
|
743
|
+
symbolSize
|
744
|
+
)
|
745
|
+
.addClass('highcharts-button-symbol')
|
746
|
+
.attr({
|
747
|
+
zIndex: 1
|
748
|
+
}).add(button);
|
749
|
+
|
750
|
+
|
751
|
+
symbol.attr({
|
752
|
+
stroke: btnOptions.symbolStroke,
|
753
|
+
fill: btnOptions.symbolFill,
|
754
|
+
'stroke-width': btnOptions.symbolStrokeWidth || 1
|
755
|
+
});
|
756
|
+
|
757
|
+
}
|
758
|
+
|
759
|
+
button.add()
|
760
|
+
.align(extend(btnOptions, {
|
761
|
+
width: button.width,
|
762
|
+
x: pick(btnOptions.x, chart.buttonOffset) // #1654
|
763
|
+
}), true, 'spacingBox');
|
764
|
+
|
765
|
+
chart.buttonOffset += (button.width + btnOptions.buttonSpacing) * (btnOptions.align === 'right' ? -1 : 1);
|
766
|
+
|
767
|
+
chart.exportSVGElements.push(button, symbol);
|
768
|
+
|
769
|
+
},
|
770
|
+
|
771
|
+
/**
|
772
|
+
* Destroy the buttons.
|
773
|
+
*/
|
774
|
+
destroyExport: function(e) {
|
775
|
+
var chart = e ? e.target : this,
|
776
|
+
exportSVGElements = chart.exportSVGElements,
|
777
|
+
exportDivElements = chart.exportDivElements;
|
778
|
+
|
779
|
+
// Destroy the extra buttons added
|
780
|
+
if (exportSVGElements) {
|
781
|
+
each(exportSVGElements, function(elem, i) {
|
782
|
+
|
783
|
+
// Destroy and null the svg/vml elements
|
784
|
+
if (elem) { // #1822
|
785
|
+
elem.onclick = elem.ontouchstart = null;
|
786
|
+
chart.exportSVGElements[i] = elem.destroy();
|
787
|
+
}
|
788
|
+
});
|
789
|
+
exportSVGElements.length = 0;
|
790
|
+
}
|
791
|
+
|
792
|
+
// Destroy the divs for the menu
|
793
|
+
if (exportDivElements) {
|
794
|
+
each(exportDivElements, function(elem, i) {
|
795
|
+
|
796
|
+
// Remove the event handler
|
797
|
+
removeEvent(elem, 'mouseleave');
|
798
|
+
|
799
|
+
// Remove inline events
|
800
|
+
chart.exportDivElements[i] = elem.onmouseout = elem.onmouseover = elem.ontouchstart = elem.onclick = null;
|
801
|
+
|
802
|
+
// Destroy the div by moving to garbage bin
|
803
|
+
discardElement(elem);
|
804
|
+
});
|
805
|
+
exportDivElements.length = 0;
|
806
|
+
}
|
807
|
+
}
|
808
|
+
});
|
809
|
+
|
810
|
+
|
811
|
+
|
812
|
+
|
813
|
+
symbols.menu = function(x, y, width, height) {
|
814
|
+
var arr = [
|
815
|
+
'M', x, y + 2.5,
|
816
|
+
'L', x + width, y + 2.5,
|
817
|
+
'M', x, y + height / 2 + 0.5,
|
818
|
+
'L', x + width, y + height / 2 + 0.5,
|
819
|
+
'M', x, y + height - 1.5,
|
820
|
+
'L', x + width, y + height - 1.5
|
821
|
+
];
|
822
|
+
return arr;
|
823
|
+
};
|
824
|
+
|
825
|
+
// Add the buttons on chart load
|
826
|
+
Chart.prototype.renderExporting = function() {
|
827
|
+
var n,
|
828
|
+
exportingOptions = this.options.exporting,
|
829
|
+
buttons = exportingOptions.buttons,
|
830
|
+
isDirty = this.isDirtyExporting || !this.exportSVGElements;
|
831
|
+
|
832
|
+
this.buttonOffset = 0;
|
833
|
+
if (this.isDirtyExporting) {
|
834
|
+
this.destroyExport();
|
835
|
+
}
|
836
|
+
|
837
|
+
if (isDirty && exportingOptions.enabled !== false) {
|
838
|
+
|
839
|
+
for (n in buttons) {
|
840
|
+
this.addButton(buttons[n]);
|
841
|
+
}
|
842
|
+
|
843
|
+
this.isDirtyExporting = false;
|
844
|
+
}
|
845
|
+
|
846
|
+
// Destroy the export elements at chart destroy
|
847
|
+
addEvent(this, 'destroy', this.destroyExport);
|
848
|
+
};
|
849
|
+
|
850
|
+
Chart.prototype.callbacks.push(function(chart) {
|
851
|
+
|
852
|
+
function update(prop, options, redraw) {
|
853
|
+
chart.isDirtyExporting = true;
|
854
|
+
merge(true, chart.options[prop], options);
|
855
|
+
if (pick(redraw, true)) {
|
856
|
+
chart.redraw();
|
857
|
+
}
|
858
|
+
|
859
|
+
}
|
860
|
+
|
861
|
+
chart.renderExporting();
|
862
|
+
|
863
|
+
addEvent(chart, 'redraw', chart.renderExporting);
|
864
|
+
|
865
|
+
// Add update methods to handle chart.update and chart.exporting.update
|
866
|
+
// and chart.navigation.update.
|
867
|
+
each(['exporting', 'navigation'], function(prop) {
|
868
|
+
chart[prop] = {
|
869
|
+
update: function(options, redraw) {
|
870
|
+
update(prop, options, redraw);
|
871
|
+
}
|
872
|
+
};
|
873
|
+
});
|
874
|
+
});
|
875
|
+
|
876
|
+
}(Highcharts));
|
798
877
|
}));
|