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