rgraph-rails 5.00 → 6.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/publish-geml.yaml +46 -0
  3. data/.gitignore +1 -0
  4. data/README.md +4 -5
  5. data/lib/rgraph-rails/version.rb +1 -1
  6. data/rgraph-rails.gemspec +4 -4
  7. data/vendor/assets/javascripts/RGraph.activity.js +1691 -0
  8. data/vendor/assets/javascripts/RGraph.bar.js +4253 -236
  9. data/vendor/assets/javascripts/RGraph.bipolar.js +3958 -162
  10. data/vendor/assets/javascripts/RGraph.common.annotate.js +414 -35
  11. data/vendor/assets/javascripts/RGraph.common.context.js +635 -30
  12. data/vendor/assets/javascripts/RGraph.common.core.js +10485 -419
  13. data/vendor/assets/javascripts/RGraph.common.csv.js +508 -27
  14. data/vendor/assets/javascripts/RGraph.common.dynamic.js +1693 -90
  15. data/vendor/assets/javascripts/RGraph.common.effects.js +1629 -89
  16. data/vendor/assets/javascripts/RGraph.common.key.js +1003 -53
  17. data/vendor/assets/javascripts/RGraph.common.moment.js +5670 -0
  18. data/vendor/assets/javascripts/RGraph.common.sheets.js +541 -31
  19. data/vendor/assets/javascripts/RGraph.common.sheets.php +351 -0
  20. data/vendor/assets/javascripts/RGraph.common.starburst.js +382 -0
  21. data/vendor/assets/javascripts/RGraph.common.table.js +386 -0
  22. data/vendor/assets/javascripts/RGraph.common.tooltips.js +1433 -32
  23. data/vendor/assets/javascripts/RGraph.drawing.background.js +660 -35
  24. data/vendor/assets/javascripts/RGraph.drawing.circle.js +618 -34
  25. data/vendor/assets/javascripts/RGraph.drawing.image.js +857 -52
  26. data/vendor/assets/javascripts/RGraph.drawing.line.js +712 -0
  27. data/vendor/assets/javascripts/RGraph.drawing.marker1.js +760 -38
  28. data/vendor/assets/javascripts/RGraph.drawing.marker2.js +740 -37
  29. data/vendor/assets/javascripts/RGraph.drawing.marker3.js +573 -36
  30. data/vendor/assets/javascripts/RGraph.drawing.poly.js +667 -36
  31. data/vendor/assets/javascripts/RGraph.drawing.rect.js +638 -34
  32. data/vendor/assets/javascripts/RGraph.drawing.text.js +672 -37
  33. data/vendor/assets/javascripts/RGraph.drawing.xaxis.js +653 -52
  34. data/vendor/assets/javascripts/RGraph.drawing.yaxis.js +714 -51
  35. data/vendor/assets/javascripts/RGraph.fuel.js +1149 -59
  36. data/vendor/assets/javascripts/RGraph.funnel.js +1277 -56
  37. data/vendor/assets/javascripts/RGraph.gantt.js +1646 -82
  38. data/vendor/assets/javascripts/RGraph.gauge.js +1773 -89
  39. data/vendor/assets/javascripts/RGraph.hbar.js +3869 -159
  40. data/vendor/assets/javascripts/RGraph.horseshoe.js +970 -0
  41. data/vendor/assets/javascripts/RGraph.hprogress.js +1829 -81
  42. data/vendor/assets/javascripts/RGraph.line.js +5293 -244
  43. data/vendor/assets/javascripts/RGraph.meter.js +1570 -77
  44. data/vendor/assets/javascripts/RGraph.modaldialog.js +300 -19
  45. data/vendor/assets/javascripts/RGraph.odo.js +1553 -68
  46. data/vendor/assets/javascripts/RGraph.pie.js +3273 -129
  47. data/vendor/assets/javascripts/RGraph.radar.js +2333 -108
  48. data/vendor/assets/javascripts/RGraph.rose.js +2685 -114
  49. data/vendor/assets/javascripts/RGraph.rscatter.js +1920 -80
  50. data/vendor/assets/javascripts/RGraph.scatter.js +4215 -171
  51. data/vendor/assets/javascripts/RGraph.segmented.js +1006 -0
  52. data/vendor/assets/javascripts/RGraph.semicircularprogress.js +1980 -59
  53. data/vendor/assets/javascripts/RGraph.svg.activity.js +1696 -0
  54. data/vendor/assets/javascripts/RGraph.svg.bar.js +2575 -77
  55. data/vendor/assets/javascripts/RGraph.svg.bipolar.js +3533 -106
  56. data/vendor/assets/javascripts/RGraph.svg.common.ajax.js +240 -21
  57. data/vendor/assets/javascripts/RGraph.svg.common.core.js +7105 -299
  58. data/vendor/assets/javascripts/RGraph.svg.common.csv.js +408 -28
  59. data/vendor/assets/javascripts/RGraph.svg.common.fx.js +1291 -68
  60. data/vendor/assets/javascripts/RGraph.svg.common.key.js +451 -20
  61. data/vendor/assets/javascripts/RGraph.svg.common.sheets.js +543 -31
  62. data/vendor/assets/javascripts/RGraph.svg.common.table.js +391 -0
  63. data/vendor/assets/javascripts/RGraph.svg.common.tooltips.js +1072 -23
  64. data/vendor/assets/javascripts/RGraph.svg.funnel.js +1151 -32
  65. data/vendor/assets/javascripts/RGraph.svg.gauge.js +1429 -34
  66. data/vendor/assets/javascripts/RGraph.svg.hbar.js +2692 -65
  67. data/vendor/assets/javascripts/RGraph.svg.horseshoe.js +969 -0
  68. data/vendor/assets/javascripts/RGraph.svg.line.js +2855 -86
  69. data/vendor/assets/javascripts/RGraph.svg.pie.js +1630 -58
  70. data/vendor/assets/javascripts/RGraph.svg.radar.js +1772 -58
  71. data/vendor/assets/javascripts/RGraph.svg.rose.js +2419 -83
  72. data/vendor/assets/javascripts/RGraph.svg.scatter.js +2280 -65
  73. data/vendor/assets/javascripts/RGraph.svg.segmented.js +930 -0
  74. data/vendor/assets/javascripts/RGraph.svg.semicircularprogress.js +1612 -29
  75. data/vendor/assets/javascripts/RGraph.svg.waterfall.js +1525 -50
  76. data/vendor/assets/javascripts/RGraph.thermometer.js +1411 -64
  77. data/vendor/assets/javascripts/RGraph.vprogress.js +1915 -81
  78. data/vendor/assets/javascripts/RGraph.waterfall.js +1896 -89
  79. data/vendor/assets/javascripts/financial-data.js +1067 -0
  80. metadata +37 -16
  81. data/.travis.yml +0 -11
  82. data/vendor/assets/javascripts/RGraph.common.deprecated.js +0 -35
  83. data/vendor/assets/javascripts/RGraph.common.resizing.js +0 -38
  84. data/vendor/assets/javascripts/RGraph.common.zoom.js +0 -15
  85. data/vendor/assets/javascripts/RGraph.cornergauge.js +0 -71
@@ -1,91 +1,1694 @@
1
+ 'version:2023-09-16 (6.14)';
2
+ //
3
+ // o--------------------------------------------------------------------------------o
4
+ // | This file is part of the RGraph package - you can learn more at: |
5
+ // | |
6
+ // | https://www.rgraph.net |
7
+ // | |
8
+ // | RGraph is licensed under the Open Source MIT license. That means that it's |
9
+ // | totally free to use and there are no restrictions on what you can do with it! |
10
+ // o--------------------------------------------------------------------------------o
1
11
 
