rhosync 2.0.9 → 2.1.0.beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +9 -0
- data/Rakefile +1 -1
- data/bench/benchapp/sources/mock_adapter.rb +2 -2
- data/bench/benchapp/tmp/restart.txt +0 -0
- data/bench/spec/mock_adapter_spec.rb +1 -1
- data/lib/rhosync/api/stats.rb +21 -0
- data/lib/rhosync/bulk_data/bulk_data.rb +1 -1
- data/lib/rhosync/client.rb +10 -0
- data/lib/rhosync/console/app/public/home.css +9 -4
- data/lib/rhosync/console/app/public/images/foot_logo_rhosync.png +0 -0
- data/lib/rhosync/console/app/public/images/landing_header.jpg +0 -0
- data/lib/rhosync/console/app/public/jqplot/excanvas.min.js +35 -0
- data/lib/rhosync/console/app/public/jqplot/jqplot.barRenderer.min.js +34 -0
- data/lib/rhosync/console/app/public/jqplot/jqplot.canvasAxisLabelRenderer.js +187 -0
- data/lib/rhosync/console/app/public/jqplot/jqplot.canvasAxisTickRenderer.js +226 -0
- data/lib/rhosync/console/app/public/jqplot/jqplot.canvasTextRenderer.js +408 -0
- data/lib/rhosync/console/app/public/jqplot/jqplot.categoryAxisRenderer.min.js +34 -0
- data/lib/rhosync/console/app/public/jqplot/jqplot.cursor.js +952 -0
- data/lib/rhosync/console/app/public/jqplot/jqplot.dateAxisRenderer.js +313 -0
- data/lib/rhosync/console/app/public/jqplot/jqplot.dateAxisRenderer.min.js +34 -0
- data/lib/rhosync/console/app/public/jqplot/jqplot.pointLabels.min.js +34 -0
- data/lib/rhosync/console/app/public/jqplot/jquery-1.4.2.min.js +154 -0
- data/lib/rhosync/console/app/public/jqplot/jquery.jqplot.min.css +1 -0
- data/lib/rhosync/console/app/public/jqplot/jquery.jqplot.min.js +34 -0
- data/lib/rhosync/console/app/routes/timing.rb +223 -7
- data/lib/rhosync/console/app/views/content.erb +1 -1
- data/lib/rhosync/console/app/views/headermenu.erb +4 -4
- data/lib/rhosync/console/app/views/jqplot.erb +52 -0
- data/lib/rhosync/console/app/views/layout.erb +86 -11
- data/lib/rhosync/console/rhosync_api.rb +19 -0
- data/lib/rhosync/jobs/bulk_data_job.rb +2 -2
- data/lib/rhosync/stats/middleware.rb +4 -6
- data/lib/rhosync/stats/record.rb +51 -26
- data/lib/rhosync/store.rb +12 -1
- data/lib/rhosync/tasks.rb +4 -2
- data/lib/rhosync/user.rb +11 -1
- data/lib/rhosync/version.rb +2 -2
- data/lib/rhosync.rb +3 -3
- data/spec/api/rhosync_api_spec.rb +26 -0
- data/spec/api/stats_spec.rb +66 -0
- data/spec/client_spec.rb +40 -0
- data/spec/client_sync_spec.rb +14 -0
- data/spec/stats/middleware_spec.rb +11 -5
- data/spec/stats/record_spec.rb +30 -11
- data/spec/store_spec.rb +15 -1
- data/spec/user_spec.rb +44 -0
- metadata +32 -14
- data/doc/protocol.html +0 -2291
- data/doc/public/css/print.css +0 -29
- data/doc/public/css/screen.css +0 -257
- data/doc/public/css/style.css +0 -20
- data/lib/rhosync/console/app/public/images/header_halo copy.jpg +0 -0
data/CHANGELOG
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 2.1.0
|
2
|
+
* #4302316 - don't allow set blank admin password
|
3
|
+
* #5672322 - stats for user count
|
4
|
+
* #5672316 - stats for device count
|
5
|
+
* #5717916 - stats api call
|
6
|
+
* #5821277 - http stats by source not showing
|
7
|
+
* #5899454 - move lock prefix to beginning so we don't return stats keys with it
|
8
|
+
* #5822966 - bulk sync data file cannot handle space in the username
|
9
|
+
|
1
10
|
## 2.0.9
|
2
11
|
* #5154725 - stats framework
|
3
12
|
* #5013521 - new web interface style
|
data/Rakefile
CHANGED
@@ -56,7 +56,7 @@ begin
|
|
56
56
|
gemspec.authors = ["Rhomobile"]
|
57
57
|
gemspec.email = %q{dev@rhomobile.com}
|
58
58
|
gemspec.version = Rhosync::VERSION
|
59
|
-
gemspec.files = FileList["[A-Z]*", "{bench,bin,
|
59
|
+
gemspec.files = FileList["[A-Z]*", "{bench,bin,generators,lib,spec,tasks}/**/*"]
|
60
60
|
|
61
61
|
# TODO: Due to https://www.pivotaltracker.com/story/show/3417862, we can't use JSON 1.4.3
|
62
62
|
gemspec.add_dependency "json", "~>1.4.2"
|
File without changes
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Server.api :stats do |params,user|
|
2
|
+
if Rhosync.stats == true
|
3
|
+
names = params[:names]
|
4
|
+
if names
|
5
|
+
Rhosync::Stats::Record.keys(names).to_json
|
6
|
+
else
|
7
|
+
metric = params[:metric]
|
8
|
+
rtype = Rhosync::Stats::Record.rtype(metric)
|
9
|
+
if rtype == 'zset'
|
10
|
+
# returns [] if no results
|
11
|
+
Rhosync::Stats::Record.range(metric,params[:start],params[:finish]).to_json
|
12
|
+
elsif rtype == 'string'
|
13
|
+
Rhosync::Stats::Record.get_value(metric) || ''
|
14
|
+
else
|
15
|
+
raise ApiException.new(404, "Unknown metric")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
else
|
19
|
+
raise ApiException.new(500, "Stats not enabled")
|
20
|
+
end
|
21
|
+
end
|
data/lib/rhosync/client.rb
CHANGED
@@ -20,6 +20,11 @@ module Rhosync
|
|
20
20
|
res = super(fields,params)
|
21
21
|
user = User.load(fields[:user_id])
|
22
22
|
user.clients << res.id
|
23
|
+
if Rhosync.stats
|
24
|
+
Rhosync::Stats::Record.set('clients') { Store.incr('client:count') }
|
25
|
+
else
|
26
|
+
Store.incr('client:count')
|
27
|
+
end
|
23
28
|
res
|
24
29
|
end
|
25
30
|
|
@@ -46,6 +51,11 @@ module Rhosync
|
|
46
51
|
def delete
|
47
52
|
flash_data('*')
|
48
53
|
Rhosync.license.free_seat
|
54
|
+
if Rhosync.stats
|
55
|
+
Rhosync::Stats::Record.set('clients') { Store.decr('client:count') }
|
56
|
+
else
|
57
|
+
Store.decr('client:count')
|
58
|
+
end
|
49
59
|
super
|
50
60
|
end
|
51
61
|
|
@@ -14,13 +14,16 @@ Description:
|
|
14
14
|
.container{
|
15
15
|
min-height:100%;
|
16
16
|
position:relative;
|
17
|
+
|
17
18
|
}
|
18
19
|
|
20
|
+
|
19
21
|
.wrapper{
|
20
22
|
display:block;
|
21
23
|
margin:0 auto 0;
|
22
24
|
overflow:hidden;
|
23
25
|
width:960px;
|
26
|
+
|
24
27
|
}
|
25
28
|
|
26
29
|
a{
|
@@ -52,8 +55,8 @@ h1.slogan{
|
|
52
55
|
/**** Body
|
53
56
|
****/
|
54
57
|
html{
|
55
|
-
font-size:
|
56
|
-
background:url("images/landing_header.jpg") repeat-x scroll 0 0
|
58
|
+
font-size: 14px;
|
59
|
+
background:url("images/landing_header.jpg") repeat-x scroll 0 0 #bbbbbb;
|
57
60
|
}
|
58
61
|
body{
|
59
62
|
margin:0;
|
@@ -76,7 +79,7 @@ body{
|
|
76
79
|
float:left;
|
77
80
|
height:38px;
|
78
81
|
text-indent:-3000px;
|
79
|
-
width:
|
82
|
+
width:175px;
|
80
83
|
}
|
81
84
|
.header .logos a.logo_rhomobile{
|
82
85
|
background:url("images/logo_rhosync.png") no-repeat scroll 0 0 transparent;
|
@@ -91,9 +94,11 @@ body{
|
|
91
94
|
}
|
92
95
|
|
93
96
|
.header_landing{
|
94
|
-
background:url("images/header_halo.jpg") no-repeat scroll 50% 0 transparent
|
97
|
+
/* background:url("images/header_halo.jpg") no-repeat scroll 50% 0 transparent;*/
|
95
98
|
height: 455px;
|
96
99
|
padding-top:85px;
|
100
|
+
|
101
|
+
|
97
102
|
}
|
98
103
|
.header_landing .col_1{
|
99
104
|
float:left;
|
Binary file
|
Binary file
|
@@ -0,0 +1,35 @@
|
|
1
|
+
document.createElement("canvas").getContext||function(){function Z(){return this.context_||(this.context_=new C(this))}function $(a,b){var c=P.call(arguments,2);return function(){return a.apply(b,c.concat(P.call(arguments)))}}function Q(a){return String(a).replace(/&/g,"&").replace(/"/g,""")}function R(a,b,c){a.namespaces[b]||a.namespaces.add(b,c,"#default#VML")}function S(a){R(a,"g_vml_","urn:schemas-microsoft-com:vml");R(a,"g_o_","urn:schemas-microsoft-com:office:office");if(!a.styleSheets.ex_canvas_){a=
|
2
|
+
a.createStyleSheet();a.owningElement.id="ex_canvas_";a.cssText="canvas{display:inline-block;overflow:hidden;text-align:left;width:300px;height:150px}"}}function aa(a){var b=a.srcElement;switch(a.propertyName){case "width":b.getContext().clearRect();b.style.width=b.attributes.width.nodeValue+"px";b.firstChild.style.width=b.clientWidth+"px";break;case "height":b.getContext().clearRect();b.style.height=b.attributes.height.nodeValue+"px";b.firstChild.style.height=b.clientHeight+"px";break}}function ba(a){a=
|
3
|
+
a.srcElement;if(a.firstChild){a.firstChild.style.width=a.clientWidth+"px";a.firstChild.style.height=a.clientHeight+"px"}}function D(){return[[1,0,0],[0,1,0],[0,0,1]]}function u(a,b){for(var c=D(),d=0;d<3;d++)for(var e=0;e<3;e++){for(var f=0,h=0;h<3;h++)f+=a[d][h]*b[h][e];c[d][e]=f}return c}function T(a,b){b.fillStyle=a.fillStyle;b.lineCap=a.lineCap;b.lineJoin=a.lineJoin;b.lineWidth=a.lineWidth;b.miterLimit=a.miterLimit;b.shadowBlur=a.shadowBlur;b.shadowColor=a.shadowColor;b.shadowOffsetX=a.shadowOffsetX;
|
4
|
+
b.shadowOffsetY=a.shadowOffsetY;b.strokeStyle=a.strokeStyle;b.globalAlpha=a.globalAlpha;b.font=a.font;b.textAlign=a.textAlign;b.textBaseline=a.textBaseline;b.arcScaleX_=a.arcScaleX_;b.arcScaleY_=a.arcScaleY_;b.lineScale_=a.lineScale_}function U(a){var b=a.indexOf("(",3),c=a.indexOf(")",b+1);b=a.substring(b+1,c).split(",");if(b.length!=4||a.charAt(3)!="a")b[3]=1;return b}function E(a){return parseFloat(a)/100}function F(a,b,c){return Math.min(c,Math.max(b,a))}function ca(a){var b,c;c=parseFloat(a[0])/
|
5
|
+
360%360;c<0&&c++;b=F(E(a[1]),0,1);a=F(E(a[2]),0,1);if(b==0)b=a=c=a;else{var d=a<0.5?a*(1+b):a+b-a*b,e=2*a-d;b=G(e,d,c+1/3);a=G(e,d,c);c=G(e,d,c-1/3)}return"#"+v[Math.floor(b*255)]+v[Math.floor(a*255)]+v[Math.floor(c*255)]}function G(a,b,c){c<0&&c++;c>1&&c--;return 6*c<1?a+(b-a)*6*c:2*c<1?b:3*c<2?a+(b-a)*(2/3-c)*6:a}function H(a){if(a in I)return I[a];var b,c=1;a=String(a);if(a.charAt(0)=="#")b=a;else if(/^rgb/.test(a)){c=U(a);b="#";for(var d,e=0;e<3;e++){d=c[e].indexOf("%")!=-1?Math.floor(E(c[e])*
|
6
|
+
255):+c[e];b+=v[F(d,0,255)]}c=+c[3]}else if(/^hsl/.test(a)){c=U(a);b=ca(c);c=c[3]}else b=da[a]||a;return I[a]={color:b,alpha:c}}function ea(a){if(J[a])return J[a];var b=document.createElement("div").style;try{b.font=a}catch(c){}return J[a]={style:b.fontStyle||w.style,variant:b.fontVariant||w.variant,weight:b.fontWeight||w.weight,size:b.fontSize||w.size,family:b.fontFamily||w.family}}function fa(a,b){var c={};for(var d in a)c[d]=a[d];b=parseFloat(b.currentStyle.fontSize);d=parseFloat(a.size);c.size=
|
7
|
+
typeof a.size=="number"?a.size:a.size.indexOf("px")!=-1?d:a.size.indexOf("em")!=-1?b*d:a.size.indexOf("%")!=-1?b/100*d:a.size.indexOf("pt")!=-1?d/0.75:b;c.size*=0.981;return c}function ga(a){return a.style+" "+a.variant+" "+a.weight+" "+a.size+"px "+a.family}function ha(a){return ia[a]||"square"}function C(a){this.m_=D();this.mStack_=[];this.aStack_=[];this.currentPath_=[];this.fillStyle=this.strokeStyle="#000";this.lineWidth=1;this.lineJoin="miter";this.lineCap="butt";this.miterLimit=l*1;this.globalAlpha=
|
8
|
+
1;this.font="10px sans-serif";this.textAlign="left";this.textBaseline="alphabetic";this.canvas=a;var b="width:"+a.clientWidth+"px;height:"+a.clientHeight+"px;overflow:hidden;position:absolute",c=a.ownerDocument.createElement("div");c.style.cssText=b;a.appendChild(c);b=c.cloneNode(false);b.style.backgroundColor="red";b.style.filter="alpha(opacity=0)";a.appendChild(b);this.element_=c;this.lineScale_=this.arcScaleY_=this.arcScaleX_=1}function V(a,b,c,d){a.currentPath_.push({type:"bezierCurveTo",cp1x:b.x,
|
9
|
+
cp1y:b.y,cp2x:c.x,cp2y:c.y,x:d.x,y:d.y});a.currentX_=d.x;a.currentY_=d.y}function W(a,b){var c=H(a.strokeStyle),d=c.color;c=c.alpha*a.globalAlpha;var e=a.lineScale_*a.lineWidth;if(e<1)c*=e;b.push("<g_vml_:stroke",' opacity="',c,'"',' joinstyle="',a.lineJoin,'"',' miterlimit="',a.miterLimit,'"',' endcap="',ha(a.lineCap),'"',' weight="',e,'px"',' color="',d,'" />')}function X(a,b,c,d){var e=a.fillStyle,f=a.arcScaleX_,h=a.arcScaleY_,j=d.x-c.x,m=d.y-c.y;if(e instanceof x){var k=0;d={x:0,y:0};var q=0,
|
10
|
+
o=1;if(e.type_=="gradient"){k=e.x1_/f;c=e.y1_/h;var n=p(a,e.x0_/f,e.y0_/h);k=p(a,k,c);k=Math.atan2(k.x-n.x,k.y-n.y)*180/Math.PI;if(k<0)k+=360;if(k<1.0E-6)k=0}else{n=p(a,e.x0_,e.y0_);d={x:(n.x-c.x)/j,y:(n.y-c.y)/m};j/=f*l;m/=h*l;o=r.max(j,m);q=2*e.r0_/o;o=2*e.r1_/o-q}f=e.colors_;f.sort(function(A,ja){return A.offset-ja.offset});h=f.length;n=f[0].color;c=f[h-1].color;j=f[0].alpha*a.globalAlpha;a=f[h-1].alpha*a.globalAlpha;m=[];for(var s=0;s<h;s++){var y=f[s];m.push(y.offset*o+q+" "+y.color)}b.push('<g_vml_:fill type="',
|
11
|
+
e.type_,'"',' method="none" focus="100%"',' color="',n,'"',' color2="',c,'"',' colors="',m.join(","),'"',' opacity="',a,'"',' g_o_:opacity2="',j,'"',' angle="',k,'"',' focusposition="',d.x,",",d.y,'" />')}else if(e instanceof K)j&&m&&b.push("<g_vml_:fill",' position="',-c.x/j*f*f,",",-c.y/m*h*h,'"',' type="tile"',' src="',e.src_,'" />');else{e=H(a.fillStyle);b.push('<g_vml_:fill color="',e.color,'" opacity="',e.alpha*a.globalAlpha,'" />')}}function p(a,b,c){a=a.m_;return{x:l*(b*a[0][0]+c*a[1][0]+
|
12
|
+
a[2][0])-t,y:l*(b*a[0][1]+c*a[1][1]+a[2][1])-t}}function ka(a){return isFinite(a[0][0])&&isFinite(a[0][1])&&isFinite(a[1][0])&&isFinite(a[1][1])&&isFinite(a[2][0])&&isFinite(a[2][1])}function z(a,b,c){if(ka(b)){a.m_=b;if(c)a.lineScale_=la(ma(b[0][0]*b[1][1]-b[0][1]*b[1][0]))}}function x(a){this.type_=a;this.r1_=this.y1_=this.x1_=this.r0_=this.y0_=this.x0_=0;this.colors_=[]}function K(a,b){na(a);switch(b){case "repeat":case null:case "":this.repetition_="repeat";break;case "repeat-x":case "repeat-y":case "no-repeat":this.repetition_=
|
13
|
+
b;break;default:L("SYNTAX_ERR")}this.src_=a.src;this.width_=a.width;this.height_=a.height}function L(a){throw new M(a);}function na(a){if(!a||a.nodeType!=1||a.tagName!="IMG")L("TYPE_MISMATCH_ERR");a.readyState!="complete"&&L("INVALID_STATE_ERR")}function M(a){this.code=this[a];this.message=a+": DOM Exception "+this.code}var r=Math,i=r.round,N=r.sin,O=r.cos,ma=r.abs,la=r.sqrt,l=10,t=l/2;navigator.userAgent.match(/MSIE ([\d.]+)?/);var P=Array.prototype.slice;S(document);var Y={init:function(a){a=a||
|
14
|
+
document;a.createElement("canvas");a.attachEvent("onreadystatechange",$(this.init_,this,a))},init_:function(a){a=a.getElementsByTagName("canvas");for(var b=0;b<a.length;b++)this.initElement(a[b])},initElement:function(a){if(!a.getContext){a.getContext=Z;S(a.ownerDocument);a.innerHTML="";a.attachEvent("onpropertychange",aa);a.attachEvent("onresize",ba);var b=a.attributes;if(b.width&&b.width.specified)a.style.width=b.width.nodeValue+"px";else a.width=a.clientWidth;if(b.height&&b.height.specified)a.style.height=
|
15
|
+
b.height.nodeValue+"px";else a.height=a.clientHeight}return a}};Y.init();for(var v=[],g=0;g<16;g++)for(var B=0;B<16;B++)v[g*16+B]=g.toString(16)+B.toString(16);var da={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000000",blanchedalmond:"#FFEBCD",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",
|
16
|
+
cyan:"#00FFFF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgreen:"#006400",darkgrey:"#A9A9A9",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",
|
17
|
+
firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",goldenrod:"#DAA520",grey:"#808080",greenyellow:"#ADFF2F",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgreen:"#90EE90",lightgrey:"#D3D3D3",
|
18
|
+
lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",
|
19
|
+
mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",oldlace:"#FDF5E6",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",
|
20
|
+
skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",whitesmoke:"#F5F5F5",yellowgreen:"#9ACD32"},I={},w={style:"normal",variant:"normal",weight:"normal",size:10,family:"sans-serif"},J={},ia={butt:"flat",round:"round"};g=C.prototype;g.clearRect=function(){if(this.textMeasureEl_){this.textMeasureEl_.removeNode(true);this.textMeasureEl_=
|
21
|
+
null}this.element_.innerHTML=""};g.beginPath=function(){this.currentPath_=[]};g.moveTo=function(a,b){a=p(this,a,b);this.currentPath_.push({type:"moveTo",x:a.x,y:a.y});this.currentX_=a.x;this.currentY_=a.y};g.lineTo=function(a,b){a=p(this,a,b);this.currentPath_.push({type:"lineTo",x:a.x,y:a.y});this.currentX_=a.x;this.currentY_=a.y};g.bezierCurveTo=function(a,b,c,d,e,f){e=p(this,e,f);a=p(this,a,b);c=p(this,c,d);V(this,a,c,e)};g.quadraticCurveTo=function(a,b,c,d){a=p(this,a,b);c=p(this,c,d);d={x:this.currentX_+
|
22
|
+
2/3*(a.x-this.currentX_),y:this.currentY_+2/3*(a.y-this.currentY_)};V(this,d,{x:d.x+(c.x-this.currentX_)/3,y:d.y+(c.y-this.currentY_)/3},c)};g.arc=function(a,b,c,d,e,f){c*=l;var h=f?"at":"wa",j=a+O(d)*c-t,m=b+N(d)*c-t;d=a+O(e)*c-t;e=b+N(e)*c-t;if(j==d&&!f)j+=0.125;a=p(this,a,b);j=p(this,j,m);d=p(this,d,e);this.currentPath_.push({type:h,x:a.x,y:a.y,radius:c,xStart:j.x,yStart:j.y,xEnd:d.x,yEnd:d.y})};g.rect=function(a,b,c,d){this.moveTo(a,b);this.lineTo(a+c,b);this.lineTo(a+c,b+d);this.lineTo(a,b+d);
|
23
|
+
this.closePath()};g.strokeRect=function(a,b,c,d){var e=this.currentPath_;this.beginPath();this.moveTo(a,b);this.lineTo(a+c,b);this.lineTo(a+c,b+d);this.lineTo(a,b+d);this.closePath();this.stroke();this.currentPath_=e};g.fillRect=function(a,b,c,d){var e=this.currentPath_;this.beginPath();this.moveTo(a,b);this.lineTo(a+c,b);this.lineTo(a+c,b+d);this.lineTo(a,b+d);this.closePath();this.fill();this.currentPath_=e};g.createLinearGradient=function(a,b,c,d){var e=new x("gradient");e.x0_=a;e.y0_=b;e.x1_=
|
24
|
+
c;e.y1_=d;return e};g.createRadialGradient=function(a,b,c,d,e,f){var h=new x("gradientradial");h.x0_=a;h.y0_=b;h.r0_=c;h.x1_=d;h.y1_=e;h.r1_=f;return h};g.drawImage=function(a){var b,c,d,e,f,h,j,m;d=a.runtimeStyle.width;e=a.runtimeStyle.height;a.runtimeStyle.width="auto";a.runtimeStyle.height="auto";var k=a.width,q=a.height;a.runtimeStyle.width=d;a.runtimeStyle.height=e;if(arguments.length==3){b=arguments[1];c=arguments[2];f=h=0;j=d=k;m=e=q}else if(arguments.length==5){b=arguments[1];c=arguments[2];
|
25
|
+
d=arguments[3];e=arguments[4];f=h=0;j=k;m=q}else if(arguments.length==9){f=arguments[1];h=arguments[2];j=arguments[3];m=arguments[4];b=arguments[5];c=arguments[6];d=arguments[7];e=arguments[8]}else throw Error("Invalid number of arguments");var o=p(this,b,c),n=[];n.push(" <g_vml_:group",' coordsize="',l*10,",",l*10,'"',' coordorigin="0,0"',' style="width:',10,"px;height:",10,"px;position:absolute;");if(this.m_[0][0]!=1||this.m_[0][1]||this.m_[1][1]!=1||this.m_[1][0]){var s=[];s.push("M11=",this.m_[0][0],
|
26
|
+
",","M12=",this.m_[1][0],",","M21=",this.m_[0][1],",","M22=",this.m_[1][1],",","Dx=",i(o.x/l),",","Dy=",i(o.y/l),"");var y=p(this,b+d,c),A=p(this,b,c+e);b=p(this,b+d,c+e);o.x=r.max(o.x,y.x,A.x,b.x);o.y=r.max(o.y,y.y,A.y,b.y);n.push("padding:0 ",i(o.x/l),"px ",i(o.y/l),"px 0;filter:progid:DXImageTransform.Microsoft.Matrix(",s.join(""),", sizingmethod='clip');")}else n.push("top:",i(o.y/l),"px;left:",i(o.x/l),"px;");n.push(' ">','<g_vml_:image src="',a.src,'"',' style="width:',l*d,"px;"," height:",
|
27
|
+
l*e,'px"',' cropleft="',f/k,'"',' croptop="',h/q,'"',' cropright="',(k-f-j)/k,'"',' cropbottom="',(q-h-m)/q,'"'," />","</g_vml_:group>");this.element_.insertAdjacentHTML("BeforeEnd",n.join(""))};g.stroke=function(a){var b=[];b.push("<g_vml_:shape",' filled="',!!a,'"',' style="position:absolute;width:',10,"px;height:",10,'px;"',' coordorigin="0,0"',' coordsize="',l*10,",",l*10,'"',' stroked="',!a,'"',' path="');for(var c={x:null,y:null},d={x:null,y:null},e=0;e<this.currentPath_.length;e++){var f=this.currentPath_[e];
|
28
|
+
switch(f.type){case "moveTo":b.push(" m ",i(f.x),",",i(f.y));break;case "lineTo":b.push(" l ",i(f.x),",",i(f.y));break;case "close":b.push(" x ");f=null;break;case "bezierCurveTo":b.push(" c ",i(f.cp1x),",",i(f.cp1y),",",i(f.cp2x),",",i(f.cp2y),",",i(f.x),",",i(f.y));break;case "at":case "wa":b.push(" ",f.type," ",i(f.x-this.arcScaleX_*f.radius),",",i(f.y-this.arcScaleY_*f.radius)," ",i(f.x+this.arcScaleX_*f.radius),",",i(f.y+this.arcScaleY_*f.radius)," ",i(f.xStart),",",i(f.yStart)," ",i(f.xEnd),
|
29
|
+
",",i(f.yEnd));break}if(f){if(c.x==null||f.x<c.x)c.x=f.x;if(d.x==null||f.x>d.x)d.x=f.x;if(c.y==null||f.y<c.y)c.y=f.y;if(d.y==null||f.y>d.y)d.y=f.y}}b.push(' ">');a?X(this,b,c,d):W(this,b);b.push("</g_vml_:shape>");this.element_.insertAdjacentHTML("beforeEnd",b.join(""))};g.fill=function(){this.stroke(true)};g.closePath=function(){this.currentPath_.push({type:"close"})};g.save=function(){var a={};T(this,a);this.aStack_.push(a);this.mStack_.push(this.m_);this.m_=u(D(),this.m_)};g.restore=function(){if(this.aStack_.length){T(this.aStack_.pop(),
|
30
|
+
this);this.m_=this.mStack_.pop()}};g.translate=function(a,b){z(this,u([[1,0,0],[0,1,0],[a,b,1]],this.m_),false)};g.rotate=function(a){var b=O(a);a=N(a);z(this,u([[b,a,0],[-a,b,0],[0,0,1]],this.m_),false)};g.scale=function(a,b){this.arcScaleX_*=a;this.arcScaleY_*=b;z(this,u([[a,0,0],[0,b,0],[0,0,1]],this.m_),true)};g.transform=function(a,b,c,d,e,f){z(this,u([[a,b,0],[c,d,0],[e,f,1]],this.m_),true)};g.setTransform=function(a,b,c,d,e,f){z(this,[[a,b,0],[c,d,0],[e,f,1]],true)};g.drawText_=function(a,
|
31
|
+
b,c,d,e){var f=this.m_;d=0;var h=1E3,j={x:0,y:0},m=[],k=fa(ea(this.font),this.element_),q=ga(k),o=this.element_.currentStyle,n=this.textAlign.toLowerCase();switch(n){case "left":case "center":case "right":break;case "end":n=o.direction=="ltr"?"right":"left";break;case "start":n=o.direction=="rtl"?"right":"left";break;default:n="left"}switch(this.textBaseline){case "hanging":case "top":j.y=k.size/1.75;break;case "middle":break;default:case null:case "alphabetic":case "ideographic":case "bottom":j.y=
|
32
|
+
-k.size/2.25;break}switch(n){case "right":d=1E3;h=0.05;break;case "center":d=h=500;break}b=p(this,b+j.x,c+j.y);m.push('<g_vml_:line from="',-d,' 0" to="',h,' 0.05" ',' coordsize="100 100" coordorigin="0 0"',' filled="',!e,'" stroked="',!!e,'" style="position:absolute;width:1px;height:1px;">');e?W(this,m):X(this,m,{x:-d,y:0},{x:h,y:k.size});e=f[0][0].toFixed(3)+","+f[1][0].toFixed(3)+","+f[0][1].toFixed(3)+","+f[1][1].toFixed(3)+",0,0";b=i(b.x/l)+","+i(b.y/l);m.push('<g_vml_:skew on="t" matrix="',
|
33
|
+
e,'" ',' offset="',b,'" origin="',d,' 0" />','<g_vml_:path textpathok="true" />','<g_vml_:textpath on="true" string="',Q(a),'" style="v-text-align:',n,";font:",Q(q),'" /></g_vml_:line>');this.element_.insertAdjacentHTML("beforeEnd",m.join(""))};g.fillText=function(a,b,c,d){this.drawText_(a,b,c,d,false)};g.strokeText=function(a,b,c,d){this.drawText_(a,b,c,d,true)};g.measureText=function(a){if(!this.textMeasureEl_){this.element_.insertAdjacentHTML("beforeEnd",'<span style="position:absolute;top:-20000px;left:0;padding:0;margin:0;border:none;white-space:pre;"></span>');
|
34
|
+
this.textMeasureEl_=this.element_.lastChild}var b=this.element_.ownerDocument;this.textMeasureEl_.innerHTML="";this.textMeasureEl_.style.font=this.font;this.textMeasureEl_.appendChild(b.createTextNode(a));return{width:this.textMeasureEl_.offsetWidth}};g.clip=function(){};g.arcTo=function(){};g.createPattern=function(a,b){return new K(a,b)};x.prototype.addColorStop=function(a,b){b=H(b);this.colors_.push({offset:a,color:b.color,alpha:b.alpha})};g=M.prototype=new Error;g.INDEX_SIZE_ERR=1;g.DOMSTRING_SIZE_ERR=
|
35
|
+
2;g.HIERARCHY_REQUEST_ERR=3;g.WRONG_DOCUMENT_ERR=4;g.INVALID_CHARACTER_ERR=5;g.NO_DATA_ALLOWED_ERR=6;g.NO_MODIFICATION_ALLOWED_ERR=7;g.NOT_FOUND_ERR=8;g.NOT_SUPPORTED_ERR=9;g.INUSE_ATTRIBUTE_ERR=10;g.INVALID_STATE_ERR=11;g.SYNTAX_ERR=12;g.INVALID_MODIFICATION_ERR=13;g.NAMESPACE_ERR=14;g.INVALID_ACCESS_ERR=15;g.VALIDATION_ERR=16;g.TYPE_MISMATCH_ERR=17;G_vmlCanvasManager=Y;CanvasRenderingContext2D=C;CanvasGradient=x;CanvasPattern=K;DOMException=M}();
|
@@ -0,0 +1,34 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2009 - 2010 Chris Leonello
|
3
|
+
* jqPlot is currently available for use in all personal or commercial projects
|
4
|
+
* under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
|
5
|
+
* version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
|
6
|
+
* choose the license that best suits your project and use it accordingly.
|
7
|
+
*
|
8
|
+
* Although not required, the author would appreciate an email letting him
|
9
|
+
* know of any substantial use of jqPlot. You can reach the author at:
|
10
|
+
* chris at jqplot or see http://www.jqplot.com/info.php .
|
11
|
+
*
|
12
|
+
* If you are feeling kind and generous, consider supporting the project by
|
13
|
+
* making a donation at: http://www.jqplot.com/donate.php .
|
14
|
+
*
|
15
|
+
* jqPlot includes date instance methods and printf/sprintf functions by other authors:
|
16
|
+
*
|
17
|
+
* Date instance methods contained in jqplot.dateMethods.js:
|
18
|
+
*
|
19
|
+
* author Ken Snyder (ken d snyder at gmail dot com)
|
20
|
+
* date 2008-09-10
|
21
|
+
* version 2.0.2 (http://kendsnyder.com/sandbox/date/)
|
22
|
+
* license Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/)
|
23
|
+
*
|
24
|
+
* JavaScript printf/sprintf functions contained in jqplot.sprintf.js:
|
25
|
+
*
|
26
|
+
* version 2007.04.27
|
27
|
+
* author Ash Searle
|
28
|
+
* http://hexmen.com/blog/2007/03/printf-sprintf/
|
29
|
+
* http://hexmen.com/js/sprintf.js
|
30
|
+
* The author (Ash Searle) has placed this code in the public domain:
|
31
|
+
* "This code is unrestricted: you are free to use it however you like."
|
32
|
+
*
|
33
|
+
*/
|
34
|
+
(function(d){d.jqplot.BarRenderer=function(){d.jqplot.LineRenderer.call(this)};d.jqplot.BarRenderer.prototype=new d.jqplot.LineRenderer();d.jqplot.BarRenderer.prototype.constructor=d.jqplot.BarRenderer;d.jqplot.BarRenderer.prototype.init=function(o,q){this.barPadding=8;this.barMargin=10;this.barDirection="vertical";this.barWidth=null;this.shadowOffset=2;this.shadowDepth=5;this.shadowAlpha=0.08;this.waterfall=false;this.groups=1;this.varyBarColor=false;this.highlightMouseOver=true;this.highlightMouseDown=false;this.highlightColors=[];if(o.highlightMouseDown&&o.highlightMouseOver==null){o.highlightMouseOver=false}d.extend(true,this,o);this.fill=true;if(this.waterfall){this.fillToZero=false;this.disableStack=true}if(this.barDirection=="vertical"){this._primaryAxis="_xaxis";this._stackAxis="y";this.fillAxis="y"}else{this._primaryAxis="_yaxis";this._stackAxis="x";this.fillAxis="x"}this._highlightedPoint=null;this._plotSeriesInfo=null;this._dataColors=[];this._barPoints=[];var p={lineJoin:"miter",lineCap:"round",fill:true,isarc:false,strokeStyle:this.color,fillStyle:this.color,closePath:this.fill};this.renderer.shapeRenderer.init(p);var n={lineJoin:"miter",lineCap:"round",fill:true,isarc:false,angle:this.shadowAngle,offset:this.shadowOffset,alpha:this.shadowAlpha,depth:this.shadowDepth,closePath:this.fill};this.renderer.shadowRenderer.init(n);q.postInitHooks.addOnce(h);q.postDrawHooks.addOnce(j);q.eventListenerHooks.addOnce("jqplotMouseMove",b);q.eventListenerHooks.addOnce("jqplotMouseDown",a);q.eventListenerHooks.addOnce("jqplotMouseUp",l);q.eventListenerHooks.addOnce("jqplotClick",e);q.eventListenerHooks.addOnce("jqplotRightClick",m)};function g(t,p,o,w){if(this.rendererOptions.barDirection=="horizontal"){this._stackAxis="x";this._primaryAxis="_yaxis"}if(this.rendererOptions.waterfall==true){this._data=d.extend(true,[],this.data);var s=0;var u=(!this.rendererOptions.barDirection||this.rendererOptions.barDirection=="vertical")?1:0;for(var q=0;q<this.data.length;q++){s+=this.data[q][u];if(q>0){this.data[q][u]+=this.data[q-1][u]}}this.data[this.data.length]=(u==1)?[this.data.length+1,s]:[s,this.data.length+1];this._data[this._data.length]=(u==1)?[this._data.length+1,s]:[s,this._data.length+1]}if(this.rendererOptions.groups>1){this.breakOnNull=true;var n=this.data.length;var v=parseInt(n/this.rendererOptions.groups,10);var r=0;for(var q=v;q<n;q+=v){this.data.splice(q+r,0,[null,null]);r++}for(q=0;q<this.data.length;q++){if(this._primaryAxis=="_xaxis"){this.data[q][0]=q+1}else{this.data[q][1]=q+1}}}}d.jqplot.preSeriesInitHooks.push(g);d.jqplot.BarRenderer.prototype.calcSeriesNumbers=function(){var r=0;var t=0;var q=this[this._primaryAxis];var p,o,u;for(var n=0;n<q._series.length;n++){o=q._series[n];if(o===this){u=n}if(o.renderer.constructor==d.jqplot.BarRenderer){r+=o.data.length;t+=1}}return[r,t,u]};d.jqplot.BarRenderer.prototype.setBarWidth=function(){var q;var n=0;var o=0;var t=this[this._primaryAxis];var x,r,v;var w=this._plotSeriesInfo=this.renderer.calcSeriesNumbers.call(this);n=w[0];o=w[1];var u=t.numberTicks;var p=(u-1)/2;if(t.name=="xaxis"||t.name=="x2axis"){if(this._stack){this.barWidth=(t._offsets.max-t._offsets.min)/n*o-this.barMargin}else{this.barWidth=((t._offsets.max-t._offsets.min)/p-this.barPadding*(o-1)-this.barMargin*2)/o}}else{if(this._stack){this.barWidth=(t._offsets.min-t._offsets.max)/n*o-this.barMargin}else{this.barWidth=((t._offsets.min-t._offsets.max)/p-this.barPadding*(o-1)-this.barMargin*2)/o}}return[n,o]};function f(o){var q=[];for(var s=0;s<o.length;s++){var r=d.jqplot.getColorComponents(o[s]);var n=[r[0],r[1],r[2]];var t=n[0]+n[1]+n[2];for(var p=0;p<3;p++){n[p]=(t>570)?n[p]*0.8:n[p]+0.3*(255-n[p]);n[p]=parseInt(n[p],10)}q.push("rgb("+n[0]+","+n[1]+","+n[2]+")")}return q}d.jqplot.BarRenderer.prototype.draw=function(E,J,q){var G;var A=(q!=undefined)?q:{};var v=(A.shadow!=undefined)?A.shadow:this.shadow;var M=(A.showLine!=undefined)?A.showLine:this.showLine;var F=(A.fill!=undefined)?A.fill:this.fill;var p=this.xaxis;var H=this.yaxis;var y=this._xaxis.series_u2p;var I=this._yaxis.series_u2p;var D,C,x,w,s;this._dataColors=[];this._barPoints=[];if(this.barWidth==null){this.renderer.setBarWidth.call(this)}var L=this._plotSeriesInfo=this.renderer.calcSeriesNumbers.call(this);x=L[0];w=L[1];s=L[2];if(this._stack){this._barNudge=0}else{this._barNudge=(-Math.abs(w/2-0.5)+s)*(this.barWidth+this.barPadding)}if(M){var u=new d.jqplot.ColorGenerator(this.negativeSeriesColors);var B=new d.jqplot.ColorGenerator(this.seriesColors);var K=u.get(this.index);if(!this.useNegativeColors){K=A.fillStyle}var t=A.fillStyle;if(this.barDirection=="vertical"){for(var G=0;G<J.length;G++){if(this.data[G][1]==null){continue}points=[];var r=J[G][0]+this._barNudge;var o;if(this._stack&&this._prevGridData.length){o=this._prevGridData[G][1]}else{if(this.fillToZero){o=this._yaxis.series_u2p(0)}else{if(this.waterfall&&G>0&&G<this.gridData.length-1){o=this.gridData[G-1][1]}else{o=E.canvas.height}}}if((this.fillToZero&&this._plotData[G][1]<0)||(this.waterfall&&this._data[G][1]<0)){if(this.varyBarColor&&!this._stack){if(this.useNegativeColors){A.fillStyle=u.next()}else{A.fillStyle=B.next()}}else{A.fillStyle=K}}else{if(this.varyBarColor&&!this._stack){A.fillStyle=B.next()}else{A.fillStyle=t}}points.push([r-this.barWidth/2,o]);points.push([r-this.barWidth/2,J[G][1]]);points.push([r+this.barWidth/2,J[G][1]]);points.push([r+this.barWidth/2,o]);this._barPoints.push(points);if(v&&!this._stack){var z=d.extend(true,{},A);delete z.fillStyle;this.renderer.shadowRenderer.draw(E,points,z)}var n=A.fillStyle||this.color;this._dataColors.push(n);this.renderer.shapeRenderer.draw(E,points,A)}}else{if(this.barDirection=="horizontal"){for(var G=0;G<J.length;G++){if(this.data[G][0]==null){continue}points=[];var r=J[G][1]-this._barNudge;var N;if(this._stack&&this._prevGridData.length){N=this._prevGridData[G][0]}else{if(this.fillToZero){N=this._xaxis.series_u2p(0)}else{if(this.waterfall&&G>0&&G<this.gridData.length-1){N=this.gridData[G-1][1]}else{N=0}}}if((this.fillToZero&&this._plotData[G][1]<0)||(this.waterfall&&this._data[G][1]<0)){if(this.varyBarColor&&!this._stack){if(this.useNegativeColors){A.fillStyle=u.next()}else{A.fillStyle=B.next()}}}else{if(this.varyBarColor&&!this._stack){A.fillStyle=B.next()}else{A.fillStyle=t}}points.push([N,r+this.barWidth/2]);points.push([N,r-this.barWidth/2]);points.push([J[G][0],r-this.barWidth/2]);points.push([J[G][0],r+this.barWidth/2]);this._barPoints.push(points);if(v&&!this._stack){var z=d.extend(true,{},A);delete z.fillStyle;this.renderer.shadowRenderer.draw(E,points,z)}var n=A.fillStyle||this.color;this._dataColors.push(n);this.renderer.shapeRenderer.draw(E,points,A)}}}}if(this.highlightColors.length==0){this.highlightColors=f(this._dataColors)}else{if(typeof(this.highlightColors)=="string"){var L=this.highlightColors;this.highlightColors=[];for(var G=0;G<this._dataColors.length;G++){this.highlightColors.push(L)}}}};d.jqplot.BarRenderer.prototype.drawShadow=function(z,E,p){var B;var w=(p!=undefined)?p:{};var s=(w.shadow!=undefined)?w.shadow:this.shadow;var G=(w.showLine!=undefined)?w.showLine:this.showLine;var A=(w.fill!=undefined)?w.fill:this.fill;var o=this.xaxis;var C=this.yaxis;var v=this._xaxis.series_u2p;var D=this._yaxis.series_u2p;var y,x,u,t,r;if(this._stack&&this.shadow){if(this.barWidth==null){this.renderer.setBarWidth.call(this)}var F=this._plotSeriesInfo=this.renderer.calcSeriesNumbers.call(this);u=F[0];t=F[1];r=F[2];if(this._stack){this._barNudge=0}else{this._barNudge=(-Math.abs(t/2-0.5)+r)*(this.barWidth+this.barPadding)}if(G){if(this.barDirection=="vertical"){for(var B=0;B<E.length;B++){if(this.data[B][1]==null){continue}points=[];var q=E[B][0]+this._barNudge;var n;if(this._stack&&this._prevGridData.length){n=this._prevGridData[B][1]}else{if(this.fillToZero){n=this._yaxis.series_u2p(0)}else{n=z.canvas.height}}points.push([q-this.barWidth/2,n]);points.push([q-this.barWidth/2,E[B][1]]);points.push([q+this.barWidth/2,E[B][1]]);points.push([q+this.barWidth/2,n]);this.renderer.shadowRenderer.draw(z,points,w)}}else{if(this.barDirection=="horizontal"){for(var B=0;B<E.length;B++){if(this.data[B][0]==null){continue}points=[];var q=E[B][1]-this._barNudge;var H;if(this._stack&&this._prevGridData.length){H=this._prevGridData[B][0]}else{H=0}points.push([H,q+this.barWidth/2]);points.push([E[B][0],q+this.barWidth/2]);points.push([E[B][0],q-this.barWidth/2]);points.push([H,q-this.barWidth/2]);this.renderer.shadowRenderer.draw(z,points,w)}}}}}};function h(p,o,n){for(i=0;i<this.series.length;i++){if(this.series[i].renderer.constructor==d.jqplot.BarRenderer){if(this.series[i].highlightMouseOver){this.series[i].highlightMouseDown=false}}}this.target.bind("mouseout",{plot:this},function(q){k(q.data.plot)})}function j(){this.plugins.barRenderer={highlightedSeriesIndex:null};this.plugins.barRenderer.highlightCanvas=new d.jqplot.GenericCanvas();this.eventCanvas._elem.before(this.plugins.barRenderer.highlightCanvas.createElement(this._gridPadding,"jqplot-barRenderer-highlight-canvas",this._plotDimensions));var n=this.plugins.barRenderer.highlightCanvas.setContext()}function c(u,t,q,p){var o=u.series[t];var n=u.plugins.barRenderer.highlightCanvas;n._ctx.clearRect(0,0,n._ctx.canvas.width,n._ctx.canvas.height);o._highlightedPoint=q;u.plugins.barRenderer.highlightedSeriesIndex=t;var r={fillStyle:o.highlightColors[q]};o.renderer.shapeRenderer.draw(n._ctx,p,r)}function k(p){var n=p.plugins.barRenderer.highlightCanvas;n._ctx.clearRect(0,0,n._ctx.canvas.width,n._ctx.canvas.height);for(var o=0;o<p.series.length;o++){p.series[o]._highlightedPoint=null}p.plugins.barRenderer.highlightedSeriesIndex=null;p.target.trigger("jqplotDataUnhighlight")}function b(r,q,u,t,s){if(t){var p=[t.seriesIndex,t.pointIndex,t.data];var o=jQuery.Event("jqplotDataMouseOver");o.pageX=r.pageX;o.pageY=r.pageY;s.target.trigger(o,p);if(s.series[p[0]].highlightMouseOver&&!(p[0]==s.plugins.barRenderer.highlightedSeriesIndex&&p[1]==s.series[p[0]]._highlightedPoint)){var n=jQuery.Event("jqplotDataHighlight");n.pageX=r.pageX;n.pageY=r.pageY;s.target.trigger(n,p);c(s,t.seriesIndex,t.pointIndex,t.points)}}else{if(t==null){k(s)}}}function a(q,p,t,s,r){if(s){var o=[s.seriesIndex,s.pointIndex,s.data];if(r.series[o[0]].highlightMouseDown&&!(o[0]==r.plugins.barRenderer.highlightedSeriesIndex&&o[1]==r.series[o[0]]._highlightedPoint)){var n=jQuery.Event("jqplotDataHighlight");n.pageX=q.pageX;n.pageY=q.pageY;r.target.trigger(n,o);c(r,s.seriesIndex,s.pointIndex,s.points)}}else{if(s==null){k(r)}}}function l(p,o,s,r,q){var n=q.plugins.barRenderer.highlightedSeriesIndex;if(n!=null&&q.series[n].highlightMouseDown){k(q)}}function e(q,p,t,s,r){if(s){var o=[s.seriesIndex,s.pointIndex,s.data];var n=jQuery.Event("jqplotDataClick");n.pageX=q.pageX;n.pageY=q.pageY;r.target.trigger(n,o)}}function m(r,q,u,t,s){if(t){var p=[t.seriesIndex,t.pointIndex,t.data];var n=s.plugins.barRenderer.highlightedSeriesIndex;if(n!=null&&s.series[n].highlightMouseDown){k(s)}var o=jQuery.Event("jqplotDataRightClick");o.pageX=r.pageX;o.pageY=r.pageY;s.target.trigger(o,p)}}})(jQuery);
|
@@ -0,0 +1,187 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2009 - 2010 Chris Leonello
|
3
|
+
* jqPlot is currently available for use in all personal or commercial projects
|
4
|
+
* under both the MIT and GPL version 2.0 licenses. This means that you can
|
5
|
+
* choose the license that best suits your project and use it accordingly.
|
6
|
+
*
|
7
|
+
* The author would appreciate an email letting him know of any substantial
|
8
|
+
* use of jqPlot. You can reach the author at: chris at jqplot dot com
|
9
|
+
* or see http://www.jqplot.com/info.php . This is, of course,
|
10
|
+
* not required.
|
11
|
+
*
|
12
|
+
* If you are feeling kind and generous, consider supporting the project by
|
13
|
+
* making a donation at: http://www.jqplot.com/donate.php .
|
14
|
+
*
|
15
|
+
* Thanks for using jqPlot!
|
16
|
+
*
|
17
|
+
*/
|
18
|
+
(function($) {
|
19
|
+
/**
|
20
|
+
* Class: $.jqplot.CanvasAxisLabelRenderer
|
21
|
+
* Renderer to draw axis labels with a canvas element to support advanced
|
22
|
+
* featrues such as rotated text. This renderer uses a separate rendering engine
|
23
|
+
* to draw the text on the canvas. Two modes of rendering the text are available.
|
24
|
+
* If the browser has native font support for canvas fonts (currently Mozila 3.5
|
25
|
+
* and Safari 4), you can enable text rendering with the canvas fillText method.
|
26
|
+
* You do so by setting the "enableFontSupport" option to true.
|
27
|
+
*
|
28
|
+
* Browsers lacking native font support will have the text drawn on the canvas
|
29
|
+
* using the Hershey font metrics. Even if the "enableFontSupport" option is true
|
30
|
+
* non-supporting browsers will still render with the Hershey font.
|
31
|
+
*
|
32
|
+
*/
|
33
|
+
$.jqplot.CanvasAxisLabelRenderer = function(options) {
|
34
|
+
// Group: Properties
|
35
|
+
|
36
|
+
// prop: angle
|
37
|
+
// angle of text, measured clockwise from x axis.
|
38
|
+
this.angle = 0;
|
39
|
+
// name of the axis associated with this tick
|
40
|
+
this.axis;
|
41
|
+
// prop: show
|
42
|
+
// wether or not to show the tick (mark and label).
|
43
|
+
this.show = true;
|
44
|
+
// prop: showLabel
|
45
|
+
// wether or not to show the label.
|
46
|
+
this.showLabel = true;
|
47
|
+
// prop: label
|
48
|
+
// label for the axis.
|
49
|
+
this.label = '';
|
50
|
+
// prop: fontFamily
|
51
|
+
// CSS spec for the font-family css attribute.
|
52
|
+
// Applies only to browsers supporting native font rendering in the
|
53
|
+
// canvas tag. Currently Mozilla 3.5 and Safari 4.
|
54
|
+
this.fontFamily = '"Trebuchet MS", Arial, Helvetica, sans-serif';
|
55
|
+
// prop: fontSize
|
56
|
+
// CSS spec for font size.
|
57
|
+
this.fontSize = '11pt';
|
58
|
+
// prop: fontWeight
|
59
|
+
// CSS spec for fontWeight: normal, bold, bolder, lighter or a number 100 - 900
|
60
|
+
this.fontWeight = 'normal';
|
61
|
+
// prop: fontStretch
|
62
|
+
// Multiplier to condense or expand font width.
|
63
|
+
// Applies only to browsers which don't support canvas native font rendering.
|
64
|
+
this.fontStretch = 1.0;
|
65
|
+
// prop: textColor
|
66
|
+
// css spec for the color attribute.
|
67
|
+
this.textColor = '#666666';
|
68
|
+
// prop: enableFontSupport
|
69
|
+
// true to turn on native canvas font support in Mozilla 3.5+ and Safari 4+.
|
70
|
+
// If true, label will be drawn with canvas tag native support for fonts.
|
71
|
+
// If false, label will be drawn with Hershey font metrics.
|
72
|
+
this.enableFontSupport = true;
|
73
|
+
// prop: pt2px
|
74
|
+
// Point to pixel scaling factor, used for computing height of bounding box
|
75
|
+
// around a label. The labels text renderer has a default setting of 1.4, which
|
76
|
+
// should be suitable for most fonts. Leave as null to use default. If tops of
|
77
|
+
// letters appear clipped, increase this. If bounding box seems too big, decrease.
|
78
|
+
// This is an issue only with the native font renderering capabilities of Mozilla
|
79
|
+
// 3.5 and Safari 4 since they do not provide a method to determine the font height.
|
80
|
+
this.pt2px = null;
|
81
|
+
|
82
|
+
this._elem;
|
83
|
+
this._ctx;
|
84
|
+
this._plotWidth;
|
85
|
+
this._plotHeight;
|
86
|
+
this._plotDimensions = {height:null, width:null};
|
87
|
+
|
88
|
+
$.extend(true, this, options);
|
89
|
+
|
90
|
+
if (options.angle == null && this.axis != 'xaxis' && this.axis != 'x2axis') {
|
91
|
+
this.angle = -90;
|
92
|
+
}
|
93
|
+
|
94
|
+
var ropts = {fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily};
|
95
|
+
if (this.pt2px) {
|
96
|
+
ropts.pt2px = this.pt2px;
|
97
|
+
}
|
98
|
+
|
99
|
+
if (this.enableFontSupport) {
|
100
|
+
|
101
|
+
function support_canvas_text() {
|
102
|
+
return !!(document.createElement('canvas').getContext && typeof document.createElement('canvas').getContext('2d').fillText == 'function');
|
103
|
+
}
|
104
|
+
|
105
|
+
if (support_canvas_text()) {
|
106
|
+
this._textRenderer = new $.jqplot.CanvasFontRenderer(ropts);
|
107
|
+
}
|
108
|
+
|
109
|
+
else {
|
110
|
+
this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts);
|
111
|
+
}
|
112
|
+
}
|
113
|
+
else {
|
114
|
+
this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts);
|
115
|
+
}
|
116
|
+
};
|
117
|
+
|
118
|
+
$.jqplot.CanvasAxisLabelRenderer.prototype.init = function(options) {
|
119
|
+
$.extend(true, this, options);
|
120
|
+
this._textRenderer.init({fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily});
|
121
|
+
};
|
122
|
+
|
123
|
+
// return width along the x axis
|
124
|
+
// will check first to see if an element exists.
|
125
|
+
// if not, will return the computed text box width.
|
126
|
+
$.jqplot.CanvasAxisLabelRenderer.prototype.getWidth = function(ctx) {
|
127
|
+
if (this._elem) {
|
128
|
+
return this._elem.outerWidth(true);
|
129
|
+
}
|
130
|
+
else {
|
131
|
+
var tr = this._textRenderer;
|
132
|
+
var l = tr.getWidth(ctx);
|
133
|
+
var h = tr.getHeight(ctx);
|
134
|
+
var w = Math.abs(Math.sin(tr.angle)*h) + Math.abs(Math.cos(tr.angle)*l);
|
135
|
+
return w;
|
136
|
+
}
|
137
|
+
};
|
138
|
+
|
139
|
+
// return height along the y axis.
|
140
|
+
$.jqplot.CanvasAxisLabelRenderer.prototype.getHeight = function(ctx) {
|
141
|
+
if (this._elem) {
|
142
|
+
return this._elem.outerHeight(true);
|
143
|
+
}
|
144
|
+
else {
|
145
|
+
var tr = this._textRenderer;
|
146
|
+
var l = tr.getWidth(ctx);
|
147
|
+
var h = tr.getHeight(ctx);
|
148
|
+
var w = Math.abs(Math.cos(tr.angle)*h) + Math.abs(Math.sin(tr.angle)*l);
|
149
|
+
return w;
|
150
|
+
}
|
151
|
+
};
|
152
|
+
|
153
|
+
$.jqplot.CanvasAxisLabelRenderer.prototype.getAngleRad = function() {
|
154
|
+
var a = this.angle * Math.PI/180;
|
155
|
+
return a;
|
156
|
+
};
|
157
|
+
|
158
|
+
$.jqplot.CanvasAxisLabelRenderer.prototype.draw = function(ctx) {
|
159
|
+
// create a canvas here, but can't draw on it untill it is appended
|
160
|
+
// to dom for IE compatability.
|
161
|
+
var domelem = document.createElement('canvas');
|
162
|
+
this._textRenderer.setText(this.label, ctx);
|
163
|
+
var w = this.getWidth(ctx);
|
164
|
+
var h = this.getHeight(ctx);
|
165
|
+
domelem.width = w;
|
166
|
+
domelem.height = h;
|
167
|
+
domelem.style.width = w;
|
168
|
+
domelem.style.height = h;
|
169
|
+
// domelem.style.textAlign = 'center';
|
170
|
+
domelem.style.position = 'absolute';
|
171
|
+
this._domelem = domelem;
|
172
|
+
this._elem = $(domelem);
|
173
|
+
this._elem.addClass('jqplot-'+this.axis+'-label');
|
174
|
+
|
175
|
+
return this._elem;
|
176
|
+
};
|
177
|
+
|
178
|
+
$.jqplot.CanvasAxisLabelRenderer.prototype.pack = function() {
|
179
|
+
if ($.browser.msie) {
|
180
|
+
window.G_vmlCanvasManager.init_(document);
|
181
|
+
this._domelem = window.G_vmlCanvasManager.initElement(this._domelem);
|
182
|
+
}
|
183
|
+
var ctx = this._elem.get(0).getContext("2d");
|
184
|
+
this._textRenderer.draw(ctx, this.label);
|
185
|
+
};
|
186
|
+
|
187
|
+
})(jQuery);
|