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
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
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
|
/**
* o------------------------------------------------------------------------------o
* | This file is part of the RGraph package - you can learn more at: |
* | |
* | http://www.rgraph.net |
* | |
* | This package is licensed under the RGraph license. For all kinds of business |
* | purposes there is a small one-time licensing fee to pay and for non |
* | commercial purposes it is free to use. You can read the full license here: |
* | |
* | http://www.rgraph.net/LICENSE.txt |
* o------------------------------------------------------------------------------o
*/
if (typeof(RGraph) == 'undefined') RGraph = {isRGraph:true,type:'common'};
/**
* This is used in two functions, hence it's here
*/
RGraph.tooltips = {};
RGraph.tooltips.padding = '3px';
RGraph.tooltips.font_face = 'Tahoma';
RGraph.tooltips.font_size = '10pt';
/**
* Shows a tooltip next to the mouse pointer
*
* @param canvas object The canvas element object
* @param text string The tooltip text
* @param int x The X position that the tooltip should appear at. Combined with the canvases offsetLeft
* gives the absolute X position
* @param int y The Y position the tooltip should appear at. Combined with the canvases offsetTop
* gives the absolute Y position
* @param int idx The index of the tooltip in the graph objects tooltip array
*/
RGraph.Tooltip = function (canvas, text, x, y, idx)
{
/**
* chart.tooltip.override allows you to totally take control of rendering the tooltip yourself
*/
if (typeof(canvas.__object__.Get('chart.tooltips.override')) == 'function') {
return canvas.__object__.Get('chart.tooltips.override')(canvas, text, x, y, idx);
}
/**
* This facilitates the "id:xxx" format
*/
text = RGraph.getTooltipTextFromDIV(text);
/**
* First clear any exising timers
*/
var timers = RGraph.Registry.Get('chart.tooltip.timers');
if (timers && timers.length) {
for (i=0; i<timers.length; ++i) {
clearTimeout(timers[i]);
}
}
RGraph.Registry.Set('chart.tooltip.timers', []);
/**
* Hide the context menu if it's currently shown
*/
if (canvas.__object__.Get('chart.contextmenu')) {
RGraph.HideContext();
}
// Redraw the canvas?
if (canvas.__object__.Get('chart.tooltips.highlight')) {
RGraph.Redraw(canvas.id);
}
var effect = canvas.__object__.Get('chart.tooltips.effect').toLowerCase();
if (effect == 'snap' && RGraph.Registry.Get('chart.tooltip') && RGraph.Registry.Get('chart.tooltip').__canvas__.id == canvas.id) {
if ( canvas.__object__.type == 'line'
|| canvas.__object__.type == 'radar'
|| canvas.__object__.type == 'scatter'
|| canvas.__object__.type == 'rscatter'
) {
var tooltipObj = RGraph.Registry.Get('chart.tooltip');
tooltipObj.style.width = null;
tooltipObj.style.height = null;
tooltipObj.innerHTML = text;
tooltipObj.__text__ = text;
/**
* Now that the new content has been set, re-set the width & height
*/
RGraph.Registry.Get('chart.tooltip').style.width = RGraph.getTooltipWidth(text, canvas.__object__) + 'px';
RGraph.Registry.Get('chart.tooltip').style.height = RGraph.Registry.Get('chart.tooltip').offsetHeight + 'px';
/**
* Now (25th September 2011) use jQuery if it's available
*/
if (typeof(jQuery) == 'function' && typeof($) == 'function') {
$('#' + tooltipObj.id).animate({
opacity: 1,
width: tooltipObj.offsetWidth + 'px',
height: tooltipObj.offsetHeight + 'px',
left: x + 'px',
top: (y - tooltipObj.offsetHeight) + 'px'
}, 150);
} else {
var currentx = parseInt(RGraph.Registry.Get('chart.tooltip').style.left);
var currenty = parseInt(RGraph.Registry.Get('chart.tooltip').style.top);
var diffx = x - currentx - ((x + RGraph.Registry.Get('chart.tooltip').offsetWidth) > document.body.offsetWidth ? RGraph.Registry.Get('chart.tooltip').offsetWidth : 0);
var diffy = y - currenty - RGraph.Registry.Get('chart.tooltip').offsetHeight;
// Position the tooltip
setTimeout('RGraph.Registry.Get("chart.tooltip").style.left = "' + (currentx + (diffx * 0.2)) + 'px"', 25);
setTimeout('RGraph.Registry.Get("chart.tooltip").style.left = "' + (currentx + (diffx * 0.4)) + 'px"', 50);
setTimeout('RGraph.Registry.Get("chart.tooltip").style.left = "' + (currentx + (diffx * 0.6)) + 'px"', 75);
setTimeout('RGraph.Registry.Get("chart.tooltip").style.left = "' + (currentx + (diffx * 0.8)) + 'px"', 100);
setTimeout('RGraph.Registry.Get("chart.tooltip").style.left = "' + (currentx + (diffx * 1.0)) + 'px"', 125);
setTimeout('RGraph.Registry.Get("chart.tooltip").style.top = "' + (currenty + (diffy * 0.2)) + 'px"', 25);
setTimeout('RGraph.Registry.Get("chart.tooltip").style.top = "' + (currenty + (diffy * 0.4)) + 'px"', 50);
setTimeout('RGraph.Registry.Get("chart.tooltip").style.top = "' + (currenty + (diffy * 0.6)) + 'px"', 75);
setTimeout('RGraph.Registry.Get("chart.tooltip").style.top = "' + (currenty + (diffy * 0.8)) + 'px"', 100);
setTimeout('RGraph.Registry.Get("chart.tooltip").style.top = "' + (currenty + (diffy * 1.0)) + 'px"', 125);
}
} else {
alert('[TOOLTIPS] The "snap" effect is only supported on the Line, Rscatter, Scatter and Radar charts (tried to use it with type: ' + canvas.__object__.type);
}
/**
* Fire the tooltip event
*/
RGraph.FireCustomEvent(canvas.__object__, 'ontooltip');
return;
}
/**
* Hide any currently shown tooltip
*/
RGraph.HideTooltip();
/**
* Show a tool tip
*/
var tooltipObj = document.createElement('DIV');
tooltipObj.className = canvas.__object__.Get('chart.tooltips.css.class');
tooltipObj.style.display = 'none';
tooltipObj.style.position = 'absolute';
tooltipObj.style.left = 0;
tooltipObj.style.top = 0;
tooltipObj.style.backgroundColor = 'rgba(255,255,239,0.9)';
tooltipObj.style.color = 'black';
if (!document.all) tooltipObj.style.border = '';
tooltipObj.style.visibility = 'visible';
tooltipObj.style.paddingLeft = RGraph.tooltips.padding;
tooltipObj.style.paddingRight = RGraph.tooltips.padding;
tooltipObj.style.fontFamily = RGraph.tooltips.font_face;
tooltipObj.style.fontSize = RGraph.tooltips.font_size;
tooltipObj.style.zIndex = 3;
tooltipObj.style.borderRadius = '5px';
tooltipObj.style.MozBorderRadius = '5px';
tooltipObj.style.WebkitBorderRadius = '5px';
tooltipObj.style.WebkitBoxShadow = 'rgba(96,96,96,0.5) 0 0 15px';
tooltipObj.style.MozBoxShadow = 'rgba(96,96,96,0.5) 0 0 15px';
tooltipObj.style.boxShadow = 'rgba(96,96,96,0.5) 0 0 15px';
tooltipObj.style.filter = 'progid:DXImageTransform.Microsoft.Shadow(color=#666666,direction=135)';
tooltipObj.style.opacity = 0;
tooltipObj.style.overflow = 'hidden';
tooltipObj.innerHTML = text;
tooltipObj.__text__ = text; // This is set because the innerHTML can change when it's set
tooltipObj.__canvas__ = canvas;
tooltipObj.style.display = 'inline';
tooltipObj.id = '__rgraph_tooltip_' + canvas.id + '_' + idx;
if (typeof(idx) == 'number') {
tooltipObj.__index__ = idx;
/**
* Just for the line chart
*/
if (canvas.__object__.type == 'line') {
var index2 = idx;
while (index2 >= canvas.__object__.data[0].length) {
index2 -= canvas.__object__.data[0].length;
}
tooltipObj.__index2__ = index2;
}
}
document.body.appendChild(tooltipObj);
var width = tooltipObj.offsetWidth;
var height = tooltipObj.offsetHeight;
if ((y - height - 2) > 0) {
y = y - height - 2;
} else {
y = y + 2;
}
/**
* Set the width on the tooltip so it doesn't resize if the window is resized
*/
tooltipObj.style.width = width + 'px';
//tooltipObj.style.height = 0; // Initially set the tooltip height to nothing
/**
* If the mouse is towards the right of the browser window and the tooltip would go outside of the window,
* move it left
*/
if ( (x + width) > document.body.offsetWidth ) {
x = x - width - 7;
var placementLeft = true;
if (canvas.__object__.Get('chart.tooltips.effect') == 'none') {
x = x - 3;
}
tooltipObj.style.left = x + 'px';
tooltipObj.style.top = y + 'px';
} else {
x += 5;
tooltipObj.style.left = x + 'px';
tooltipObj.style.top = y + 'px';
}
if (effect == 'expand') {
tooltipObj.style.left = (x + (width / 2)) + 'px';
tooltipObj.style.top = (y + (height / 2)) + 'px';
leftDelta = (width / 2) / 10;
topDelta = (height / 2) / 10;
tooltipObj.style.width = 0;
tooltipObj.style.height = 0;
//tooltipObj.style.boxShadow = '';
//tooltipObj.style.MozBoxShadow = '';
//tooltipObj.style.WebkitBoxShadow = '';
//tooltipObj.style.borderRadius = 0;
//tooltipObj.style.MozBorderRadius = 0;
//tooltipObj.style.WebkitBorderRadius = 0;
tooltipObj.style.opacity = 1;
// Progressively move the tooltip to where it should be (the x position)
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.left = (parseInt(RGraph.Registry.Get('chart.tooltip').style.left) - leftDelta) + 'px' }", 25));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.left = (parseInt(RGraph.Registry.Get('chart.tooltip').style.left) - leftDelta) + 'px' }", 50));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.left = (parseInt(RGraph.Registry.Get('chart.tooltip').style.left) - leftDelta) + 'px' }", 75));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.left = (parseInt(RGraph.Registry.Get('chart.tooltip').style.left) - leftDelta) + 'px' }", 100));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.left = (parseInt(RGraph.Registry.Get('chart.tooltip').style.left) - leftDelta) + 'px' }", 125));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.left = (parseInt(RGraph.Registry.Get('chart.tooltip').style.left) - leftDelta) + 'px' }", 150));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.left = (parseInt(RGraph.Registry.Get('chart.tooltip').style.left) - leftDelta) + 'px' }", 175));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.left = (parseInt(RGraph.Registry.Get('chart.tooltip').style.left) - leftDelta) + 'px' }", 200));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.left = (parseInt(RGraph.Registry.Get('chart.tooltip').style.left) - leftDelta) + 'px' }", 225));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.left = (parseInt(RGraph.Registry.Get('chart.tooltip').style.left) - leftDelta) + 'px' }", 250));
// Progressively move the tooltip to where it should be (the Y position)
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.top = (parseInt(RGraph.Registry.Get('chart.tooltip').style.top) - topDelta) + 'px' }", 25));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.top = (parseInt(RGraph.Registry.Get('chart.tooltip').style.top) - topDelta) + 'px' }", 50));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.top = (parseInt(RGraph.Registry.Get('chart.tooltip').style.top) - topDelta) + 'px' }", 75));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.top = (parseInt(RGraph.Registry.Get('chart.tooltip').style.top) - topDelta) + 'px' }", 100));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.top = (parseInt(RGraph.Registry.Get('chart.tooltip').style.top) - topDelta) + 'px' }", 125));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.top = (parseInt(RGraph.Registry.Get('chart.tooltip').style.top) - topDelta) + 'px' }", 150));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.top = (parseInt(RGraph.Registry.Get('chart.tooltip').style.top) - topDelta) + 'px' }", 175));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.top = (parseInt(RGraph.Registry.Get('chart.tooltip').style.top) - topDelta) + 'px' }", 200));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.top = (parseInt(RGraph.Registry.Get('chart.tooltip').style.top) - topDelta) + 'px' }", 225));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.top = (parseInt(RGraph.Registry.Get('chart.tooltip').style.top) - topDelta) + 'px' }", 250));
// Progressively grow the tooltip width
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.width = '" + (width * 0.1) + "px'; }", 25));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.width = '" + (width * 0.2) + "px'; }", 50));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.width = '" + (width * 0.3) + "px'; }", 75));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.width = '" + (width * 0.4) + "px'; }", 100));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.width = '" + (width * 0.5) + "px'; }", 125));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.width = '" + (width * 0.6) + "px'; }", 150));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.width = '" + (width * 0.7) + "px'; }", 175));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.width = '" + (width * 0.8) + "px'; }", 200));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.width = '" + (width * 0.9) + "px'; }", 225));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.width = '" + width + "px'; }", 250));
// Progressively grow the tooltip height
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.height = '" + (height * 0.1) + "px'; }", 25));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.height = '" + (height * 0.2) + "px'; }", 50));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.height = '" + (height * 0.3) + "px'; }", 75));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.height = '" + (height * 0.4) + "px'; }", 100));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.height = '" + (height * 0.5) + "px'; }", 125));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.height = '" + (height * 0.6) + "px'; }", 150));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.height = '" + (height * 0.7) + "px'; }", 175));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.height = '" + (height * 0.8) + "px'; }", 200));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.height = '" + (height * 0.9) + "px'; }", 225));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.height = '" + height + "px'; }", 250));
// When the animation is finished, set the tooltip HTML
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').innerHTML = RGraph.Registry.Get('chart.tooltip').__text__; }", 250));
} else if (effect == 'contract') {
tooltipObj.style.left = (x - width) + 'px';
tooltipObj.style.top = (y - (height * 2)) + 'px';
tooltipObj.style.cursor = 'pointer';
leftDelta = width / 10;
topDelta = height / 10;
tooltipObj.style.width = (width * 5) + 'px';
tooltipObj.style.height = (height * 5) + 'px';
tooltipObj.style.opacity = 0.2;
// Progressively move the tooltip to where it should be (the x position)
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.left = (parseInt(RGraph.Registry.Get('chart.tooltip').style.left) + leftDelta) + 'px' }", 25));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.left = (parseInt(RGraph.Registry.Get('chart.tooltip').style.left) + leftDelta) + 'px' }", 50));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.left = (parseInt(RGraph.Registry.Get('chart.tooltip').style.left) + leftDelta) + 'px' }", 75));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.left = (parseInt(RGraph.Registry.Get('chart.tooltip').style.left) + leftDelta) + 'px' }", 100));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.left = (parseInt(RGraph.Registry.Get('chart.tooltip').style.left) + leftDelta) + 'px' }", 125));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.left = (parseInt(RGraph.Registry.Get('chart.tooltip').style.left) + leftDelta) + 'px' }", 150));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.left = (parseInt(RGraph.Registry.Get('chart.tooltip').style.left) + leftDelta) + 'px' }", 175));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.left = (parseInt(RGraph.Registry.Get('chart.tooltip').style.left) + leftDelta) + 'px' }", 200));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.left = (parseInt(RGraph.Registry.Get('chart.tooltip').style.left) + leftDelta) + 'px' }", 225));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.left = (parseInt(RGraph.Registry.Get('chart.tooltip').style.left) + leftDelta) + 'px' }", 250));
// Progressively move the tooltip to where it should be (the Y position)
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.top = (parseInt(RGraph.Registry.Get('chart.tooltip').style.top) + (topDelta*2)) + 'px' }", 25));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.top = (parseInt(RGraph.Registry.Get('chart.tooltip').style.top) + (topDelta*2)) + 'px' }", 50));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.top = (parseInt(RGraph.Registry.Get('chart.tooltip').style.top) + (topDelta*2)) + 'px' }", 75));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.top = (parseInt(RGraph.Registry.Get('chart.tooltip').style.top) + (topDelta*2)) + 'px' }", 100));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.top = (parseInt(RGraph.Registry.Get('chart.tooltip').style.top) + (topDelta*2)) + 'px' }", 125));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.top = (parseInt(RGraph.Registry.Get('chart.tooltip').style.top) + (topDelta*2)) + 'px' }", 150));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.top = (parseInt(RGraph.Registry.Get('chart.tooltip').style.top) + (topDelta*2)) + 'px' }", 175));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.top = (parseInt(RGraph.Registry.Get('chart.tooltip').style.top) + (topDelta*2)) + 'px' }", 200));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.top = (parseInt(RGraph.Registry.Get('chart.tooltip').style.top) + (topDelta*2)) + 'px' }", 225));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.top = (parseInt(RGraph.Registry.Get('chart.tooltip').style.top) + (topDelta*2)) + 'px' }", 250));
// Progressively shrink the tooltip width
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.width = '" + (width * 5.5) + "px'; }", 25));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.width = '" + (width * 5.0) + "px'; }", 50));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.width = '" + (width * 4.5) + "px'; }", 75));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.width = '" + (width * 4.0) + "px'; }", 100));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.width = '" + (width * 3.5) + "px'; }", 125));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.width = '" + (width * 3.0) + "px'; }", 150));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.width = '" + (width * 2.5) + "px'; }", 175));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.width = '" + (width * 2.0) + "px'; }", 200));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.width = '" + (width * 1.5) + "px'; }", 225));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.width = '" + width + "px'; }", 250));
// Progressively shrink the tooltip height
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.height = '" + (height * 5.5) + "px'; }", 25));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.height = '" + (height * 5.0) + "px'; }", 50));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.height = '" + (height * 4.5) + "px'; }", 75));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.height = '" + (height * 4.0) + "px'; }", 100));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.height = '" + (height * 3.5) + "px'; }", 125));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.height = '" + (height * 3.0) + "px'; }", 150));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.height = '" + (height * 2.5) + "px'; }", 175));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.height = '" + (height * 2.0) + "px'; }", 200));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.height = '" + (height * 1.5) + "px'; }", 225));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.height = '" + height + "px'; }", 250));
// When the animation is finished, set the tooltip HTML
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').innerHTML = RGraph.Registry.Get('chart.tooltip').__text__; }", 250));
/**
* This resets the pointer
*/
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.cursor = 'default'; }", 275));
} else if (effect == 'snap') {
/*******************************************************
* Move the tooltip
*******************************************************/
for (var i=1; i<=10; ++i) {
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.left = '" + (x * 0.1 * i) + "px'; }", 15 * i));
RGraph.Registry.Get('chart.tooltip.timers').push(setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.top = '" + (y * 0.1 * i) + "px'; }", 15 * i));
}
tooltipObj.style.left = 0 - tooltipObj.offsetWidth + 'px';
tooltipObj.style.top = 0 - tooltipObj.offsetHeight + 'px';
} else if (effect != 'fade' && effect != 'expand' && effect != 'none' && effect != 'snap' && effect != 'contract') {
alert('[COMMON] Unknown tooltip effect: ' + effect);
}
if (effect != 'none') {
setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.opacity = 0.1; }", 25);
setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.opacity = 0.2; }", 50);
setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.opacity = 0.3; }", 75);
setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.opacity = 0.4; }", 100);
setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.opacity = 0.5; }", 125);
setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.opacity = 0.6; }", 150);
setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.opacity = 0.7; }", 175);
setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.opacity = 0.8; }", 200);
setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.opacity = 0.9; }", 225);
}
setTimeout("if (RGraph.Registry.Get('chart.tooltip')) { RGraph.Registry.Get('chart.tooltip').style.opacity = 1;}", effect == 'none' ? 50 : 250);
/**
* If the tooltip it self is clicked, cancel it
*/
tooltipObj.onmousedown = function (e)
{
e = RGraph.FixEventObject(e)
e.stopPropagation();
}
tooltipObj.onclick = function (e)
{
if (e.button == 0) {
e = RGraph.FixEventObject(e);
e.stopPropagation();
}
}
/**
* Install the function for hiding the tooltip.
*/
document.body.onmousedown = function (event)
{
var tooltip = RGraph.Registry.Get('chart.tooltip');
if (tooltip) {
RGraph.HideTooltip();
// Redraw if highlighting is enabled
if (tooltip.__canvas__.__object__.Get('chart.tooltips.highlight')) {
RGraph.Redraw();
}
}
}
/**
* If the window is resized, hide the tooltip
*/
window.onresize = function ()
{
var tooltip = RGraph.Registry.Get('chart.tooltip');
if (tooltip) {
tooltip.parentNode.removeChild(tooltip);
tooltip.style.display = 'none';
tooltip.style.visibility = 'hidden';
RGraph.Registry.Set('chart.tooltip', null);
// Redraw the graph if necessary
if (canvas.__object__.Get('chart.tooltips.highlight')) {
RGraph.Clear(canvas);
canvas.__object__.Draw();
}
}
}
/**
* Keep a reference to the tooltip
*/
RGraph.Registry.Set('chart.tooltip', tooltipObj);
/**
* Fire the tooltip event
*/
RGraph.FireCustomEvent(canvas.__object__, 'ontooltip');
}
/**
*
*/
RGraph.getTooltipTextFromDIV = function (text)
{
var result = /^id:(.*)/.exec(text);
if (result && result[1] && document.getElementById(result[1])) {
text = document.getElementById(result[1]).innerHTML;
}
return text;
}
/**
* This function handles the tooltip text being a string, function, or an array of functions.
*/
RGraph.parseTooltipText = function (tooltips, idx)
{
// Get the tooltip text
if (typeof(tooltips) == 'function') {
var text = tooltips(idx);
} else if (typeof(tooltips) == 'object' && tooltips && typeof(tooltips[idx]) == 'function') {
var text = tooltips[idx](idx);
} else if (typeof(tooltips) == 'object' && tooltips) {
var text = String(tooltips[idx]);
} else {
var text = '';
}
if (text == 'undefined') {
text = '';
}
return text;
}
/**
*
*/
RGraph.getTooltipWidth = function (text, obj)
{
var div = document.createElement('DIV');
div.className = obj.Get('chart.tooltips.css.class');
div.style.paddingLeft = RGraph.tooltips.padding;
div.style.paddingRight = RGraph.tooltips.padding;
div.style.fontFamily = RGraph.tooltips.font_face;
div.style.fontSize = RGraph.tooltips.font_size;
div.style.visibility = 'hidden';
div.style.position = 'absolute';
div.style.top = '300px';
div.style.left = 0;
div.style.display = 'inline';
div.innerHTML = RGraph.getTooltipTextFromDIV(text);
document.body.appendChild(div);
return div.offsetWidth;
}
/**
* Hides the currently shown tooltip
*/
RGraph.HideTooltip = function ()
{
var tooltip = RGraph.Registry.Get('chart.tooltip');
if (tooltip) {
tooltip.parentNode.removeChild(tooltip);
tooltip.style.display = 'none';
tooltip.style.visibility = 'hidden';
RGraph.Registry.Set('chart.tooltip', null);
}
}
/**
* The BAR chart onmousemove event Bar chart tooltips can now
* be based around the onmousemove event
*/
RGraph.InstallBarTooltipEventListeners = function (obj)
{
/**
* Install the window onclick handler
*/
var window_onclick_func = function (){RGraph.Redraw();};
window.addEventListener('click', window_onclick_func, false);
RGraph.AddEventListener('window_' + obj.id, 'click', window_onclick_func);
var canvas_onmousemove = function (e)
{
e = RGraph.FixEventObject(e);
var canvas = document.getElementById(e.target.id);
var obj = canvas.__object__;
if (obj.__bar__) {
var lineObj = obj;
obj = obj.__bar__;
obj.__line__ = lineObj;
}
var barCoords = obj.getBar(e);
/**
* If there are bar coords AND the bar has height
*/
if (barCoords && barCoords[4] > 0) {
/**
* Get the tooltip text
*/
var text = RGraph.parseTooltipText(obj.Get('chart.tooltips'), barCoords[5]);
if (text) {
canvas.style.cursor = 'pointer';
} else {
canvas.style.cursor = 'default';
}
/**
* Hide the currently displayed tooltip if the index is the same
*/
if ( RGraph.Registry.Get('chart.tooltip')
&& RGraph.Registry.Get('chart.tooltip').__canvas__.id != obj.id
&& obj.Get('chart.tooltips.event') == 'onmousemove') {
RGraph.Redraw();
RGraph.HideTooltip();
}
/**
* This facilitates the tooltips using the onmousemove event
*/
if ( obj.Get('chart.tooltips.event') == 'onmousemove'
&& (
(RGraph.Registry.Get('chart.tooltip') && RGraph.Registry.Get('chart.tooltip').__index__ != barCoords[5])
|| !RGraph.Registry.Get('chart.tooltip')
)
&& text) {
/**
* Show a tooltip if it's defined
*/
RGraph.Redraw(obj);
if (obj.Get('chart.tooltips.highlight')) {
obj.context.beginPath();
obj.context.strokeStyle = obj.Get('chart.highlight.stroke');
obj.context.fillStyle = obj.Get('chart.highlight.fill');
obj.context.strokeRect(barCoords[1], barCoords[2], barCoords[3], barCoords[4]);
obj.context.fillRect(barCoords[1], barCoords[2], barCoords[3], barCoords[4]);
obj.context.stroke();
obj.context.fill();
}
RGraph.Tooltip(canvas, text, e.pageX, e.pageY, barCoords[5]);
}
} else if (obj.__line__ && obj.__line__.getPoint && obj.__line__.getPoint(e)) {
canvas.style.cursor = 'pointer';
} else {
canvas.style.cursor = 'default';
}
}
RGraph.AddEventListener(obj.id, 'mousemove', canvas_onmousemove);
obj.canvas.addEventListener('mousemove', canvas_onmousemove, false);
/**
* Install the onclick event handler for the tooltips
*/
if (obj.Get('chart.tooltips.event') == 'onclick') {
var canvas_onclick = function (e)
{
var e = RGraph.FixEventObject(e);
// If the button pressed isn't the left, we're not interested
if (e.button != 0) return;
e = RGraph.FixEventObject(e);
var canvas = document.getElementById(this.id);
var obj = canvas.__object__;
if (obj.__bar__) {
obj = obj.__bar__;
}
var barCoords = obj.getBar(e);
/**
* Redraw the graph first, in effect resetting the graph to as it was when it was first drawn
* This "deselects" any already selected bar
*/
RGraph.Redraw();
/**
* Loop through the bars determining if the mouse is over a bar
*/
if (barCoords) {
/**
* Get the tooltip text
*/
var text = RGraph.parseTooltipText(obj.Get('chart.tooltips'), barCoords[5]);
/**
* Show a tooltip if it's defined
*/
if (text && text != 'undefined') {
if (obj.Get('chart.tooltips.highlight')) {
obj.context.beginPath();
obj.context.strokeStyle = obj.Get('chart.highlight.stroke');
obj.context.fillStyle = obj.Get('chart.highlight.fill');
obj.context.strokeRect(barCoords[1], barCoords[2], barCoords[3], barCoords[4]);
obj.context.fillRect(barCoords[1], barCoords[2], barCoords[3], barCoords[4]);
obj.context.stroke();
obj.context.fill();
}
RGraph.Tooltip(canvas, text, e.pageX, e.pageY, barCoords[5]);
}
}
/**
* Stop the event bubbling
*/
e.stopPropagation();
}
RGraph.AddEventListener(obj.id, 'click', canvas_onclick);
obj.canvas.addEventListener('click', canvas_onclick, false);
}
}
/**
* The LINE chart tooltips event handlers
*
* @param object obj The graph object
*/
RGraph.InstallLineTooltipEventListeners = function (obj)
{
var canvas_onmousemove_func = function (e)
{
e = RGraph.FixEventObject(e);
var canvas = e.target;
var context = canvas.getContext('2d');
var obj = canvas.__object__;
var point = obj.getPoint(e);
if (obj.Get('chart.tooltips.highlight')) {
RGraph.Register(obj);
}
if ( point
&& typeof(point[0]) == 'object'
&& typeof(point[1]) == 'number'
&& typeof(point[2]) == 'number'
&& typeof(point[3]) == 'number'
) {
// point[0] is the graph object
var xCoord = point[1];
var yCoord = point[2];
var idx = point[3];
if ((obj.Get('chart.tooltips')[idx] || typeof(obj.Get('chart.tooltips')) == 'function')) {
var text = RGraph.parseTooltipText(obj.Get('chart.tooltips'), idx);
// No tooltip text - do nada
if (text.match(/^id:(.*)$/) && RGraph.getTooltipTextFromDIV(text).substring(0,3) == 'id:') {
return;
}
// Chnage the pointer to a hand
canvas.style.cursor = 'pointer';
/**
* If the tooltip is the same one as is currently visible (going by the array index), don't do squat and return.
*/
if ( RGraph.Registry.Get('chart.tooltip')
&& RGraph.Registry.Get('chart.tooltip').__index__ == idx
&& RGraph.Registry.Get('chart.tooltip').__canvas__.id == canvas.id
&& RGraph.Registry.Get('chart.tooltip').__event__
&& RGraph.Registry.Get('chart.tooltip').__event__ == 'mousemove') {
return;
}
/**
* Redraw the graph
*/
if (obj.Get('chart.tooltips.highlight') || obj.__bar__) {
RGraph.Redraw();
if (obj.__bar__) {
RGraph.Clear(obj.canvas);
obj.__bar__.Draw();
}
}
// SHOW THE CORRECT TOOLTIP
RGraph.Tooltip(canvas, text, e.pageX, obj.Get('chart.tooltips.hotspot.xonly') ? (point[2] + RGraph.getCanvasXY(canvas)[1]) : e.pageY, idx);
// Store the tooltip index on the tooltip object
RGraph.Registry.Get('chart.tooltip').__index__ = Number(idx);
/**
* This converts idx into the index that is not greater than the
* number of items in the data array
*/
while (idx >= obj.data[0].length) {
idx -= obj.data[0].length
}
RGraph.Registry.Get('chart.tooltip').__index2__ = idx;
/**
* Set the source event
*/
RGraph.Registry.Get('chart.tooltip').__event__ = 'mousemove';
/**
* Highlight the graph
*/
if (obj.Get('chart.tooltips.highlight')) {
context.beginPath();
context.moveTo(xCoord, yCoord);
context.arc(xCoord, yCoord, 2, 0, 6.28, 0);
context.strokeStyle = obj.Get('chart.highlight.stroke');
context.fillStyle = obj.Get('chart.highlight.fill');
context.stroke();
context.fill();
}
e.stopPropagation();
return;
}
}
/**
* Not over a hotspot?
*/
canvas.style.cursor = 'default';
}
obj.canvas.addEventListener('mousemove', canvas_onmousemove_func, false);
RGraph.AddEventListener(obj.id, 'mousemove', canvas_onmousemove_func);
}
|