2
- RGraph=window.RGraph||{isRGraph:true};(function(win,doc,undefined)
3
- {var RG=RGraph,ua=navigator.userAgent,ma=Math;RG.installWindowMousedownListener=RG.InstallWindowMousedownListener=function(obj)
4
- {if(!RG.window_mousedown_event_listener){RG.window_mousedown_event_listener=function(e)
5
- {if(navigator.userAgent.indexOf('Firefox')>=0)win.event=e;e=RG.fixEventObject(e);if(RG.HideTooltip&&RG.Registry.get('chart.tooltip')){RG.clear(RG.Registry.get('chart.tooltip').__canvas__);RG.redraw();RG.hideTooltip();}};win.addEventListener('mousedown',RG.window_mousedown_event_listener,false);}};RG.installWindowMouseupListener=RG.InstallWindowMouseupListener=function(obj)
6
- {if(!RG.window_mouseup_event_listener){RG.window_mouseup_event_listener=function(e)
7
- {if(navigator.userAgent.indexOf('Firefox')>=0)win.event=e;e=RG.fixEventObject(e);if(RG.annotating_window_onmouseup){RG.annotating_window_onmouseup(e);return;}
8
- if(RG.Registry.get('chart.adjusting')||RG.Registry.get('chart.adjusting.gantt')){var obj=RG.Registry.get('chart.adjusting');if(obj&&obj.type==='line'){obj.data_arr=RG.arrayLinearize(obj.data);}
9
- RG.fireCustomEvent(RG.Registry.get('chart.adjusting'),'onadjustend');}
10
- RG.Registry.set('chart.adjusting',null);RG.Registry.set('chart.adjusting.shape',null);RG.Registry.set('chart.adjusting.gantt',null);var tags=document.getElementsByTagName('canvas');for(var i=0;i<tags.length;++i){if(tags[i].__object__&&tags[i].__object__.isRGraph){if(!tags[i].__object__.get('chart.annotatable')){if(!tags[i].__rgraph_trace_cover__&&!noredraw){RG.clear(tags[i]);}else{var noredraw=true;}}}}
11
- if(!noredraw){RG.redraw();}};win.addEventListener('mouseup',RG.window_mouseup_event_listener,false);}};RG.installCanvasMouseupListener=RG.InstallCanvasMouseupListener=function(obj)
12
- {if(!obj.canvas.rgraph_mouseup_event_listener){obj.canvas.rgraph_mouseup_event_listener=function(e)
13
- {if(navigator.userAgent.indexOf('Firefox')>=0)window.event=e;e=RG.fixEventObject(e);var objects=RG.ObjectRegistry.getObjectsByXY(e);if(objects){for(var i=0,len=objects.length;i<len;i+=1){var obj=objects[i],id=objects[i].id;var link=obj.get('link');if(obj.type=='drawing.text'&&typeof link==='string'){var link_target=obj.get('link.target');var link_options=obj.get('link.options');window.open(link,link_target?link_target:null,link_options);}
14
- if(!RG.isNull(obj)&&RG.tooltip){var shape=obj.getShape(e);if(shape&&shape['tooltip']){var text=shape['tooltip'];if(text){var type=shape['object'].type;RG.clear(obj.canvas);RG.redraw();RG.Registry.set('chart.tooltip.shape',shape);RG.tooltip(obj,text,0,0,shape['index'],e);obj.highlight(shape);if(RG.Registry.get('chart.tooltip')){RG.Registry.get('chart.tooltip').__shape__=shape;RG.evaluateCursor(e);}
15
- e.cancelBubble=true;e.stopPropagation();return false;}}}
16
- if(RG.Registry.get('chart.adjusting')||RG.Registry.get('chart.adjusting.gantt')){if(obj&&obj.type==='line'){obj.data_arr=RG.arrayLinearize(obj.data);}
17
- RG.fireCustomEvent(RG.Registry.get('chart.adjusting'),'onadjustend');}
18
- RG.Registry.set('chart.adjusting',null);RG.Registry.set('chart.adjusting.shape',null);RG.Registry.set('chart.adjusting.gantt',null);if(shape||(obj.overChartArea&&obj.overChartArea(e))){break;}}}};obj.canvas.addEventListener('mouseup',obj.canvas.rgraph_mouseup_event_listener,false);}};RG.installCanvasMousemoveListener=RG.InstallCanvasMousemoveListener=function(obj)
19
- {if(!obj.canvas.rgraph_mousemove_event_listener){obj.canvas.rgraph_mousemove_event_listener=function(e)
20
- {if(navigator.userAgent.indexOf('Firefox')>=0)window.event=e;e=RG.fixEventObject(e);var objects=RG.OR.getObjectsByXY(e);var uids=[];if(objects&&objects.length>0){for(var i=0,len=objects.length;i<len;i+=1){var obj=objects[i];var id=obj.id;uids[obj.uid]=true;if(!obj.getShape){continue;}
21
- var shape=obj.getShape(e);if(RG.last_mouseover_uid&&RG.last_mouseover_uid!==obj.uid){RG.fireCustomEvent(RG.last_mouseover_object,'onmouseout');RG.last_mouseover_object.__mouseover_shape_index__=null;RG.last_mouseover_object.__mouseover_shape__=null;RG.last_mouseover_object=null;RG.last_mouseover_uid=null;}
22
- if((!shape&&typeof obj.__mouseover_shape_index__==='number')||(shape&&typeof obj.__mouseover_shape_index__==='number'&&shape.index!==obj.__mouseover_shape_index__)){RG.fireCustomEvent(obj,'onmouseout');}
23
- if(obj.coords&&obj.coords.key&&obj.coords.key.length){var mouseXY=RG.getMouseXY(e);for(var i=0,overkey=false;i<obj.coords.key.length;++i){if(mouseXY[0]>=obj.coords.key[i][0]&&mouseXY[0]<=(obj.coords.key[i][0]+obj.coords.key[i][2])&&mouseXY[1]>=obj.coords.key[i][1]&&mouseXY[1]<=(obj.coords.key[i][1]+obj.coords.key[i][3])){RG.Registry.set('key-element',obj.coords.key[i]);overkey=true;}
24
- if(!overkey){RG.Registry.set('key-element',null);}}}
25
- var func=obj.get('chart.events.mousemove');if(!func&&typeof obj.onmousemove=='function'){var func=obj.onmousemove;}
26
- if(shape){var index=shape['object'].type=='scatter'?shape['index_adjusted']:shape['index'];if(typeof(obj['$'+index])=='object'&&typeof(obj['$'+index].onmousemove)=='function'){var func2=obj['$'+index].onmousemove;}}
27
- if(shape&&(typeof(func)=='function'||typeof(func2)=='function'||typeof obj.get('link')==='string')){if(obj.get('chart.events.mousemove.revertto')==null){obj.set('chart.events.mousemove.revertto',e.target.style.cursor);}
28
- if(typeof(func)=='function')RGraph.custom_events_mousemove_pointer=func(e,shape);if(typeof(func2)=='function')RGraph.custom_events_mousemove_pointer=RGraph.custom_events_mousemove_pointer||func2(e,shape);if(typeof RG.events==='object'&&typeof RG.events[obj.uid]==='object'){for(i in RG.events[obj.uid]){if(typeof i==='string'&&typeof RG.events[obj.uid][i]==='object'&&RG.events[obj.uid][i][1]==='onmousemove'&&typeof RG.events[obj.uid][i][2]==='function'){(RG.events[obj.uid][i][2])(obj);}}}}else if(typeof(obj.get('chart.events.mousemove.revertto'))=='string'){RG.cursor.push('default');obj.set('chart.events.mousemove.revertto',null);}
29
- var func=obj.properties['chart.events.mouseover'];if(!func&&typeof obj.onmouseover==='function'){func=obj.onmouseover;}
30
- if(shape){var index=shape['object'].type=='scatter'?shape['index_adjusted']:shape['index'];if(typeof(obj['$'+index])=='object'&&typeof(obj['$'+index].onmouseover)=='function'){var func2=obj['$'+index].onmouseover;}}else{obj.__mouseover_shape_index__=null;RG.__mouseover_objects__=[];RG.last_mouseover_uid=null;RG.last_mouseover_object=null;}
31
- if(typeof RG.__mouseover_objects__==='undefined'){RG.__mouseover_objects__=[];RG.last_mouseover_uid=null;RG.last_mouseover_object=null;}
32
- if(shape){if((obj.__mouseover_shape_index__===shape.index)===false){obj.__mouseover_shape__=shape;obj.__mouseover_shape_index__=shape.index;RG.last_mouseover_uid=obj.uid;RG.last_mouseover_object=obj;RG.__mouseover_objects__.push(obj);if(func)func(e,shape);if(func2)func2(e,shape);if(typeof RG.events==='object'&&typeof RG.events[obj.uid]==='object'){for(i in RG.events[obj.uid]){if(typeof i==='string'&&typeof RG.events[obj.uid][i]==='object'&&RG.events[obj.uid][i][1]==='onmouseover'&&typeof RG.events[obj.uid][i][2]==='function'){(RG.events[obj.uid][i][2])(obj);}}}}}else{obj.__mouseover_shape_index__=null;RG.__mouseover_objects__=[];RG.last_mouseover_uid=null;RG.last_mouseover_object=null;}
33
- var current_tooltip=RG.Registry.get('chart.tooltip');var tooltips=obj.get('chart.tooltips');var tooltips_event=obj.get('chart.tooltips.event');if(shape&&(tooltips&&tooltips[shape['index']]||shape['tooltip'])&&tooltips_event.indexOf('mousemove')!==-1&&(RG.isNull(current_tooltip)||obj.uid!=current_tooltip.__object__.uid||(current_tooltip.__index__!=shape['index'])||(typeof shape['dataset']==='number'&&shape['dataset']!=current_tooltip.__shape__['dataset']))){RG.clear(obj.canvas);RG.hideTooltip();RG.redraw();obj.canvas.rgraph_mouseup_event_listener(e);return;}
34
- if(obj&&obj.get('chart.adjustable')){obj.Adjusting_mousemove(e);}
35
- if(shape||(obj.overChartArea&&obj.overChartArea(e))){break;}}
36
- var objects=RG.OR.getObjectsByCanvasID(e.target.id);for(var i=0;i<objects.length;++i){if(!uids[objects[i].uid]){objects[i].__mouseover_shape_index__=null;}}}else{var objects=RG.OR.getObjectsByCanvasID(e.target.id);for(var i=0;i<objects.length;i++){if(typeof objects[i].__mouseover_shape_index__==='number'){RG.fireCustomEvent(objects[i],'onmouseout');}
37
- objects[i].__mouseover_shape_index__=null;}
38
- RG.__mouseover_objects__=[];RG.last_mouseover_uid=null;RG.last_mouseover_object=null;}
39
- if(e.target&&e.target.__object__&&e.target.__object__.get('chart.crosshairs')){RG.drawCrosshairs(e,e.target.__object__);}
40
- if(e.target.__object__&&e.target.__object__.get('chart.annotatable')&&RG.annotating_canvas_onmousemove){RG.annotating_canvas_onmousemove(e);}
41
- RG.evaluateCursor(e);};obj.canvas.addEventListener('mousemove',obj.canvas.rgraph_mousemove_event_listener,false);}};RG.installCanvasMousedownListener=RG.InstallCanvasMousedownListener=function(obj)
42
- {if(!obj.canvas.rgraph_mousedown_event_listener){obj.canvas.rgraph_mousedown_event_listener=function(e)
43
- {if(navigator.userAgent.indexOf('Firefox')>=0)window.event=e;e=RG.fixEventObject(e);if(e.target.__object__&&e.target.__object__.get('chart.annotatable')&&RG.annotating_canvas_onmousedown){RG.annotating_canvas_onmousedown(e);return;}
44
- var obj=RG.ObjectRegistry.getObjectByXY(e);if(obj){var id=obj.id;if(obj&&obj.isRGraph&&obj.get('chart.adjustable')){var obj=RG.OR.getObjectByXY(e);if(obj&&obj.isRGraph){switch(obj.type){case'bar':var shape=obj.getShapeByX(e);break;case'gantt':var shape=obj.getShape(e);var data=typeof shape.subindex==='number'?obj.data[shape.index][shape.subindex]:obj.data[shape.index];if(shape){var mouseXY=RG.getMouseXY(e);RG.Registry.set('chart.adjusting.gantt',{index:shape.index,subindex:shape.subindex,object:obj,mousex:mouseXY[0],mousey:mouseXY[1],event:data,event_start:data.start,event_duration:data.duration,mode:(mouseXY[0]>(shape['x']+shape['width']-5)?'resize':'move'),shape:shape});}
45
- break;case'line':var shape=obj.getShape(e);break;case'hbar':var shape=obj.getShapeByY(e);break;default:var shape=null;}
46
- if(RG.isNull(obj.properties['chart.adjustable.only'])||typeof obj.properties['chart.adjustable.only']==='undefined'||(RG.isArray(obj.properties['chart.adjustable.only'])&&obj.isAdjustable&&obj.isAdjustable(shape))){RG.Registry.set('chart.adjusting.shape',shape);RG.fireCustomEvent(obj,'onadjustbegin');RG.Registry.set('chart.adjusting',obj);RG.clear(obj.canvas);RG.redraw();obj.canvas.rgraph_mousemove_event_listener(e);}}}
47
- RG.clear(obj.canvas);RG.redraw();}};obj.canvas.addEventListener('mousedown',obj.canvas.rgraph_mousedown_event_listener,false);}};RG.installCanvasClickListener=RG.InstallCanvasClickListener=function(obj)
48
- {if(!obj.canvas.rgraph_click_event_listener){obj.canvas.rgraph_click_event_listener=function(e)
49
- {if(navigator.userAgent.indexOf('Firefox')>=0)window.event=e;e=RG.fixEventObject(e);var objects=RG.ObjectRegistry.getObjectsByXY(e);for(var i=0,len=objects.length;i<len;i+=1){var obj=objects[i];var id=obj.id;var shape=obj.getShape(e);var func=obj.get('chart.events.click');if(!func&&typeof(obj.onclick)=='function'){func=obj.onclick;}
50
- if(shape&&typeof func=='function'){func(e,shape);if(typeof RG.events==='object'&&typeof RG.events[obj.uid]==='object'){for(i in RG.events[obj.uid]){if(typeof i==='string'&&typeof RG.events[obj.uid][i]==='object'&&RG.events[obj.uid][i][1]==='onclick'&&typeof RG.events[obj.uid][i][2]==='function'){(RG.events[obj.uid][i][2])(obj);}}}
51
- return;}
52
- var key=RG.Registry.get('key-element');if(key){RG.fireCustomEvent(obj,'onkeyclick');}
53
- if(shape){var index=shape['object'].type=='scatter'?shape['index_adjusted']:shape['index'];if(typeof(index)=='number'&&obj['$'+index]){var func=obj['$'+index].onclick;if(typeof(func)=='function'){func(e,shape);return;}}}
54
- if(shape||(obj.overChartArea&&obj.overChartArea(e))){break;}}};obj.canvas.addEventListener('click',obj.canvas.rgraph_click_event_listener,false);}};RG.evaluateCursor=RG.EvaluateCursor=function(e)
55
- {if(e.rgraph_evaluateCursor===false){return;}
56
- var obj=null;var mouseXY=RG.getMouseXY(e);var mouseX=mouseXY[0];var mouseY=mouseXY[1];var canvas=e.target;var objects=RG.OR.getObjectsByCanvasID(canvas.id);for(var i=0,len=objects.length;i<len;i+=1){if((objects[i].getShape&&objects[i].getShape(e))||(objects[i].overChartArea&&objects[i].overChartArea(e))){var obj=objects[i];var id=obj.id;}}
57
- if(!RG.isNull(obj)){if(obj.getShape&&obj.getShape(e)){var shape=obj.getShape(e);if(obj.get('chart.tooltips')){var text=RG.parseTooltipText(obj.get('chart.tooltips'),shape['index']);if(!text&&shape['object'].type=='scatter'&&shape['index_adjusted']){text=RG.parseTooltipText(obj.get('chart.tooltips'),shape['index_adjusted']);}
58
- if(text){var pointer=true;}}}
59
- if(!RG.isNull(obj)&&obj.get('chart.key.interactive')){for(var j=0;j<obj.coords.key.length;++j){if(mouseX>obj.coords.key[j][0]&&mouseX<(obj.coords.key[j][0]+obj.coords.key[j][2])&&mouseY>obj.coords.key[j][1]&&mouseY<(obj.coords.key[j][1]+obj.coords.key[j][3])){var pointer=true;}}}}
60
- if(RGraph.custom_events_mousemove_pointer){var pointer=true;RGraph.custom_events_mousemove_pointer=false;}
61
- var objects=RG.OR.objects.byCanvasID;for(var i=0,len=objects.length;i<len;i+=1){if(objects[i]&&objects[i][1].get('chart.resizable')){var resizable=true;}}
62
- if(resizable&&mouseX>(e.target.width-32)&&mouseY>(e.target.height-16)){pointer=true;}
63
- if(pointer){e.target.style.cursor='pointer';}else if(e.target.style.cursor=='pointer'){e.target.style.cursor='default';}else{e.target.style.cursor=null;}
64
- if(resizable&&mouseX>=(e.target.width-15)&&mouseY>=(e.target.height-15)){e.target.style.cursor='move';}else if(e.target.style.cursor==='move'){e.target.style.cursor='default';}
65
- if(typeof mouse_over_key=='boolean'&&mouse_over_key){e.target.style.cursor='pointer';}
66
- if(obj&&obj.type=='line'&&obj.get('chart.adjustable')){if(obj.getShape){var shape=obj.getShape(e);if(shape&&obj.isAdjustable(shape)){e.target.style.cursor='ns-resize';}}else{e.target.style.cursor='default';}}
67
- if(e.target.__object__&&e.target.__object__.get('chart.annotatable')){e.target.style.cursor='crosshair';}
68
- if(obj&&obj.type==='drawing.text'&&shape&&typeof obj.get('link')==='string'){e.target.style.cursor='pointer';}};RG.parseTooltipText=function(tooltips,idx)
69
- {if(!tooltips){return null;}
70
- if(typeof tooltips=='function'){var text=tooltips(idx);}else if(typeof tooltips=='string'){var text=tooltips;}else if(typeof tooltips=='object'&&typeof tooltips[idx]=='function'){var text=tooltips[idx](idx);}else if(typeof tooltips[idx]=='string'&&tooltips[idx]){var text=tooltips[idx];}else{var text='';}
71
- if(text=='undefined'){text='';}else if(text=='null'){text='';}
72
- return RG.getTooltipTextFromDIV?RG.getTooltipTextFromDIV(text):text;};RG.drawCrosshairs=RG.DrawCrosshairs=function(e,obj)
73
- {var e=RG.fixEventObject(e),width=obj.canvas.width,height=obj.canvas.height,mouseXY=RG.getMouseXY(e),x=mouseXY[0],y=mouseXY[1],marginLeft=obj.marginLeft,marginRight=obj.marginRight,marginTop=obj.marginTop,marginBottom=obj.marginBottom,Mathround=Math.round,prop=obj.properties,co=obj.context,ca=obj.canvas
74
- RG.redrawCanvas(ca);if(x>=marginLeft&&y>=marginTop&&x<=(width-marginRight)&&y<=(height-marginBottom)){var linewidth=prop['chart.crosshairs.linewidth']?prop['chart.crosshairs.linewidth']:1;co.lineWidth=linewidth?linewidth:1;co.beginPath();co.strokeStyle=prop['chart.crosshairs.color'];if(prop['chart.crosshairs.snap']){var point=null;var dist=null;var len=null;if(obj.type=='line'){for(var i=0;i<obj.coords.length;++i){var length=RG.getHypLength(obj.coords[i][0],obj.coords[i][1],x,y);if(typeof dist!='number'||length<dist){var point=i;var dist=length;}}
75
- x=obj.coords[point][0];y=obj.coords[point][1];for(var dataset=0;dataset<obj.coords2.length;++dataset){for(var point=0;point<obj.coords2[dataset].length;++point){if(obj.coords2[dataset][point][0]==x&&obj.coords2[dataset][point][1]==y){ca.__crosshairs_snap_dataset__=dataset;ca.__crosshairs_snap_point__=point;}}}}else{for(var i=0;i<obj.coords.length;++i){for(var j=0;j<obj.coords[i].length;++j){var len=RG.getHypLength(obj.coords[i][j][0],obj.coords[i][j][1],x,y);if(typeof(dist)!='number'||len<dist){var dataset=i;var point=j;var dist=len;}}}
76
- ca.__crosshairs_snap_dataset__=dataset;ca.__crosshairs_snap_point__=point;x=obj.coords[dataset][point][0];y=obj.coords[dataset][point][1];}}
77
- if(prop['chart.crosshairs.vline']){co.moveTo(Mathround(x),Mathround(marginTop));co.lineTo(Mathround(x),Mathround(height-marginBottom));}
78
- if(prop['chart.crosshairs.hline']){co.moveTo(Mathround(marginLeft),Mathround(y));co.lineTo(Mathround(width-marginRight),Mathround(y));}
79
- co.stroke();if(obj.type=='scatter'&&prop['chart.crosshairs.coords']){var xCoord=(((x-marginLeft)/(width-marginLeft-marginRight))*(prop['chart.xaxis.scale.max']-prop['chart.xaxis.scale.min']))+prop['chart.xaxis.scale.min'];xCoord=xCoord.toFixed(prop['chart.yaxis.scale.decimals']);var yCoord=obj.max-(((y-prop['chart.margin.top'])/(height-marginTop-marginBottom))*obj.max);if(obj.type=='scatter'&&obj.properties['chart.xaxis.position']=='center'){yCoord=(yCoord-(obj.max/2))*2;}
80
- yCoord=yCoord.toFixed(prop['chart.yaxis.scale.decimals']);var div=RG.Registry.get('chart.coordinates.coords.div');var mouseXY=RG.getMouseXY(e);var canvasXY=RG.getCanvasXY(ca);if(!div){var div=document.createElement('DIV');div.__object__=obj;div.style.position='absolute';div.style.backgroundColor='white';div.style.border='1px solid black';div.style.fontFamily='Arial, Verdana, sans-serif';div.style.fontSize='10pt'
81
- div.style.padding='2px';div.style.opacity=1;div.style.WebkitBorderRadius='3px';div.style.borderRadius='3px';div.style.MozBorderRadius='3px';document.body.appendChild(div);RG.Registry.set('chart.coordinates.coords.div',div);}
82
- div.style.opacity=1;div.style.display='inline';if(!prop['chart.crosshairs.coords.fixed']){div.style.left=ma.max(2,(e.pageX-div.offsetWidth-3))+'px';div.style.top=ma.max(2,(e.pageY-div.offsetHeight-3))+'px';}else{div.style.left=canvasXY[0]+marginLeft+3+'px';div.style.top=canvasXY[1]+marginTop+3+'px';}
83
- if(typeof prop['chart.crosshairs.coords.formatter.x']==='function'){xCoord=(prop['chart.crosshairs.coords.formatter.x'])({object:obj,value:parseInt(xCoord)});}
84
- if(typeof prop['chart.crosshairs.coords.formatter.y']==='function'){yCoord=(prop['chart.crosshairs.coords.formatter.y'])({object:obj,value:parseInt(yCoord)});}
85
- div.innerHTML='<span style="color: #666">'+prop['chart.crosshairs.coords.labels.x']+':</span> '+xCoord+'<br><span style="color: #666">'+prop['chart.crosshairs.coords.labels.y']+':</span> '+yCoord;obj.canvas.addEventListener('mouseout',RG.hideCrosshairCoords,false);ca.__crosshairs_labels__=div;ca.__crosshairs_x__=xCoord;ca.__crosshairs_y__=yCoord;}else if(prop['chart.crosshairs.coords']){alert('[RGRAPH] Showing crosshair coordinates is only supported on the Scatter chart');}
86
- RG.fireCustomEvent(obj,'oncrosshairs');}else{RG.hideCrosshairCoords();}};RG.allowSegmentHighlight=function(opt)
87
- {var obj=opt.object,count=opt.count,fill=opt.fill,stroke=opt.stroke
88
- if(!RG.segmentHighlightFunction){RG.segmentHighlightFunction=function(e)
89
- {var mouseXY=RG.getMouseXY(e);var angle=RG.getAngleByXY(obj.centerx,obj.centery,mouseXY[0],mouseXY[1]);angle+=RG.HALFPI;if(angle>RG.TWOPI){angle-=RG.TWOPI;}
90
- RG.redraw();var start=0;var end=0;var a=(ma.PI*2)/count;var r=obj.radius;(function()
91
- {for(i=0;i<count;i+=1){if(angle<(a*(i+1))){start=i*a;end=(i+1)*a;return;}}})();start-=RG.HALFPI;end-=RG.HALFPI;RG.path2(obj.context,'b m % % a % % % % % false c s % f %',obj.centerx,obj.centery,obj.centerx,obj.centery,r,start,end,stroke,fill);};obj.canvas.addEventListener('mousemove',RG.segmentHighlightFunction,false);}}})(window,document);
12
+ //
13
+ // Initialise the various objects
14
+ //
15
+ RGraph = window.RGraph || {isrgraph:true,isRGraph: true,rgraph:true};
16
+
17
+ // Module pattern
18
+ (function (win, doc, undefined)
19
+ {
20
+ var ua = navigator.userAgent;
21
+
22
+ //
23
+ // This is the window click event listener. It redraws all canvas tags on the page.
24
+ //
25
+ RGraph.installWindowMousedownListener = function (obj)
26
+ {
27
+ if (!RGraph.window_mousedown_event_listener) {
28
+
29
+ RGraph.window_mousedown_event_listener = function (e)
30
+ {
31
+ //
32
+ // For firefox add the window.event object
33
+ //
34
+ if (navigator.userAgent.indexOf('Firefox') >= 0) win.event = e;
35
+
36
+ var tooltip = RGraph.Registry.get('tooltip');
37
+
38
+ if ( RGraph.hideTooltip
39
+ && tooltip
40
+ && tooltip.__object__.get('tooltipsEffect') !== 'slide'
41
+ ) {
42
+ RGraph.clear(RGraph.Registry.get('tooltip').__canvas__);
43
+ RGraph.redraw();
44
+ RGraph.hideTooltip();
45
+ }
46
+ };
47
+ win.addEventListener('mousedown', RGraph.window_mousedown_event_listener, false);
48
+ }
49
+ };
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+ //
59
+ // This is the window click event listener. It redraws all canvas tags on the page.
60
+ //
61
+ RGraph.installWindowMouseupListener = function (obj)
62
+ {
63
+ if (!RGraph.window_mouseup_event_listener) {
64
+ RGraph.window_mouseup_event_listener = function (e)
65
+ {
66
+ //
67
+ // For firefox add the window.event object
68
+ //
69
+ if (navigator.userAgent.indexOf('Firefox') >= 0) win.event = e;
70
+
71
+ //
72
+ // Stop any annotating that may be going on
73
+ //
74
+ if (RGraph.annotating_window_onmouseup) {
75
+ RGraph.annotating_window_onmouseup(e);
76
+ return;
77
+ }
78
+
79
+ //
80
+ // End adjusting
81
+ //
82
+ if (RGraph.Registry.get('adjusting') || RGraph.Registry.get('adjusting.gantt')) {
83
+
84
+ var obj = RGraph.Registry.get('adjusting');
85
+
86
+ // If it's a line chart update the data_arr variable
87
+ if (obj && obj.type === 'line') {
88
+ obj.data_arr = RGraph.arrayLinearize(obj.data);
89
+ }
90
+
91
+ RGraph.fireCustomEvent(RGraph.Registry.get('adjusting'), 'onadjustend');
92
+ }
93
+
94
+ RGraph.Registry.set('adjusting', null);
95
+ RGraph.Registry.set('adjusting.shape', null);
96
+ RGraph.Registry.set('adjusting.gantt', null);
97
+
98
+
99
+ // ==============================================
100
+ // Finally, redraw the chart
101
+ // ==============================================
102
+
103
+ var tags = document.getElementsByTagName('canvas');
104
+ for (var i=0; i<tags.length; ++i) {
105
+ if (tags[i].__object__ && tags[i].__object__.isRGraph) {
106
+ if (!tags[i].__object__.get('annotatable')) {
107
+ if (!tags[i].__rgraph_trace_cover__ && !noredraw) {
108
+ RGraph.clear(tags[i]);
109
+ } else {
110
+ var noredraw = true;
111
+ }
112
+ }
113
+ }
114
+ }
115
+
116
+ if (!noredraw) {
117
+ RGraph.redraw();
118
+ }
119
+ };
120
+ win.addEventListener('mouseup', RGraph.window_mouseup_event_listener, false);
121
+ }
122
+ };
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+ //
132
+ // This is the canvas mouseup event listener. It installs the
133
+ // mouseup event for the canvas. The mouseup event then checks
134
+ // the relevant object.
135
+ //
136
+ // @param object obj The chart object
137
+ //
138
+ RGraph.installCanvasMouseupListener = function (obj)
139
+ {
140
+ if (!obj.canvas.rgraph_mouseup_event_listener) {
141
+ obj.canvas.rgraph_mouseup_event_listener = function (e)
142
+ {
143
+
144
+ //
145
+ // For firefox add the window.event object
146
+ //
147
+ if (navigator.userAgent.indexOf('Firefox') >= 0) window.event = e;
148
+
149
+ // *************************************************************************
150
+ // Tooltips
151
+ // *************************************************************************
152
+
153
+
154
+ // This causes things at the edge of the chart area - eg line chart hotspots - not to fire because the
155
+ // cursor is out of the chart area
156
+ var objects = RGraph.ObjectRegistry.getObjectsByXY(e);
157
+ //var objects = RGraph.ObjectRegistry.getObjectsByCanvasID(e.target.id);
158
+
159
+
160
+ if (objects) {
161
+
162
+ for (var i=0,len=objects.length; i<len; i+=1) {
163
+
164
+ var obj = objects[i],
165
+ id = objects[i].id;
166
+
167
+
168
+ // =========================================================================
169
+ // The drawing API text object supports the link configuration property
170
+ // ========================================================================
171
+ var link = obj.get('link');
172
+
173
+ if (obj.type == 'drawing.text' && typeof link === 'string') {
174
+
175
+ var link_target = obj.get('linkTarget');
176
+ var link_options = obj.get('linkOptions');
177
+
178
+ window.open(link, link_target ? link_target : null, link_options);
179
+ }
180
+
181
+
182
+ // ========================================================================
183
+ // Tooltips
184
+ // ========================================================================
185
+
186
+
187
+ if (!RGraph.isNull(obj) && RGraph.tooltip) {
188
+
189
+ var shape = obj.getShape(e);
190
+
191
+ if (shape && shape.tooltip) {
192
+
193
+ var text = shape.tooltip;
194
+
195
+ if (text) {
196
+
197
+ var type = shape.object.type;
198
+
199
+ RGraph.clear(obj.canvas);
200
+ RGraph.redraw();
201
+ RGraph.Registry.set('tooltip.shape', shape);
202
+
203
+ // Note that tooltips are positioned at the pointer
204
+ // now; and thats done within the .tooltip() function
205
+
206
+ RGraph.tooltip(
207
+ obj,
208
+ text,
209
+ 0,
210
+ 0,
211
+ shape.sequentialIndex,
212
+ e
213
+ );
214
+
215
+ obj.highlight(shape);
216
+
217
+ // Add the shape that triggered the tooltip
218
+ if (RGraph.Registry.get('tooltip')) {
219
+
220
+ RGraph.Registry.get('tooltip').__shape__ = shape;
221
+
222
+ RGraph.evaluateCursor(e);
223
+ }
224
+
225
+ e.cancelBubble = true;
226
+ e.stopPropagation();
227
+ return false;
228
+ }
229
+ }
230
+ }
231
+
232
+
233
+
234
+
235
+
236
+ // =========================================================================
237
+ // Adjusting
238
+ // ========================================================================
239
+
240
+
241
+
242
+ if (RGraph.Registry.get('adjusting') || RGraph.Registry.get('adjusting.gantt')) {
243
+
244
+ //var obj = RGraph.Registry.get('adjusting');
245
+
246
+ // If it's a line chart update the data_arr variable
247
+ if (obj && obj.type === 'line') {
248
+ obj.data_arr = RGraph.arrayLinearize(obj.data);
249
+ }
250
+
251
+ RGraph.fireCustomEvent(RGraph.Registry.get('adjusting'), 'onadjustend');
252
+ }
253
+
254
+ RGraph.Registry.set('adjusting', null);
255
+ RGraph.Registry.set('adjusting.shape', null);
256
+ RGraph.Registry.set('adjusting.gantt', null);
257
+
258
+ //
259
+ // If the mouse pointer is over a "front" chart this prevents charts behind it
260
+ // from firing their events.
261
+ //
262
+ if (shape || (obj.overChartArea && obj.overChartArea(e)) ) {
263
+ break;
264
+ }
265
+ }
266
+ }
267
+ };
268
+ obj.canvas.addEventListener('mouseup', obj.canvas.rgraph_mouseup_event_listener, false);
269
+ }
270
+ };
271
+
272
+
273
+
274
+
275
+
276
+
277
+
278
+
279
+ //
280
+ // This is the canvas mousemove event listener.
281
+ //
282
+ // @param object obj The chart object
283
+ //
284
+ RGraph.installCanvasMousemoveListener = function (obj)
285
+ {
286
+ if (!obj.canvas.rgraph_mousemove_event_listener) {
287
+ obj.canvas.rgraph_mousemove_event_listener = function (e)
288
+ {
289
+ //
290
+ // For firefox add the window.event object
291
+ //
292
+ if (navigator.userAgent.indexOf('Firefox') >= 0) window.event = e;
293
+
294
+
295
+
296
+
297
+ //
298
+ // Go through all the objects and check them to see if anything needs doing
299
+ //
300
+ var objects = RGraph.OR.getObjectsByXY(e);
301
+
302
+ // Necessary to track which objects have had the mouseover
303
+ // triggered on them
304
+ var uids = [];
305
+
306
+ if (objects && objects.length > 0) {
307
+
308
+ for (var i=0,len=objects.length; i<len; i+=1) {
309
+
310
+ var obj = objects[i];
311
+ var id = obj.id;
312
+
313
+
314
+ // Record the uid
315
+ uids[obj.uid] = true;
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
+ // This bit facilitates the dataset highlighting //
343
+ ///////////////////////////////////////////////////
344
+ if (obj && obj.properties.highlightDataset && obj.properties.highlightDatasetEvent === 'mousemove') {
345
+
346
+ var [x, y] = RGraph.getMouseXY(e);
347
+ var shape = obj.over(x, y);
348
+ var excludedNumber = RGraph.isNumber(obj.properties.highlightDatasetExclude) && shape && obj.properties.highlightDatasetExclude === shape.dataset;
349
+ var excludedArray = RGraph.isArray(obj.properties.highlightDatasetExclude) && shape && obj.properties.highlightDatasetExclude.includes(shape.dataset);
350
+
351
+ if (shape && !excludedNumber && !excludedArray) {
352
+
353
+ // Store the index that's highlighted on the canvas if
354
+ // it's different to what's previously been stored.
355
+ if (shape.dataset !== obj.canvas.rgraph_highlightDataset_dataset) {
356
+
357
+ RGraph.redrawCanvas(obj.canvas);
358
+
359
+ obj.canvas.rgraph_highlightDataset_dataset = shape.dataset;
360
+
361
+ obj.highlightDataset({
362
+ dataset: shape.dataset,
363
+ fill: obj.properties.highlightDatasetFill,
364
+ stroke: obj.properties.highlightDatasetStroke,
365
+ linewidth: obj.properties.highlightDatasetLinewidth,
366
+ linedash: obj.properties.highlightDatasetDashArray,
367
+ dotted: obj.properties.highlightDatasetDotted,
368
+ dashed: obj.properties.highlightDatasetDashed
369
+ });
370
+
371
+ // Call the callback if specified
372
+ if (RGraph.isFunction (obj.properties.highlightDatasetCallback)) {
373
+
374
+ obj.properties.highlightDatasetCallback({
375
+ dataset: shape.dataset,
376
+ object: obj
377
+ });
378
+ }
379
+ }
380
+
381
+
382
+ } else {
383
+ obj.canvas.rgraph_highlightDataset_dataset = null;
384
+ RGraph.redraw();
385
+ }
386
+ }
387
+
388
+
389
+
390
+
391
+
392
+
393
+
394
+
395
+
396
+
397
+
398
+
399
+
400
+
401
+ if (!obj.getShape) {
402
+ continue;
403
+ }
404
+
405
+
406
+ var shape = obj.getShape(e);
407
+
408
+ // If the object has changed (based on the UID) then
409
+ // fire the prior objects mouseout event
410
+ if (RGraph.last_mouseover_uid && RGraph.last_mouseover_uid !== obj.uid) {
411
+
412
+ RGraph.fireCustomEvent(RGraph.last_mouseover_object, 'onmouseout');
413
+
414
+ RGraph.last_mouseover_object.__mouseover_shape_index__ = null;
415
+ RGraph.last_mouseover_object.__mouseover_shape__ = null;
416
+ RGraph.last_mouseover_object = null;
417
+ RGraph.last_mouseover_uid = null;
418
+ }
419
+
420
+ // Fire the onmouseout event if necessary
421
+ if (
422
+ (!shape && typeof obj.__mouseover_shape_index__ === 'number')
423
+ || (shape && typeof obj.__mouseover_shape_index__ === 'number' && shape.index !== obj.__mouseover_shape_index__)
424
+
425
+ ) {
426
+
427
+ RGraph.fireCustomEvent(obj, 'onmouseout');
428
+ }
429
+
430
+
431
+
432
+
433
+
434
+
435
+
436
+ //
437
+ // If the mouse is over a key element add the details
438
+ // of it to the Registry
439
+ //
440
+ if (obj.coords && obj.coords.key && obj.coords.key.length) {
441
+
442
+ var mouseXY = RGraph.getMouseXY(e);
443
+
444
+ for (var i=0,overkey=false; i<obj.coords.key.length; ++i) {
445
+
446
+ if (
447
+ mouseXY[0] >= obj.coords.key[i][0]
448
+ && mouseXY[0] <= (obj.coords.key[i][0] + obj.coords.key[i][2])
449
+ && mouseXY[1] >= obj.coords.key[i][1]
450
+ && mouseXY[1] <= (obj.coords.key[i][1] + obj.coords.key[i][3])
451
+ ) {
452
+
453
+ RGraph.Registry.set('key-element', obj.coords.key[i]);
454
+ overkey = true;
455
+ }
456
+
457
+ if (!overkey) {
458
+ RGraph.Registry.set('key-element', null);
459
+ }
460
+ }
461
+ }
462
+
463
+
464
+
465
+
466
+
467
+
468
+
469
+
470
+
471
+
472
+
473
+
474
+
475
+
476
+ // ================================================================================================ //
477
+ // This facilitates the onmousemove facility
478
+ // ================================================================================================ //
479
+
480
+ var func = null;
481
+ if (!func && typeof obj.onmousemove == 'function') {
482
+ var func = obj.onmousemove;
483
+ }
484
+
485
+ //
486
+ //
487
+ //
488
+ if (shape) {
489
+
490
+ var index = shape.sequentialIndex;
491
+
492
+ if (typeof obj['$' + index] === 'object' && typeof obj['$' + index].onmousemove == 'function') {
493
+ var func2 = obj['$' + index].onmousemove;
494
+ }
495
+ }
496
+
497
+ //
498
+ // This bit saves the current pointer style if there isn't one already saved
499
+ //
500
+ if (shape && (typeof func == 'function' || typeof func2 == 'function' || typeof obj.get('link') === 'string')) {
501
+
502
+ if (obj.get('eventsMousemoveRevertto') == null) {
503
+ obj.set('eventsMousemoveRevertto', e.target.style.cursor);
504
+ }
505
+
506
+ if (typeof func == 'function') RGraph.custom_events_mousemove_pointer = func(e, shape);
507
+ if (typeof func2 == 'function') RGraph.custom_events_mousemove_pointer = RGraph.custom_events_mousemove_pointer || func2(e, shape);
508
+
509
+ // Go through the RGraph.events array looking for more
510
+ // event listeners
511
+ if ( typeof RGraph.events === 'object'
512
+ && typeof RGraph.events[obj.uid] === 'object') {
513
+
514
+ for (i in RGraph.events[obj.uid]) {
515
+
516
+ if ( typeof i === 'string'
517
+ && typeof RGraph.events[obj.uid][i] === 'object'
518
+ && RGraph.events[obj.uid][i][1] === 'onmousemove'
519
+ && typeof RGraph.events[obj.uid][i][2] === 'function') {
520
+
521
+ (RGraph.events[obj.uid][i][2])(obj);
522
+ }
523
+ }
524
+ }
525
+ //return;
526
+
527
+ } else if (typeof obj.get('eventsMousemoveRevertto') == 'string') {
528
+
529
+ RGraph.cursor.push('default');
530
+ obj.set('eventsMousemoveRevertto', null);
531
+ }
532
+
533
+
534
+
535
+
536
+
537
+
538
+
539
+
540
+
541
+
542
+
543
+
544
+
545
+
546
+
547
+
548
+
549
+
550
+
551
+
552
+
553
+ // ======================================================
554
+ // This bit of code facilitates the onmouseover event
555
+ // ======================================================
556
+
557
+
558
+
559
+ var func = null;
560
+
561
+ if (!func && typeof obj.onmouseover === 'function') {
562
+ func = obj.onmouseover;
563
+ }
564
+
565
+
566
+ // Allow for individually index functions to be specified
567
+ if (shape) {
568
+
569
+ var index = shape.sequentialIndex;
570
+
571
+ if (typeof obj['$' + index] == 'object' && typeof obj['$' + index].onmouseover == 'function') {
572
+ var func2 = obj['$' + index].onmouseover;
573
+ }
574
+ } else {
575
+
576
+ obj.__mouseover_shape_index__ = null;
577
+ RGraph.__mouseover_objects__ = [];
578
+ RGraph.last_mouseover_uid = null;
579
+ RGraph.last_mouseover_object = null;
580
+ }
581
+
582
+ if (typeof RGraph.__mouseover_objects__ === 'undefined') {
583
+ RGraph.__mouseover_objects__ = [];
584
+ RGraph.last_mouseover_uid = null;
585
+ RGraph.last_mouseover_object = null;
586
+ }
587
+
588
+
589
+ if (shape) {
590
+ if ((obj.__mouseover_shape_index__ === shape.index) === false) {
591
+
592
+ obj.__mouseover_shape__ = shape;
593
+ obj.__mouseover_shape_index__ = shape.index;
594
+ RGraph.last_mouseover_uid = obj.uid;
595
+ RGraph.last_mouseover_object = obj;
596
+ RGraph.__mouseover_objects__.push(obj);
597
+
598
+ if (func) func(e, shape);
599
+ if (func2) func2(e, shape);
600
+
601
+ // Go through the RGraph.events array looking for more
602
+ // event listeners
603
+ if ( typeof RGraph.events === 'object'
604
+ && typeof RGraph.events[obj.uid] === 'object') {
605
+
606
+ for (i in RGraph.events[obj.uid]) {
607
+
608
+ if ( typeof i === 'string'
609
+ && typeof RGraph.events[obj.uid][i] === 'object'
610
+ && RGraph.events[obj.uid][i][1] === 'onmouseover'
611
+ && typeof RGraph.events[obj.uid][i][2] === 'function') {
612
+
613
+ (RGraph.events[obj.uid][i][2])(obj);
614
+ }
615
+ }
616
+ }
617
+ }
618
+ } else {
619
+ obj.__mouseover_shape_index__ = null;
620
+ RGraph.__mouseover_objects__ = [];
621
+ RGraph.last_mouseover_uid = null;
622
+ RGraph.last_mouseover_object = null;
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
+ // Tooltips
649
+ // ================================================================================================ //
650
+ var current_tooltip = RGraph.Registry.get('tooltip');
651
+ var tooltips = obj.get('tooltips');
652
+ var tooltips_event = obj.get('tooltipsEvent');
653
+
654
+
655
+ if ( shape
656
+ && (tooltips && tooltips[shape.index] || shape.tooltip)
657
+ && tooltips_event.indexOf('mousemove') !== -1
658
+ && ( RGraph.isNull(current_tooltip) // Is there a tooltip being shown?
659
+ || obj.uid != current_tooltip.__object__.uid // Same object?
660
+ || (current_tooltip.__index__ != shape.sequentialIndex) // Same datapiece index? [UPDATE ON 29/10/2019 TO TRY AND MATCH THE sequentialIndex]
661
+ || (typeof shape.dataset === 'number' && shape.dataset != current_tooltip.__shape__.dataset) // Different dataset index
662
+ )
663
+ ) {
664
+
665
+ RGraph.clear(obj.canvas);
666
+ RGraph.hideTooltip();
667
+ RGraph.redraw();
668
+ obj.canvas.rgraph_mouseup_event_listener(e);
669
+
670
+ return;
671
+ }
672
+
673
+
674
+ // ================================================================================================ //
675
+ // Adjusting
676
+ // ================================================================================================ //
677
+
678
+
679
+ if (obj && obj.get('adjustable')) {
680
+ obj.adjusting_mousemove(e);
681
+ }
682
+
683
+
684
+ //
685
+ // This facilitates breaking out of the loop when a shape has been found -
686
+ // ie the cursor is over a shape an upper chart
687
+ //
688
+ if (shape || (obj.overChartArea && obj.overChartArea(e) )) {
689
+ break;
690
+ }
691
+ }
692
+
693
+ //
694
+ // For all objects that are NOT mouseover'ed, reset the
695
+ // mouseover flag back to null
696
+ //
697
+ var objects = RGraph.OR.getObjectsByCanvasID(e.target.id);
698
+
699
+ for (var i=0; i<objects.length; ++i) {
700
+ if (!uids[objects[i].uid]) {
701
+ objects[i].__mouseover_shape_index__ = null;
702
+ }
703
+ }
704
+
705
+ } else {
706
+
707
+ // Reset the mouseover flag on all of this canvas tags objects
708
+ var objects = RGraph.OR.getObjectsByCanvasID(e.target.id);
709
+
710
+ for (var i=0; i<objects.length; i++) {
711
+ if (typeof objects[i].__mouseover_shape_index__ === 'number') {
712
+ RGraph.fireCustomEvent(objects[i], 'onmouseout');
713
+ }
714
+
715
+ objects[i].__mouseover_shape_index__ = null;
716
+ }
717
+
718
+ RGraph.__mouseover_objects__ = [];
719
+ RGraph.last_mouseover_uid = null;
720
+ RGraph.last_mouseover_object = null;
721
+ }
722
+
723
+
724
+
725
+
726
+
727
+
728
+
729
+ // ================================================================================================ //
730
+ // Crosshairs
731
+ // ================================================================================================ //
732
+
733
+
734
+ if (e.target && e.target.__object__ && e.target.__object__.get('crosshairs')) {
735
+ RGraph.drawCrosshairs(e, e.target.__object__);
736
+ }
737
+
738
+
739
+ // ================================================================================================ //
740
+ // Interactive key No LONGER REQUIRED
741
+ // ================================================================================================ //
742
+
743
+
744
+ //if (typeof InteractiveKey_line_mousemove == 'function') InteractiveKey_line_mousemove(e);
745
+ //if (typeof InteractiveKey_pie_mousemove == 'function') InteractiveKey_pie_mousemove(e);
746
+
747
+
748
+ // ================================================================================================ //
749
+ // Annotating
750
+ // ================================================================================================ //
751
+
752
+
753
+ if (e.target.__object__ && e.target.__object__.get('annotatable') && RGraph.annotating_canvas_onmousemove) {
754
+ RGraph.annotating_canvas_onmousemove(e);
755
+ }
756
+
757
+
758
+
759
+ //
760
+ // Determine the pointer
761
+ //
762
+ RGraph.evaluateCursor(e);
763
+ };
764
+ obj.canvas.addEventListener('mousemove', obj.canvas.rgraph_mousemove_event_listener, false);
765
+ }
766
+ };
767
+
768
+
769
+
770
+
771
+
772
+
773
+
774
+
775
+ //
776
+ // This is the canvas mousedown event listener.
777
+ //
778
+ // @param object obj The chart object
779
+ //
780
+ RGraph.installCanvasMousedownListener = function (obj)
781
+ {
782
+ if (!obj.canvas.rgraph_mousedown_event_listener) {
783
+ obj.canvas.rgraph_mousedown_event_listener = function (e)
784
+ {
785
+ //
786
+ // For firefox add the window.event object
787
+ //
788
+ if (navigator.userAgent.indexOf('Firefox') >= 0) window.event = e;
789
+
790
+
791
+ //
792
+ // Annotating
793
+ //
794
+ if (e.target.__object__ && e.target.__object__.get('annotatable') && RGraph.annotating_canvas_onmousedown) {
795
+ RGraph.annotating_canvas_onmousedown(e);
796
+ return;
797
+ }
798
+
799
+ var obj = RGraph.ObjectRegistry.getObjectByXY(e);
800
+
801
+ if (obj) {
802
+
803
+
804
+ var id = obj.id;
805
+
806
+
807
+
808
+
809
+ //
810
+ // Handle adjusting for all object types
811
+ //
812
+ if (obj && obj.isRGraph && obj.get('adjustable')) {
813
+ //
814
+ // Check the cursor is in the correct area
815
+ //
816
+ var obj = RGraph.OR.getObjectByXY(e);
817
+
818
+ if (obj && obj.isRGraph) {
819
+
820
+ // If applicable, get the appropriate shape and store it in the registry
821
+ switch (obj.type) {
822
+ case 'bar': var shape = obj.getShapeByX(e); break;
823
+ case 'gantt':
824
+
825
+ var shape = obj.getShape(e);
826
+
827
+ if (shape) {
828
+
829
+ var data = typeof obj.data[shape.dataset] === 'object'
830
+ && obj.data[shape.dataset][shape.index]
831
+ && obj.data[shape.dataset][shape.index].start
832
+ ?
833
+ obj.data[shape.dataset][shape.index] :
834
+ obj.data[shape.dataset];
835
+
836
+ var mouseXY = RGraph.getMouseXY(e);
837
+
838
+ RGraph.Registry.set('adjusting.gantt', {
839
+ dataset: shape.dataset,
840
+ index: shape.index,
841
+ object: obj,
842
+ mousex: mouseXY[0],
843
+ mousey: mouseXY[1],
844
+ event: data,
845
+ event_start: data.start,
846
+ event_duration: data.duration,
847
+ mode: (mouseXY[0] > (shape.x + shape.width - 5) ? 'resize' : 'move'),
848
+ shape: shape
849
+ });
850
+ }
851
+ break;
852
+ case 'line': var shape = obj.getShape(e); break;
853
+ case 'scatter': var shape = obj.getShape(e); break;
854
+ case 'hbar': var shape = obj.getShapeByY(e); break;
855
+ case 'activity': var shape = obj.getShape(e); break;
856
+ default: var shape = null;
857
+ }
858
+
859
+ // Facilitate one click adjusting on the lline chart
860
+ if (obj.type === 'line' && obj.properties.adjustableXonly) {
861
+ var shape = obj.getShapeByX(e);
862
+ }
863
+
864
+ //
865
+ // Added 30/9/2016
866
+ // Now check the index in the adjustingOnly property
867
+ // If that property is an object and the appropriate index is
868
+ // truthy then allow adjusting, otherwise don't.
869
+ //
870
+ if (
871
+ RGraph.isNull(obj.properties.adjustableOnly)
872
+ || typeof obj.properties.adjustableOnly === 'undefined'
873
+ ||
874
+ (
875
+ RGraph.isArray(obj.properties.adjustableOnly)
876
+ && obj.isAdjustable
877
+ && obj.isAdjustable(shape)
878
+ )
879
+ ) {
880
+
881
+ RGraph.Registry.set('adjusting.shape', shape);
882
+
883
+
884
+ // Fire the onadjustbegin event
885
+ RGraph.fireCustomEvent(obj, 'onadjustbegin');
886
+
887
+ RGraph.Registry.set('adjusting', obj);
888
+
889
+
890
+ // Liberally redraw the canvas
891
+ RGraph.clear(obj.canvas);
892
+ RGraph.redraw();
893
+
894
+ // Call the mousemove event listener so that the canvas
895
+ // is adjusted even though the mouse isn't moved
896
+ obj.canvas.rgraph_mousemove_event_listener(e);
897
+ }
898
+ }
899
+ }
900
+
901
+ if (obj.properties.tooltipsEffect !== 'slide') {
902
+ RGraph.clear(obj.canvas);
903
+ RGraph.redraw();
904
+ }
905
+ }
906
+ };
907
+ obj.canvas.addEventListener('mousedown', obj.canvas.rgraph_mousedown_event_listener, false);
908
+ }
909
+ };
910
+
911
+
912
+
913
+
914
+
915
+
916
+
917
+
918
+ //
919
+ // This is the canvas click event listener. Used by the pseudo event listener
920
+ //
921
+ // @param object obj The chart object
922
+ //
923
+ RGraph.installCanvasClickListener = function (obj)
924
+ {
925
+ if (!obj.canvas.rgraph_click_event_listener) {
926
+ obj.canvas.rgraph_click_event_listener = function (e)
927
+ {
928
+ //
929
+ // For firefox add the window.event object
930
+ //
931
+ if (navigator.userAgent.indexOf('Firefox') >= 0) window.event = e;
932
+
933
+ var objects = RGraph.ObjectRegistry.getObjectsByXY(e);
934
+
935
+ for (var i=0,len=objects.length; i<len; i+=1) {
936
+
937
+ var obj = objects[i];
938
+ var id = obj.id;
939
+ var shape = obj.getShape(e);
940
+
941
+
942
+
943
+
944
+
945
+ ///////////////////////////////////////////////////
946
+ // This bit facilitates the dataset highlighting //
947
+ ///////////////////////////////////////////////////
948
+ if (obj && obj.properties.highlightDataset && obj.properties.highlightDatasetEvent === 'click') {
949
+
950
+ var [x, y] = RGraph.getMouseXY(e);
951
+ var shape = obj.over(x, y);
952
+ var excludedNumber = RGraph.isNumber(obj.properties.highlightDatasetExclude) && shape && obj.properties.highlightDatasetExclude === shape.dataset;
953
+ var excludedArray = RGraph.isArray(obj.properties.highlightDatasetExclude) && shape && obj.properties.highlightDatasetExclude.includes(shape.dataset);
954
+
955
+ if (shape && !excludedNumber && !excludedArray) {
956
+ obj.highlightDataset({
957
+ dataset: shape.dataset,
958
+ fill: obj.properties.highlightDatasetFill,
959
+ stroke: obj.properties.highlightDatasetStroke,
960
+ linewidth: obj.properties.highlightDatasetLinewidth,
961
+ linedash: obj.properties.highlightDatasetDashArray,
962
+ dotted: obj.properties.highlightDatasetDotted,
963
+ dashed: obj.properties.highlightDatasetDashed
964
+ });
965
+
966
+ // Call the callback if specified
967
+ if (RGraph.isFunction (obj.properties.highlightDatasetCallback)) {
968
+ obj.properties.highlightDatasetCallback({
969
+ dataset: shape.dataset,
970
+ object: obj
971
+ });
972
+ }
973
+ }
974
+ }
975
+
976
+
977
+
978
+
979
+
980
+
981
+
982
+
983
+
984
+
985
+
986
+
987
+ //
988
+ // This bit saves the current pointer style
989
+ // if there isn't one already saved
990
+ //
991
+ var func = null;
992
+ if (!func && typeof obj.onclick == 'function') {
993
+ func = obj.onclick;
994
+ }
995
+
996
+ if (shape && typeof func == 'function') {
997
+
998
+ func(e, shape);
999
+
1000
+ // Go through the RGraph.events array looking for more
1001
+ // event listeners
1002
+
1003
+ if ( typeof RGraph.events === 'object'
1004
+ && typeof RGraph.events[obj.uid] === 'object') {
1005
+
1006
+ for (i in RGraph.events[obj.uid]) {
1007
+
1008
+ if ( typeof i === 'string'
1009
+ && typeof RGraph.events[obj.uid][i] === 'object'
1010
+ && RGraph.events[obj.uid][i][1] === 'onclick'
1011
+ && typeof RGraph.events[obj.uid][i][2] === 'function') {
1012
+
1013
+ (RGraph.events[obj.uid][i][2])(obj);
1014
+ }
1015
+ }
1016
+ }
1017
+
1018
+ //
1019
+ // If objects are layered on top of each other this return
1020
+ // stops objects underneath from firing once the "top"
1021
+ // objects user event has fired
1022
+ //
1023
+ return;
1024
+ }
1025
+
1026
+
1027
+
1028
+ //
1029
+ // Handle the key click event
1030
+ //
1031
+ var key = RGraph.Registry.get('key-element');
1032
+ if (key) {
1033
+ RGraph.fireCustomEvent(obj, 'onkeyclick');
1034
+ }
1035
+
1036
+
1037
+
1038
+
1039
+
1040
+ //
1041
+ // The property takes priority over this.
1042
+ //
1043
+ if (shape) {
1044
+
1045
+ var index = shape.sequentialIndex;
1046
+
1047
+ if (typeof index == 'number' && obj['$' + index]) {
1048
+
1049
+ var func = obj['$' + index].onclick;
1050
+
1051
+ if (typeof func == 'function') {
1052
+
1053
+ func(e, shape);
1054
+
1055
+ //
1056
+ // If objects are layered on top of each other this return
1057
+ // stops objects underneath from firing once the "top"
1058
+ // objects user event has fired
1059
+ //
1060
+ return;
1061
+ }
1062
+ }
1063
+ }
1064
+
1065
+ //
1066
+ // This facilitates breaking out of the loop when a shape has been found -
1067
+ // ie the cursor is over a shape an upper chart
1068
+ //
1069
+ if (shape || (obj.overChartArea && obj.overChartArea(e)) ) {
1070
+ break;
1071
+ }
1072
+ }
1073
+ };
1074
+ obj.canvas.addEventListener('click', obj.canvas.rgraph_click_event_listener, false);
1075
+ }
1076
+ };
1077
+
1078
+
1079
+
1080
+
1081
+
1082
+
1083
+
1084
+
1085
+ //
1086
+ // This function evaluates the various cursor settings and if there's one for pointer, changes it to that
1087
+ //
1088
+ RGraph.evaluateCursor = function (e)
1089
+ {
1090
+ if (e.rgraph_evaluateCursor === false) {
1091
+ return;
1092
+ }
1093
+
1094
+ var obj = null;
1095
+ var mouseXY = RGraph.getMouseXY(e);
1096
+ var mouseX = mouseXY[0];
1097
+ var mouseY = mouseXY[1];
1098
+ var canvas = e.target;
1099
+
1100
+ //
1101
+ // Tooltips cause the mouse pointer to change
1102
+ //
1103
+ var objects = RGraph.OR.getObjectsByCanvasID(canvas.id);
1104
+
1105
+ for (var i=0,len=objects.length; i<len; i+=1) {
1106
+ if ((objects[i].getShape && objects[i].getShape(e)) || (objects[i].overChartArea && objects[i].overChartArea(e))) {
1107
+ var obj = objects[i];
1108
+ var id = obj.id;
1109
+ }
1110
+ }
1111
+
1112
+ if (!RGraph.isNull(obj)) {
1113
+ if (obj.getShape && obj.getShape(e)) {
1114
+
1115
+ var shape = obj.getShape(e);
1116
+
1117
+ if (
1118
+ (!obj.isMarimekko && obj.get('tooltips')) ||
1119
+ (obj.isMarimekko && obj.get('marimekkoTooltips'))
1120
+ ) {
1121
+
1122
+ var text = RGraph.parseTooltipText(
1123
+ obj.isMarimekko ? obj.get('marimekkoTooltips') : obj.get('tooltips'),
1124
+ shape.sequentialIndex
1125
+ );
1126
+
1127
+ if (!text && shape.object.type == 'scatter' && shape.index) {
1128
+ text = RGraph.parseTooltipText(obj.get('tooltips'), shape.index);
1129
+ }
1130
+
1131
+ //
1132
+ // This essentially makes front charts "hide" the back charts
1133
+ //
1134
+ if (text) {
1135
+ var pointer = true;
1136
+ }
1137
+ }
1138
+ }
1139
+
1140
+ //
1141
+ // Now go through the key coords and see if it's over that.
1142
+ //
1143
+ if (!RGraph.isNull(obj) && obj.get('keyInteractive')) {
1144
+ for (var j=0; j<obj.coords.key.length; ++j) {
1145
+ if (mouseX > obj.coords.key[j][0] && mouseX < (obj.coords.key[j][0] + obj.coords.key[j][2]) && mouseY > obj.coords.key[j][1] && mouseY < (obj.coords.key[j][1] + obj.coords.key[j][3])) {
1146
+ var pointer = true;
1147
+ }
1148
+ }
1149
+ }
1150
+ }
1151
+
1152
+ //
1153
+ // It can be specified in the user mousemove event - remember it can now
1154
+ // be specified in THREE ways
1155
+ //
1156
+ if (RGraph.custom_events_mousemove_pointer) {
1157
+ var pointer = true;
1158
+ RGraph.custom_events_mousemove_pointer = false;
1159
+ }
1160
+ //
1161
+ //
1162
+ //
1163
+ // var index = shape.object.type == 'scatter' ? shape.index_adjusted : shape.index;
1164
+ //
1165
+ // if (!RGraph.isNull(obj['$' + index]) && typeof obj['$' + index].onmousemove == 'function') {
1166
+ // var str = (obj['$' + index].onmousemove).toString();
1167
+ // if (str.match(/pointer/) && str.match(/cursor/) && str.match(/style/)) {
1168
+ // var pointer = true;
1169
+ // }
1170
+ // }
1171
+ // }
1172
+ //
1173
+
1174
+ //
1175
+ // Is the chart resizable? Go through all the objects again
1176
+ //
1177
+ var objects = RGraph.OR.objects.byCanvasID;
1178
+
1179
+ for (var i=0,len=objects.length; i<len; i+=1) {
1180
+ if (objects[i] && objects[i][1].get('resizable')) {
1181
+ var resizable = true;
1182
+ }
1183
+ }
1184
+
1185
+ if (resizable && mouseX > (e.target.width - 32) && mouseY > (e.target.height - 16)) {
1186
+ pointer = true;
1187
+ }
1188
+
1189
+
1190
+ if (pointer) {
1191
+ e.target.style.cursor = 'pointer';
1192
+
1193
+ } else if (e.target.style.cursor == 'pointer') {
1194
+ e.target.style.cursor = 'default';
1195
+ } else {
1196
+ e.target.style.cursor = null;
1197
+ }
1198
+
1199
+
1200
+
1201
+ // =========================================================================
1202
+ // Resize cursor - check mouseis in bottom left corner and if it is change it
1203
+ // =========================================================================
1204
+
1205
+
1206
+ if (resizable && mouseX >= (e.target.width - 15) && mouseY >= (e.target.height - 15)) {
1207
+ e.target.style.cursor = 'move';
1208
+
1209
+ } else if (e.target.style.cursor === 'move') {
1210
+ e.target.style.cursor = 'default';
1211
+ }
1212
+
1213
+
1214
+
1215
+
1216
+
1217
+
1218
+
1219
+
1220
+
1221
+
1222
+ // =========================================================================
1223
+ // Line chart dataset highlighting
1224
+ // =========================================================================
1225
+ var objects = RGraph.OR.getObjectsByXY(e);
1226
+
1227
+ for (let i=0; i<objects.length; ++i) {
1228
+ if (objects[i] && objects[i].type && objects[i].type === 'line' && objects[i].properties.highlightDataset) {
1229
+
1230
+ var [x, y] = RGraph.getMouseXY(e);
1231
+ var shape = objects[i].over(x, y);
1232
+ var excludedNumber = RGraph.isNumber(objects[i].properties.highlightDatasetExclude) && shape && objects[i].properties.highlightDatasetExclude === shape.dataset;
1233
+ var excludedArray = RGraph.isArray(objects[i].properties.highlightDatasetExclude) && shape && objects[i].properties.highlightDatasetExclude.includes(shape.dataset);
1234
+
1235
+ if (shape && !excludedNumber && !excludedArray) {
1236
+ e.target.style.cursor = 'pointer';
1237
+ }
1238
+ }
1239
+
1240
+ if (objects[i].getShape(e)) {
1241
+ break;
1242
+ }
1243
+ }
1244
+
1245
+
1246
+
1247
+
1248
+
1249
+
1250
+
1251
+
1252
+
1253
+
1254
+
1255
+
1256
+
1257
+
1258
+
1259
+
1260
+
1261
+ // =========================================================================
1262
+ // Interactive key
1263
+ // =========================================================================
1264
+
1265
+
1266
+
1267
+ if (typeof mouse_over_key == 'boolean' && mouse_over_key) {
1268
+ e.target.style.cursor = 'pointer';
1269
+ }
1270
+
1271
+
1272
+ // =========================================================================
1273
+ // Gantt chart adjusting
1274
+ // =========================================================================
1275
+
1276
+ //if (obj && obj.type == 'gantt' && obj.get('adjustable')) {
1277
+ // if (obj.getShape && obj.getShape(e)) {
1278
+ // e.target.style.cursor = 'ew-resize';
1279
+ // } else {
1280
+ // e.target.style.cursor = 'default';
1281
+ // }
1282
+ //} else if (!obj || !obj.type) {
1283
+ // e.target.style.cursor = cursor;
1284
+ //}
1285
+
1286
+
1287
+ // =========================================================================
1288
+ // Line chart adjusting
1289
+ // =========================================================================
1290
+
1291
+
1292
+ if (obj && obj.type == 'line' && obj.get('adjustable')) {
1293
+ if (obj.getShape) {
1294
+
1295
+ var shape = obj.getShape(e);
1296
+
1297
+ if (shape && obj.isAdjustable(shape)) {
1298
+ e.target.style.cursor = 'ns-resize';
1299
+ }
1300
+ } else {
1301
+ e.target.style.cursor = 'default';
1302
+ }
1303
+ }
1304
+
1305
+
1306
+ // =========================================================================
1307
+ // Scatter chart adjusting
1308
+ // =========================================================================
1309
+
1310
+
1311
+ if (obj && obj.type == 'scatter' && obj.get('adjustable')) {
1312
+ if (obj.getShape) {
1313
+
1314
+ var shape = obj.getShape(e);
1315
+
1316
+ if (shape && obj.isAdjustable(shape)) {
1317
+ e.target.style.cursor = 'move';
1318
+ }
1319
+ } else {
1320
+ e.target.style.cursor = 'default';
1321
+ }
1322
+ }
1323
+
1324
+
1325
+ // =========================================================================
1326
+ // Annotatable
1327
+ // =========================================================================
1328
+
1329
+
1330
+ if (e.target.__object__ && e.target.__object__.get('annotatable')) {
1331
+ e.target.style.cursor = 'crosshair';
1332
+ }
1333
+
1334
+
1335
+ // =========================================================================
1336
+ // Drawing API link
1337
+ // =========================================================================
1338
+
1339
+
1340
+ if (obj && obj.type === 'drawing.text' && shape && typeof obj.get('link') === 'string') {
1341
+ e.target.style.cursor = 'pointer';
1342
+ }
1343
+ };
1344
+
1345
+
1346
+
1347
+
1348
+
1349
+
1350
+
1351
+
1352
+ //
1353
+ // This function handles the tooltip text being a string, function
1354
+ //
1355
+ // @param mixed tooltip This could be a string or a function. If it's a function it's called and
1356
+ // the return value is used as the tooltip text
1357
+ // @param numbr idx The index of the tooltip.
1358
+ //
1359
+ RGraph.parseTooltipText = function (tooltips, idx)
1360
+ {
1361
+ // No tooltips
1362
+ if (!tooltips) {
1363
+ return null;
1364
+ }
1365
+
1366
+
1367
+ // Get the tooltip text
1368
+ if (typeof tooltips == 'function') {
1369
+ var text = tooltips(idx);
1370
+
1371
+ // A single tooltip. Now with template support
1372
+ } else if (typeof tooltips == 'string') {
1373
+ var text = tooltips;
1374
+
1375
+ } else if (typeof tooltips === 'object' && typeof tooltips[idx] == 'function') {
1376
+ var text = tooltips[idx](idx);
1377
+
1378
+ } else if (typeof tooltips === 'object' && (RGraph.isNull(tooltips[idx]) || typeof tooltips[idx] === 'undefined') ) {
1379
+ return null;
1380
+
1381
+ } else if (typeof tooltips[idx] == 'string' && tooltips[idx]) {
1382
+ var text = tooltips[idx];
1383
+
1384
+ } else {
1385
+ var text = '';
1386
+ }
1387
+
1388
+ if (typeof text === 'undefined') {
1389
+ text = '';
1390
+ } else if (typeof text === 'null') {
1391
+ text = '';
1392
+ }
1393
+
1394
+ // Conditional in case the tooltip file isn't included
1395
+ return RGraph.getTooltipTextFromDIV ? RGraph.getTooltipTextFromDIV(text) : text;
1396
+ };
1397
+
1398
+
1399
+
1400
+
1401
+
1402
+
1403
+
1404
+
1405
+ //
1406
+ // Draw crosshairs if enabled
1407
+ //
1408
+ // @param object obj The graph object (from which we can get the context and canvas as required)
1409
+ //
1410
+ RGraph.drawCrosshairs = function (e, obj)
1411
+ {
1412
+ var width = obj.canvas.width,
1413
+ height = obj.canvas.height,
1414
+ mouseXY = RGraph.getMouseXY(e),
1415
+ x = mouseXY[0],
1416
+ y = mouseXY[1],
1417
+ marginLeft = obj.marginLeft,
1418
+ marginRight = obj.marginRight,
1419
+ marginTop = obj.marginTop,
1420
+ marginBottom = obj.marginBottom,
1421
+ prop = obj.properties,
1422
+ properties = obj.properties;
1423
+
1424
+ RGraph.redrawCanvas(obj.canvas);
1425
+
1426
+ if ( x >= marginLeft
1427
+ && y >= marginTop
1428
+ && x <= (width - marginRight)
1429
+ && y <= (height - marginBottom)
1430
+ ) {
1431
+
1432
+ var linewidth = properties.crosshairsLinewidth ? properties.crosshairsLinewidth : 1;
1433
+ obj.context.lineWidth = linewidth ? linewidth : 1;
1434
+
1435
+ obj.context.beginPath();
1436
+ obj.context.strokeStyle = properties.crosshairsColor;
1437
+
1438
+
1439
+
1440
+
1441
+
1442
+ //
1443
+ // The crosshairsSnap option
1444
+ //
1445
+ if (properties.crosshairsSnap) {
1446
+
1447
+ // Linear search for the closest point
1448
+ var point = null;
1449
+ var dist = null;
1450
+ var len = null;
1451
+
1452
+ if (obj.type == 'line') {
1453
+
1454
+ for (var i=0; i<obj.coords.length; ++i) {
1455
+
1456
+ var length = RGraph.getHypLength(obj.coords[i][0], obj.coords[i][1], x, y);
1457
+
1458
+ // Check the mouse X coordinate
1459
+ if (typeof dist != 'number' || length < dist) {
1460
+ var point = i;
1461
+ var dist = length;
1462
+ }
1463
+ }
1464
+
1465
+ x = obj.coords[point][0];
1466
+ y = obj.coords[point][1];
1467
+
1468
+ // Get the dataset
1469
+ for (var dataset=0; dataset<obj.coords2.length; ++dataset) {
1470
+ for (var point=0; point<obj.coords2[dataset].length; ++point) {
1471
+ if (obj.coords2[dataset][point][0] == x && obj.coords2[dataset][point][1] == y) {
1472
+ obj.canvas.__crosshairs_snap_dataset__ = dataset;
1473
+ obj.canvas.__crosshairs_snap_point__ = point;
1474
+ }
1475
+ }
1476
+ }
1477
+
1478
+ } else {
1479
+
1480
+ for (var i=0; i<obj.coords.length; ++i) {
1481
+ for (var j=0; j<obj.coords[i].length; ++j) {
1482
+
1483
+ // Check the mouse X coordinate
1484
+ var len = RGraph.getHypLength(obj.coords[i][j][0], obj.coords[i][j][1], x, y);
1485
+
1486
+ if (typeof dist != 'number' || len < dist) {
1487
+
1488
+ var dataset = i;
1489
+ var point = j;
1490
+ var dist = len;
1491
+ }
1492
+ }
1493
+
1494
+ }
1495
+ obj.canvas.__crosshairs_snap_dataset__ = dataset;
1496
+ obj.canvas.__crosshairs_snap_point__ = point;
1497
+
1498
+
1499
+ x = obj.coords[dataset][point][0];
1500
+ y = obj.coords[dataset][point][1];
1501
+ }
1502
+ }
1503
+
1504
+
1505
+
1506
+
1507
+
1508
+
1509
+ // Draw a vertical line
1510
+ if (properties.crosshairsVline) {
1511
+ obj.context.moveTo(Math.round(x), Math.round(marginTop));
1512
+ obj.context.lineTo(Math.round(x), Math.round(height - marginBottom));
1513
+ }
1514
+
1515
+ // Draw a horizontal line
1516
+ if (properties.crosshairsHline) {
1517
+ obj.context.moveTo(Math.round(marginLeft), Math.round(y));
1518
+ obj.context.lineTo(Math.round(width - marginRight), Math.round(y));
1519
+ }
1520
+
1521
+ obj.context.stroke();
1522
+
1523
+
1524
+ //
1525
+ // Need to show the coords?
1526
+ //
1527
+ if (obj.type == 'scatter' && properties.crosshairsCoords) {
1528
+
1529
+ var xCoord = (((x - marginLeft) / (width - marginLeft - marginRight)) * (properties.xaxisScaleMax - properties.xaxisScaleMin)) + properties.xaxisScaleMin;
1530
+ xCoord = xCoord.toFixed(properties.yaxisScaleDecimals);
1531
+ var yCoord = obj.max - (((y - properties.marginTop) / (height - marginTop - marginBottom)) * (obj.max - obj.scale2.min));
1532
+
1533
+ if (obj.type == 'scatter' && obj.properties.xaxisPosition === 'center') {
1534
+ yCoord = (yCoord - (obj.max / 2)) * 2;
1535
+ }
1536
+
1537
+ yCoord = yCoord.toFixed(properties.yaxisScaleDecimals);
1538
+
1539
+ var div = RGraph.Registry.get('coordinates.coords.div');
1540
+ var mouseXY = RGraph.getMouseXY(e);
1541
+ var canvasXY = RGraph.getCanvasXY(obj.canvas);
1542
+
1543
+ if (!div) {
1544
+ var div = document.createElement('DIV');
1545
+ div.__object__ = obj;
1546
+ div.style.position = 'absolute';
1547
+ div.style.backgroundColor = 'white';
1548
+ div.style.border = '1px solid gray';
1549
+ div.style.fontFamily = 'Arial, Verdana, sans-serif';
1550
+ div.style.fontSize = '10pt'
1551
+ div.style.padding = '2px';
1552
+ div.style.opacity = 1;
1553
+ div.style.WebkitBorderRadius = '3px';
1554
+ div.style.borderRadius = '3px';
1555
+ div.style.MozBorderRadius = '3px';
1556
+ div.style.lineHeight = RGraph.ISIE ? 'normal' : 'initial';
1557
+ document.body.appendChild(div);
1558
+
1559
+ RGraph.Registry.set('coordinates.coords.div', div);
1560
+ }
1561
+
1562
+ // Convert the X/Y pixel coords to correspond to the scale
1563
+ div.style.opacity = 1;
1564
+ div.style.display = 'inline';
1565
+
1566
+ if (!properties.crosshairsCoordsFixed) {
1567
+ div.style.left = Math.max(2, (e.pageX - div.offsetWidth - 3)) + 'px';
1568
+ div.style.top = Math.max(2, (e.pageY - div.offsetHeight - 3)) + 'px';
1569
+ } else {
1570
+ div.style.left = canvasXY[0] + marginLeft + 3 + 'px';
1571
+ div.style.top = canvasXY[1] + marginTop + 3 + 'px';
1572
+ }
1573
+
1574
+ // Use the formatter functions if defined. This allows the user to format them as they wish
1575
+ if (typeof properties.crosshairsCoordsFormatterX === 'function') {
1576
+ xCoord = (properties.crosshairsCoordsFormatterX)({object: obj, value: parseInt(xCoord)});
1577
+ }
1578
+ if (typeof properties.crosshairsCoordsFormatterY === 'function') {
1579
+ yCoord = (properties.crosshairsCoordsFormatterY)({object: obj, value: parseInt(yCoord)});
1580
+ }
1581
+
1582
+ div.innerHTML = '<span id="rgraph_crosshairsCoordsLabelsX">' + properties.crosshairsCoordsLabelsX + ':</span> ' + xCoord + '<br><span id="rgraph_crosshairsCoordsLabelsY">' + properties.crosshairsCoordsLabelsY + ':</span> ' + yCoord;
1583
+
1584
+ // Change the color of the labels - don't use
1585
+ // inline styles because of CSP security errors
1586
+ document.getElementById('rgraph_crosshairsCoordsLabelsX').style.color = '#666';
1587
+ document.getElementById('rgraph_crosshairsCoordsLabelsY').style.color = '#666';
1588
+
1589
+ obj.canvas.addEventListener('mouseout', RGraph.hideCrosshairCoords, false);
1590
+
1591
+ obj.canvas.__crosshairs_labels__ = div;
1592
+ obj.canvas.__crosshairs_x__ = xCoord;
1593
+ obj.canvas.__crosshairs_y__ = yCoord;
1594
+
1595
+ } else if (properties.crosshairsCoords) {
1596
+ alert('[RGRAPH] Showing crosshair coordinates is only supported on the Scatter chart');
1597
+ }
1598
+
1599
+ //
1600
+ // Fire the oncrosshairs custom event
1601
+ //
1602
+ RGraph.fireCustomEvent(obj, 'oncrosshairs');
1603
+
1604
+ } else {
1605
+ RGraph.hideCrosshairCoords();
1606
+ }
1607
+ };
1608
+
1609
+
1610
+
1611
+
1612
+
1613
+
1614
+
1615
+
1616
+ //
1617
+ // Adds a mousemove event listener that highlights a segment based on th
1618
+ // mousemove event. Used in the Rose and the RScatter charts
1619
+ //
1620
+ //@param int segments The number of segments to allow
1621
+ //
1622
+ RGraph.allowSegmentHighlight = function (opt)
1623
+ {
1624
+ var obj = opt.object,
1625
+ count = opt.count,
1626
+ fill = opt.fill,
1627
+ stroke = opt.stroke
1628
+
1629
+ if (!RGraph.segmentHighlightFunction) {
1630
+
1631
+ RGraph.segmentHighlightFunction = function (e)
1632
+ {
1633
+ var mouseXY = RGraph.getMouseXY(e);
1634
+ var angle = RGraph.getAngleByXY(obj.centerx, obj.centery, mouseXY[0], mouseXY[1]);
1635
+
1636
+ angle += RGraph.HALFPI;
1637
+
1638
+ if (angle > RGraph.TWOPI) {
1639
+ angle -= RGraph.TWOPI;
1640
+ }
1641
+
1642
+ RGraph.redraw();
1643
+
1644
+ var start = 0;
1645
+ var end = 0;
1646
+ var a = (Math.PI * 2) / count;
1647
+
1648
+ //
1649
+ // Radius
1650
+ //
1651
+ var r = obj.radius;
1652
+
1653
+
1654
+ (function ()
1655
+ {
1656
+ for (i=0; i<count; i+=1) {
1657
+ if (angle < (a * (i + 1))) {
1658
+ start = i * a;
1659
+ end = (i + 1) * a;
1660
+
1661
+ return;
1662
+ }
1663
+ }
1664
+ })();
1665
+
1666
+ start -= RGraph.HALFPI;
1667
+ end -= RGraph.HALFPI;
1668
+
1669
+
1670
+ obj.path(
1671
+ 'b m % % a % % % % % false c s % f %',
1672
+ obj.centerx, obj.centery,
1673
+ obj.centerx,obj.centery,r,start,end,
1674
+ stroke, fill
1675
+ );
1676
+
1677
+ };
1678
+ obj.canvas.addEventListener(
1679
+ 'mousemove',
1680
+ RGraph.segmentHighlightFunction,
1681
+ false
1682
+ );
1683
+ }
1684
+ }
1685
+
1686
+
1687
+
1688
+
1689
+
1690
+
1691
+
1692
+
1693
+ // End module pattern
1694
+ })(window, document);