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,52 +1,715 @@
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};RGraph.Drawing=RGraph.Drawing||{};RGraph.Drawing.YAxis=function(conf)
3
- {if(typeof conf==='object'&&typeof conf.x==='number'&&typeof conf.id==='string'){var id=conf.id
4
- var x=conf.x;var parseConfObjectForOptions=true;}else{var id=conf;var x=arguments[1];}
5
- this.id=id;this.canvas=document.getElementById(this.id);this.context=this.canvas.getContext("2d");this.canvas.__object__=this;this.x=x;this.coords=[];this.coordsText=[];this.original_colors=[];this.maxLabelLength=0;this.firstDraw=true;this.type='drawing.yaxis';this.isRGraph=true;this.uid=RGraph.CreateUID();this.canvas.uid=this.canvas.uid?this.canvas.uid:RGraph.CreateUID();this.properties={'chart.margin.top':25,'chart.margin.bottom':30,'chart.colors':['black'],'chart.title':'','chart.title.color':null,'chart.title.font':null,'chart.title.size':null,'chart.title.bold':null,'chart.title.italic':null,'chart.text.font':'Arial, Verdana, sans-serif','chart.text.size':12,'chart.text.color':'black','chart.text.bold':false,'chart.text.italic':false,'chart.text.accessible':true,'chart.text.accessible.overflow':'visible','chart.text.accessible.pointerevents':false,'chart.yaxis':true,'chart.yaxis.tickmarks.count':5,'chart.yaxis.labels.count':5,'chart.yaxis.labels.specific':null,'chart.yaxis.labels.font':null,'chart.yaxis.labels.size':null,'chart.yaxis.labels.color':null,'chart.yaxis.labels.bold':null,'chart.yaxis.labels.italic':null,'chart.yaxis.tickmarks.align':'left','chart.yaxis.scale.min':0,'chart.yaxis.scale.max':null,'chart.yaxis.scale.formatter':null,'chart.yaxis.scale.decimals':0,'chart.yaxis.scale.point':'.','chart.yaxis.scale.thousand':',','chart.yaxis.scale.invert':false,'chart.yaxis.scale.zerostart':true,'chart.yaxis.scale.visible':true,'chart.yaxis.scale.units.pre':'','chart.yaxis.scale.units.post':'','chart.yaxis.tickmarks.last.top':true,'chart.yaxis.tickmarks.last.bottom':true,'chart.linewidth':1,'chart.tooltips':null,'chart.tooltips.effect':'fade','chart.tooltips.css.class':'RGraph_tooltip','chart.tooltips.event':'onclick','chart.xaxis.position':'bottom','chart.events.click':null,'chart.events.mousemove':null,'chart.clearto':'rgba(0,0,0,0)'}
6
- if(!this.canvas){alert('[DRAWING.YAXIS] No canvas support');return;}
7
- this.$0={};if(!this.canvas.__rgraph_aa_translated__){this.context.translate(0.5,0.5);this.canvas.__rgraph_aa_translated__=true;}
8
- var RG=RGraph,ca=this.canvas,co=ca.getContext('2d'),prop=this.properties,pa2=RG.path2,win=window,doc=document,ma=Math
9
- if(RG.Effects&&typeof RG.Effects.decorate==='function'){RG.Effects.decorate(this);}
10
- this.set=this.Set=function(name)
11
- {var value=typeof arguments[1]==='undefined'?null:arguments[1];if(arguments.length===1&&typeof name==='object'){RG.parseObjectStyleConfig(this,name);return this;}
12
- if(name.substr(0,6)!='chart.'){name='chart.'+name;}
13
- while(name.match(/([A-Z])/)){name=name.replace(/([A-Z])/,'.'+RegExp.$1.toLowerCase());}
14
- prop[name]=value;return this;};this.get=this.Get=function(name)
15
- {if(name.substr(0,6)!='chart.'){name='chart.'+name;}
16
- while(name.match(/([A-Z])/)){name=name.replace(/([A-Z])/,'.'+RegExp.$1.toLowerCase());}
17
- return prop[name.toLowerCase()];};this.draw=this.Draw=function()
18
- {RG.fireCustomEvent(this,'onbeforedraw');this.marginTop=prop['chart.margin.top'];this.marginBottom=prop['chart.margin.bottom'];this.coordsText=[];if(!prop['chart.text.color'])prop['chart.text.color']=prop['chart.colors'][0];if(!prop['chart.title.color'])prop['chart.title.color']=prop['chart.text.color'];if(!this.colorsParsed){this.parseColors();this.colorsParsed=true;}
19
- this.drawYAxis();RG.installEventListeners(this);if(this.firstDraw){this.firstDraw=false;RG.fireCustomEvent(this,'onfirstdraw');this.firstDrawFunc();}
20
- RG.FireCustomEvent(this,'ondraw');return this;};this.exec=function(func)
21
- {func(this);return this;};this.getObjectByXY=function(e)
22
- {if(this.getShape(e)){return this;}};this.getShape=function(e)
23
- {var mouseXY=RG.getMouseXY(e);var mouseX=mouseXY[0];var mouseY=mouseXY[1];if(mouseX>=this.x-(prop['chart.tickmarks.align']=='right'?0:this.getWidth())&&mouseX<=this.x+(prop['chart.tickmarks.align']=='right'?this.getWidth():0)&&mouseY>=this.marginTop&&mouseY<=(ca.height-this.marginBottom)){var x=this.x;var y=this.marginTop;var w=15;;var h=ca.height-this.marginTop-this.marginBottom;return{0:this,1:x,2:y,3:w,4:h,5:0,'object':this,'x':x,'y':y,'width':w,'height':h,'index':0,'tooltip':prop['chart.tooltips']?prop['chart.tooltips'][0]:null};}
24
- return null;};this.highlight=this.Highlight=function(shape)
25
- {if(typeof prop['chart.highlight.style']==='function'){(prop['chart.highlight.style'])(shape);}};this.parseColors=function()
26
- {if(this.original_colors.length===0){this.original_colors['chart.yaxis.labels.color']=RG.arrayClone(prop['chart.yaxis.labels.color']);this.original_colors['chart.title.color']=RG.arrayClone(prop['chart.title.color']);this.original_colors['chart.text.color']=RG.arrayClone(prop['chart.text.color']);this.original_colors['chart.colors']=RG.arrayClone(prop['chart.colors']);}
27
- prop['chart.yaxis.labels.color']=this.parseSingleColorForGradient(prop['chart.yaxis.labels.color']);prop['chart.title.color']=this.parseSingleColorForGradient(prop['chart.title.color']);prop['chart.text.color']=this.parseSingleColorForGradient(prop['chart.text.color']);prop['chart.colors'][0]=this.parseSingleColorForGradient(prop['chart.colors'][0]);};this.reset=function()
28
- {};this.parseSingleColorForGradient=function(color)
29
- {if(!color){return color;}
30
- if(typeof color==='string'&&color.match(/^gradient\((.*)\)$/i)){if(color.match(/^gradient\(({.*})\)$/i)){return RGraph.parseJSONGradient({object:this,def:RegExp.$1});}
31
- var parts=RegExp.$1.split(':');var grad=co.createLinearGradient(0,prop['chart.margin.top'],0,ca.height-this.marginBottom);var diff=1/(parts.length-1);grad.addColorStop(0,RG.trim(parts[0]));for(var j=1;j<parts.length;++j){grad.addColorStop(j*diff,RG.trim(parts[j]));}}
32
- return grad?grad:color;};this.drawYAxis=this.DrawYAxis=function()
33
- {var x=this.x,y=this.marginTop,height=ca.height-this.marginBottom-this.marginTop,min=+prop['chart.yaxis.scale.min']?+prop['chart.yaxis.scale.min']:0,max=+prop['chart.yaxis.scale.max'],title=prop['chart.yaxis.title']?prop['chart.yaxis.title']:'',color=prop['chart.colors']?prop['chart.colors'][0]:'black',title_color=prop['chart.yaxis.title.color']?prop['chart.yaxis.title.color']:color,label_color=prop['chart.text.color']?prop['chart.text.color']:color,numticks=typeof(prop['chart.yaxis.tickmarks.count'])=='number'?prop['chart.yaxis.tickmarks.count']:10,labels_specific=prop['chart.yaxis.labels.specific'],numlabels=prop['chart.yaxis.labels.count']?prop['chart.yaxis.labels.count']:5,font=prop['chart.text.font']?prop['chart.text.font']:'Arial, Verdana, sans-serif',size=prop['chart.text.size']?prop['chart.text.size']:12
34
- align=typeof(prop['chart.yaxis.tickmarks.align'])=='string'?prop['chart.yaxis.tickmarks.align']:'left',formatter=prop['chart.yaxis.scale.formatter'],decimals=prop['chart.yaxis.scale.decimals'],invert=prop['chart.yaxis.scale.invert'],scale_visible=prop['chart.yaxis.scale.visible'],units_pre=prop['chart.yaxis.scale.units.pre'],units_post=prop['chart.yaxis.scale.units.post'],linewidth=prop['chart.linewidth']?prop['chart.linewidth']:1,notopendtick=!prop['chart.yaxis.tickmarks.last.top'],nobottomendtick=!prop['chart.yaxis.tickmarks.last.bottom'],yaxis=prop['chart.yaxis'],xaxispos=prop['chart.xaxis.position']
35
- co.lineWidth=linewidth+0.001;co.strokeStyle=color;if(yaxis){pa2(co,'b m % % l % % s %',Math.round(x),y,Math.round(x),y+height,color);if(numticks){var gap=(xaxispos=='center'?height/2:height)/numticks;var halfheight=height/2;co.beginPath();for(var i=(notopendtick?1:0);i<=(numticks-(nobottomendtick||xaxispos=='center'?1:0));++i){pa2(co,['m',align=='right'?x+3:x-3,Math.round(y+(gap*i)),'l',x,Math.round(y+(gap*i))]);}
36
- if(xaxispos=='center'){for(var i=1;i<=numticks-(nobottomendtick?1:0);++i){pa2(co,['m',align=='right'?x+3:x-3,Math.round(y+halfheight+(gap*i)),'l',x,Math.round(y+halfheight+(gap*i))]);}}
37
- co.stroke();}}
38
- co.fillStyle=label_color;var text_len=0;if(scale_visible){if(labels_specific&&labels_specific.length){var text_len=0;for(var i=0,len=labels_specific.length;i<len;i+=1){text_len=ma.max(text_len,co.measureText(labels_specific[i]).width);}
39
- var textConf=RG.getTextConf({object:this,prefix:'chart.yaxis.labels'});for(var i=0,len=labels_specific.length;i<len;++i){var gap=(len-1)>0?(height/(len-1)):0;if(xaxispos=='center'){gap/=2;}
40
- RG.text2(this,{font:textConf.font,size:textConf.size,bold:textConf.bold,italic:textConf.italic,color:textConf.color,x:x-(align=='right'?-5:5),y:(i*gap)+this.marginTop,text:labels_specific[i],valign:'center',halign:align=='right'?'left':'right',tag:'scale'});this.maxLabelLength=ma.max(this.maxLabelLength,co.measureText(labels_specific[i]).width);}
41
- if(xaxispos=='center'){for(var i=(labels_specific.length-2);i>=0;--i){RG.text2(this,{font:textConf.font,size:textConf.size,bold:textConf.bold,italic:textConf.italic,color:textConf.color,x:x-(align=='right'?-5:5),y:ca.height-this.marginBottom-(i*gap),text:labels_specific[i],valign:'center',halign:align=='right'?'left':'right',tag:'scale'});}}}else{var textConf=RG.getTextConf({object:this,prefix:'chart.yaxis.labels'});for(var i=0;i<=numlabels;++i){var original=((max-min)*((numlabels-i)/numlabels))+min;if(original==0&&prop['chart.yaxis.scale.zerostart']==false){continue;}
42
- var text=RG.numberFormat({object:this,number:original.toFixed(original===0?0:decimals),unitspre:units_pre,unitspost:units_post,point:prop['chart.yaxis.scale.point'],thousand:prop['chart.yaxis.scale.thousand']});var text=String(typeof(formatter)=='function'?formatter(this,original):text);var text_len=ma.max(text_len,co.measureText(text).width);this.maxLabelLength=text_len;if(invert){var y=height-((height/numlabels)*i);}else{var y=(height/numlabels)*i;}
43
- if(prop['chart.xaxis.position']=='center'){y=y/2;}
44
- text=text.replace(/^-,([0-9])/,'-$1');RG.text2(this,{font:textConf.font,size:textConf.size,bold:textConf.bold,italic:textConf.italic,color:textConf.color,x:x-(align=='right'?-5:5),y:y+this.marginTop,text:text,valign:'center',halign:align=='right'?'left':'right',tag:'scale'});if(prop['chart.xaxis.position']=='center'&&i<numlabels){RG.Text2(this,{font:textConf.font,size:textConf.size,bold:textConf.bold,italic:textConf.italic,color:textConf.color,x:x-(align=='right'?-5:5),y:ca.height-this.marginBottom-y,text:'-'+text,valign:'center',halign:align=='right'?'left':'right',tag:'scale'});}}}}
45
- if(title){co.beginPath();co.fillStyle=title_color;if(labels_specific){var width=0;for(var i=0,len=labels_specific.length;i<len;i+=1){width=Math.max(width,co.measureText(labels_specific[i]).width);}}else{var m=RG.measureText(prop['chart.yaxis.scale.units.pre']+prop['chart.yaxis.scale.max'].toFixed(prop['chart.yaxis.scale.decimals'])+prop['chart.yaxis.scale.units.post']),width=m[0];}
46
- var textConf=RG.getTextConf({object:this,prefix:'chart.yaxis.title'});RG.text2(this,{font:textConf.font,size:textConf.size,bold:textConf.bold,italic:textConf.italic,color:textConf.color,x:align=='right'?x+width+13:x-width-13,y:height/2+this.marginTop,text:title,valign:'bottom',halign:'center',angle:align=='right'?90:-90,accessible:false});co.stroke();}};this.getWidth=function()
47
- {var width=this.maxLabelLength;if(prop['chart.yaxis.title']&&prop['chart.yaxis.title'].length){width+=(prop['chart.text.size']*1.5);}
48
- this.width=width;return width;};this.on=function(type,func)
49
- {if(type.substr(0,2)!=='on'){type='on'+type;}
50
- if(typeof this[type]!=='function'){this[type]=func;}else{RG.addCustomEventListener(this,type,func);}
51
- return this;};this.firstDrawFunc=function()
52
- {};RG.register(this);if(parseConfObjectForOptions){RG.parseObjectStyleConfig(this,conf.options);}};
12
+ //
13
+ // Having this here means that the RGraph libraries can be included in any order, instead of you having
14
+ // to include the common core library first.
15
+ //
16
+
17
+ // Define the RGraph global variable
18
+ RGraph = window.RGraph || {isRGraph: true,isrgraph: true,rgraph: true};
19
+ RGraph.Drawing = RGraph.Drawing || {};
20
+
21
+ //
22
+ // The constructor. This function sets up the object.
23
+ //
24
+ RGraph.Drawing.YAxis = function (conf)
25
+ {
26
+ var id = conf.id
27
+ var x = conf.x;
28
+
29
+ this.id = id;
30
+ this.canvas = document.getElementById(this.id);
31
+ this.context = this.canvas.getContext("2d");
32
+ this.canvas.__object__ = this;
33
+ this.x = x;
34
+ this.coords = [];
35
+ this.coordsText = [];
36
+ this.original_colors = [];
37
+ this.maxLabelLength = 0;
38
+ this.firstDraw = true; // After the first draw this will be false
39
+
40
+
41
+
42
+ //
43
+ // This defines the type of this shape
44
+ //
45
+ this.type = 'drawing.yaxis';
46
+
47
+
48
+ //
49
+ // This facilitates easy object identification, and should always be true
50
+ //
51
+ this.isRGraph = true;
52
+ this.isrgraph = true;
53
+ this.rgraph = true;
54
+
55
+
56
+ //
57
+ // This adds a uid to the object that you can use for identification purposes
58
+ //
59
+ this.uid = RGraph.createUID();
60
+
61
+
62
+ //
63
+ // This adds a UID to the canvas for identification purposes
64
+ //
65
+ this.canvas.uid = this.canvas.uid ? this.canvas.uid : RGraph.createUID();
66
+
67
+
68
+
69
+ //
70
+ // Some example background properties
71
+ //
72
+ this.properties =
73
+ {
74
+ marginLeft: 35,
75
+ marginRight: 35,
76
+ marginTop: 35,
77
+ marginBottom: 35,
78
+
79
+ colors: ['black'],
80
+
81
+ title: '',
82
+ titleColor: null,
83
+ titleFont: null,
84
+ titleSize: null,
85
+ titleBold: null,
86
+ titleItalic: null,
87
+
88
+ textFont: 'Arial, Verdana, sans-serif',
89
+ textSize: 12,
90
+ textColor: 'black',
91
+ textBold: false,
92
+ textItalic: false,
93
+ textAccessible: false,
94
+ textAccessibleOverflow:'visible',
95
+ textAccessiblePointerevents: false,
96
+ text: null,
97
+
98
+ yaxis: true,
99
+ yaxisLinewidth: 1,
100
+ yaxisColor: 'black',
101
+ yaxisTickmarks: true,
102
+ yaxisTickmarksCount: null,
103
+ yaxisTickmarksLastTop: null,
104
+ yaxisTickmarksLastBottom: null,
105
+ yaxisTickmarksLength: 3,
106
+ yaxisScale: true,
107
+ yaxisScaleMin: 0,
108
+ yaxisScaleMax: null,
109
+ yaxisScaleUnitsPre: '',
110
+ yaxisScaleUnitsPost: '',
111
+ yaxisScaleDecimals: 0,
112
+ yaxisScalePoint: '.',
113
+ yaxisScaleThousand: ',',
114
+ yaxisScaleRound: false,
115
+ yaxisScaleFormatter: null,
116
+ yaxisLabelsSpecific: null,
117
+ yaxisLabelsCount: 5,
118
+ yaxisLabels: null,
119
+ yaxisLabelsOffsetx: 0,
120
+ yaxisLabelsOffsety: 0,
121
+ yaxisLabelsHalign: null,
122
+ yaxisLabelsValign: null,
123
+ yaxisLabelsFont: null,
124
+ yaxisLabelsSize: null,
125
+ yaxisLabelsColor: null,
126
+ yaxisLabelsBold: null,
127
+ yaxisLabelsItalic: null,
128
+ yaxisLabelsPosition: 'edge',
129
+ yaxisPosition: 'left',
130
+ yaxisTitle: '',
131
+ yaxisTitleBold: null,
132
+ yaxisTitleSize: null,
133
+ yaxisTitleFont: null,
134
+ yaxisTitleColor: null,
135
+ yaxisTitleItalic: null,
136
+ yaxisTitlePos: null,
137
+ yaxisTitleX: null,
138
+ yaxisTitleY: null,
139
+ yaxisTitleOffsetx: 0,
140
+ yaxisTitleOffsety: 0,
141
+ yaxisTitleHalign: null,
142
+ yaxisTitleValign: null,
143
+ yaxisTitleAccessible: null,
144
+
145
+ xaxisPosition: 'bottom',
146
+
147
+ linewidth: 1,
148
+
149
+ tooltips: null,
150
+ tooltipsEffect: 'slide',
151
+ tooltipsCssClass: 'RGraph_tooltip',
152
+ tooltipsCss: null,
153
+ tooltipsEvent: 'onclick',
154
+ tooltipsFormattedPoint: '.',
155
+ tooltipsFormattedThousand: ',',
156
+ tooltipsFormattedDecimals: 0,
157
+ tooltipsFormattedUnitsPre: '',
158
+ tooltipsFormattedUnitsPost: '',
159
+ tooltipsFormattedListType: 'ul',
160
+ tooltipsFormattedListItems: null,
161
+ tooltipsFormattedTableHeaders: null,
162
+ tooltipsFormattedTableData: null,
163
+ tooltipsPointer: true,
164
+ tooltipsPointerOffsetx: 0,
165
+ tooltipsPointerOffsety: 0,
166
+ tooltipsPositionStatic: true,
167
+
168
+ xaxisPosition: 'bottom',
169
+
170
+ clearto: 'rgba(0,0,0,0)'
171
+ }
172
+
173
+
174
+ //
175
+ // A simple check that the browser has canvas support
176
+ //
177
+ if (!this.canvas) {
178
+ alert('[DRAWING.YAXIS] No canvas support');
179
+ return;
180
+ }
181
+
182
+ //
183
+ // Create the dollar object so that functions can be added to them
184
+ //
185
+ this.$0 = {};
186
+
187
+
188
+
189
+ // Easy access to properties and the path function
190
+ var properties = this.properties;
191
+ this.path = RGraph.pathObjectFunction;
192
+
193
+
194
+
195
+ //
196
+ // "Decorate" the object with the generic effects if the effects library has been included
197
+ //
198
+ if (RGraph.Effects && typeof RGraph.Effects.decorate === 'function') {
199
+ RGraph.Effects.decorate(this);
200
+ }
201
+
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+ //
210
+ // A setter method for setting graph properties. It can be used like this: obj.set('colorsStroke', '#666');
211
+ //
212
+ // @param name string The name of the property to set
213
+ // @param value mixed The value of the property
214
+ //
215
+ this.set = function (name)
216
+ {
217
+ var value = typeof arguments[1] === 'undefined' ? null : arguments[1];
218
+
219
+ // the number of arguments is only one and it's an
220
+ // object - parse it for configuration data and return.
221
+ if (arguments.length === 1 && typeof arguments[0] === 'object') {
222
+ for (i in arguments[0]) {
223
+ if (typeof i === 'string') {
224
+ this.set(i, arguments[0][i]);
225
+ }
226
+ }
227
+
228
+ return this;
229
+ }
230
+
231
+ properties[name] = value;
232
+
233
+ return this;
234
+ };
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+ //
244
+ // A getter method for retrieving graph properties. It can be used like this: obj.get('colorsStroke');
245
+ //
246
+ // @param name string The name of the property to get
247
+ //
248
+ this.get = function (name)
249
+ {
250
+ return properties[name];
251
+ };
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+ //
261
+ // Draws the axes
262
+ //
263
+ this.draw = function ()
264
+ {
265
+ //
266
+ // Fire the onbeforedraw event
267
+ //
268
+ RGraph.fireCustomEvent(this, 'onbeforedraw');
269
+
270
+ // Translate half a pixel for antialiasing purposes - but only if it hasn't been
271
+ // done already
272
+ //
273
+ // MUST be the first thing done!
274
+ //
275
+ if (!this.canvas.__rgraph_aa_translated__) {
276
+ this.context.translate(0.5,0.5);
277
+
278
+ this.canvas.__rgraph_aa_translated__ = true;
279
+ }
280
+
281
+ //
282
+ // Some defaults
283
+ //
284
+ this.marginTop = properties.marginTop;
285
+ this.marginBottom = properties.marginBottom;
286
+
287
+
288
+ //
289
+ // Stop this growing uncntrollably
290
+ //
291
+ this.coordsText = [];
292
+
293
+
294
+
295
+ if (!properties.textColor) properties.textColor = properties.colors[0];
296
+ if (!properties.titleColor) properties.titleColor = properties.textColor;
297
+
298
+ //
299
+ // Parse the colors. This allows for simple gradient syntax
300
+ //
301
+ if (!this.colorsParsed) {
302
+
303
+ this.parseColors();
304
+
305
+ // Don't want to do this again
306
+ this.colorsParsed = true;
307
+ }
308
+
309
+
310
+
311
+ // DRAW Y AXIS HERE
312
+ this.drawYAxis();
313
+
314
+
315
+
316
+
317
+ //
318
+ // Add custom text thats specified
319
+ //
320
+ RGraph.addCustomText(this);
321
+
322
+
323
+
324
+
325
+
326
+
327
+ //
328
+ // This installs the event listeners
329
+ //
330
+ RGraph.installEventListeners(this);
331
+
332
+
333
+
334
+ //
335
+ // Fire the onfirstdraw event
336
+ //
337
+ if (this.firstDraw) {
338
+ this.firstDraw = false;
339
+ RGraph.fireCustomEvent(this, 'onfirstdraw');
340
+ this.firstDrawFunc();
341
+ }
342
+
343
+
344
+
345
+
346
+ //
347
+ // Fire the draw event
348
+ //
349
+ RGraph.fireCustomEvent(this, 'ondraw');
350
+
351
+ return this;
352
+ };
353
+
354
+
355
+
356
+
357
+
358
+
359
+
360
+
361
+ //
362
+ // Used in chaining. Runs a function there and then - not waiting for
363
+ // the events to fire (eg the onbeforedraw event)
364
+ //
365
+ // @param function func The function to execute
366
+ //
367
+ this.exec = function (func)
368
+ {
369
+ func(this);
370
+
371
+ return this;
372
+ };
373
+
374
+
375
+
376
+
377
+
378
+
379
+
380
+
381
+ //
382
+ // The getObjectByXY() worker method
383
+ //
384
+ this.getObjectByXY = function (e)
385
+ {
386
+ if (this.getShape(e)) {
387
+ return this;
388
+ }
389
+ };
390
+
391
+
392
+
393
+
394
+
395
+
396
+
397
+
398
+ //
399
+ // Not used by the class during creating the axis, but is used by event handlers
400
+ // to get the coordinates (if any) of the selected shape
401
+ //
402
+ // @param object e The event object
403
+ //
404
+ this.getShape = function (e)
405
+ {
406
+ var mouseXY = RGraph.getMouseXY(e);
407
+ var mouseX = mouseXY[0];
408
+ var mouseY = mouseXY[1];
409
+
410
+ if ( mouseX >= this.x - (properties.tickmarksAlign == 'right' ? 0 : this.getWidth())
411
+ && mouseX <= this.x + (properties.tickmarksAlign == 'right' ? this.getWidth() : 0)
412
+ && mouseY >= this.marginTop
413
+ && mouseY <= (this.canvas.height - this.marginBottom)
414
+ ) {
415
+
416
+ var x = this.x;
417
+ var y = this.marginTop;
418
+ var w = 15;;
419
+ var h = this.canvas.height - this.marginTop - this.marginBottom;
420
+
421
+ if (RGraph.parseTooltipText && properties.tooltips) {
422
+ var tooltip = RGraph.parseTooltipText(properties.tooltips, 0);
423
+ }
424
+
425
+ return {
426
+ object: this,
427
+ x: x,
428
+ y: y,
429
+ width: w,
430
+ height: h,
431
+ dataset: 0,
432
+ index: 0,
433
+ sequentialIndex: 0,
434
+ tooltip: typeof tooltip === 'string' ? tooltip : null
435
+ };
436
+ }
437
+
438
+ return null;
439
+ };
440
+
441
+
442
+
443
+
444
+
445
+
446
+
447
+
448
+ //
449
+ // Each object type has its own Highlight() function which highlights the appropriate shape
450
+ //
451
+ // @param object shape The shape to highlight
452
+ //
453
+ this.highlight = function (shape)
454
+ {
455
+ if (typeof properties.highlightStyle === 'function') {
456
+ (properties.highlightStyle)(shape);
457
+ }
458
+ };
459
+
460
+
461
+
462
+
463
+
464
+
465
+
466
+
467
+ //
468
+ // This allows for easy specification of gradients
469
+ //
470
+ this.parseColors = function ()
471
+ {
472
+ // Save the original colors so that they can be restored when the canvas is reset
473
+ if (this.original_colors.length === 0) {
474
+ this.original_colors.yaxisLabelsColor = RGraph.arrayClone(properties.yaxisLabelsColor);
475
+ this.original_colors.titleColor = RGraph.arrayClone(properties.titleColor);
476
+ this.original_colors.textColor = RGraph.arrayClone(properties.textColor);
477
+ this.original_colors.colors = RGraph.arrayClone(properties.colors);
478
+ }
479
+
480
+
481
+
482
+
483
+ //
484
+ // Parse various properties for colors
485
+ //
486
+ properties.yaxisLabelsColor = this.parseSingleColorForGradient(properties.yaxisLabelsColor);
487
+ properties.titleColor = this.parseSingleColorForGradient(properties.titleColor);
488
+ properties.textColor = this.parseSingleColorForGradient(properties.textColor);
489
+ properties.colors[0] = this.parseSingleColorForGradient(properties.colors[0]);
490
+ };
491
+
492
+
493
+
494
+
495
+
496
+
497
+
498
+
499
+ //
500
+ // Use this function to reset the object to the post-constructor state. Eg reset colors if
501
+ // need be etc
502
+ //
503
+ this.reset = function ()
504
+ {
505
+ };
506
+
507
+
508
+
509
+
510
+
511
+
512
+
513
+
514
+ //
515
+ // This parses a single color value
516
+ //
517
+ this.parseSingleColorForGradient = function (color)
518
+ {
519
+ if (!color) {
520
+ return color;
521
+ }
522
+
523
+ if (typeof color === 'string' && color.match(/^gradient\((.*)\)$/i)) {
524
+
525
+
526
+
527
+ // Allow for JSON gradients
528
+ if (color.match(/^gradient\(({.*})\)$/i)) {
529
+ return RGraph.parseJSONGradient({object: this, def: RegExp.$1});
530
+ }
531
+
532
+ var parts = RegExp.$1.split(':');
533
+
534
+ // Create the gradient
535
+ var grad = this.context.createLinearGradient(0,properties.marginTop,0,this.canvas.height - this.marginBottom);
536
+
537
+ var diff = 1 / (parts.length - 1);
538
+
539
+ grad.addColorStop(0, RGraph.trim(parts[0]));
540
+
541
+ for (var j=1; j<parts.length; ++j) {
542
+ grad.addColorStop(j * diff, RGraph.trim(parts[j]));
543
+ }
544
+ }
545
+
546
+ return grad ? grad : color;
547
+ };
548
+
549
+
550
+
551
+
552
+
553
+
554
+
555
+
556
+ //
557
+ // The function that draws the Y axis
558
+ //
559
+ this.drawYAxis = function ()
560
+ {
561
+ RGraph.drawYAxis(this);
562
+ };
563
+
564
+
565
+
566
+
567
+
568
+
569
+
570
+
571
+ //
572
+ // This detemines the maximum text width of either the scale or text
573
+ // labels - whichever is given
574
+ //
575
+ // @return number The maximum text width
576
+ //
577
+ this.getWidth = function ()
578
+ {
579
+ var width = this.maxLabelLength;
580
+
581
+ // Add the title width if it's specified
582
+ if (properties.yaxisTitle && properties.yaxisTitle.length) {
583
+ width += (properties.textSize * 1.5);
584
+ }
585
+
586
+ this.width = width;
587
+
588
+ return width;
589
+ };
590
+
591
+
592
+
593
+
594
+
595
+
596
+
597
+
598
+ //
599
+ // Using a function to add events makes it easier to facilitate method chaining
600
+ //
601
+ // @param string type The type of even to add
602
+ // @param function func
603
+ //
604
+ this.on = function (type, func)
605
+ {
606
+ if (type.substr(0,2) !== 'on') {
607
+ type = 'on' + type;
608
+ }
609
+
610
+ if (typeof this[type] !== 'function') {
611
+ this[type] = func;
612
+ } else {
613
+ RGraph.addCustomEventListener(this, type, func);
614
+ }
615
+
616
+ return this;
617
+ };
618
+
619
+
620
+
621
+
622
+
623
+
624
+
625
+
626
+ //
627
+ // This function runs once only
628
+ // (put at the end of the file (before any effects))
629
+ //
630
+ this.firstDrawFunc = function ()
631
+ {
632
+ };
633
+
634
+
635
+
636
+
637
+
638
+
639
+
640
+
641
+ //
642
+ // A worker function that handles Bar chart specific tooltip substitutions
643
+ //
644
+ this.tooltipSubstitutions = function (opt)
645
+ {
646
+ return {
647
+ index: 0,
648
+ dataset: 0,
649
+ sequentialIndex: 0,
650
+ value: null
651
+ };
652
+ };
653
+
654
+
655
+
656
+
657
+
658
+
659
+
660
+
661
+ //
662
+ // This allows for static tooltip positioning
663
+ //
664
+ this.positionTooltipStatic = function (args)
665
+ {
666
+ var obj = args.object,
667
+ e = args.event,
668
+ tooltip = args.tooltip,
669
+ index = args.index,
670
+ canvasXY = RGraph.getCanvasXY(obj.canvas);
671
+
672
+ // Position the tooltip in the X direction
673
+ args.tooltip.style.left = (
674
+ canvasXY[0] // The X coordinate of the canvas
675
+ - (tooltip.offsetWidth / 2) // Subtract half of the tooltip width
676
+ + obj.properties.tooltipsOffsetx // Add any user defined offset
677
+ + this.x // Add the X coordinate
678
+ - (this.getWidth() / 2)
679
+ ) + 'px';
680
+
681
+ args.tooltip.style.top = (
682
+ canvasXY[1] // The Y coordinate of the canvas
683
+ - tooltip.offsetHeight // The height of the tooltip
684
+ + obj.properties.tooltipsOffsety // Add any user defined offset
685
+ + properties.marginTop
686
+ - ((properties.textSize * 1.5) / 2) // Account for the size of the text
687
+ - 10 // An arbitrary amount
688
+ ) + 'px';
689
+ };
690
+
691
+
692
+
693
+
694
+
695
+
696
+
697
+
698
+ //
699
+ // Objects are now always registered so that the chart is redrawn if need be.
700
+ //
701
+ RGraph.register(this);
702
+
703
+
704
+
705
+
706
+
707
+
708
+
709
+
710
+ //
711
+ // This is the 'end' of the constructor so if the first argument
712
+ // contains configuration data - handle that.
713
+ //
714
+ RGraph.parseObjectStyleConfig(this, conf.options);
715
+ };