visage-app 0.3.3 → 0.9.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +0,0 @@
1
- /*
2
- * g.Raphael 0.4.1 - Charting library, based on Raphaël
3
- *
4
- * Copyright (c) 2009 Dmitry Baranovskiy (http://g.raphaeljs.com)
5
- * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
6
- */
7
- Raphael.fn.g.linechart=function(J,I,a,c,s,r,C){function B(y,Y){var x=y.length/Y,V=0,i=x,X=0,W=[];while(V<y.length){i--;if(i<0){X+=y[V]*(1+i);W.push(X/x);X=y[V++]*-i;i+=x;}else{X+=y[V++];}}return W;}C=C||{};if(!this.raphael.is(s[0],"array")){s=[s];}if(!this.raphael.is(r[0],"array")){r=[r];}var O=Array.prototype.concat.apply([],s),M=Array.prototype.concat.apply([],r),o=this.g.snapEnds(Math.min.apply(Math,O),Math.max.apply(Math,O),s[0].length-1),v=o.from,h=o.to,l=C.gutter||10,P=(a-l*2)/(h-v),G=this.g.snapEnds(Math.min.apply(Math,M),Math.max.apply(Math,M),r[0].length-1),u=G.from,g=G.to,N=(c-l*2)/(g-u),t=Math.max(s[0].length,r[0].length),n=C.symbol||"",K=C.colors||Raphael.fn.g.colors,H=this,p=null,k=null,T=this.set(),L=[];for(var S=0,E=r.length;S<E;S++){t=Math.max(t,r[S].length);}var U=this.set();for(var S=0,E=r.length;S<E;S++){if(C.shade){U.push(this.path().attr({stroke:"none",fill:K[S],opacity:C.nostroke?1:0.3}));}if(r[S].length>a-2*l){r[S]=B(r[S],a-2*l);t=a-2*l;}if(s[S]&&s[S].length>a-2*l){s[S]=B(s[S],a-2*l);}}var w=this.set();if(C.axis){var f=(C.axis+"").split(/[,\s]+/);+f[0]&&w.push(this.g.axis(J+l,I+l,a-2*l,v,h,C.axisxstep||Math.floor((a-2*l)/20),2));+f[1]&&w.push(this.g.axis(J+a-l,I+c-l,c-2*l,u,g,C.axisystep||Math.floor((c-2*l)/20),3));+f[2]&&w.push(this.g.axis(J+l,I+c-l,a-2*l,v,h,C.axisxstep||Math.floor((a-2*l)/20),0));+f[3]&&w.push(this.g.axis(J+l,I+c-l,c-2*l,u,g,C.axisystep||Math.floor((c-2*l)/20),1));}var F=this.set(),Q=this.set(),m;for(var S=0,E=r.length;S<E;S++){if(!C.nostroke){F.push(m=this.path().attr({stroke:K[S],"stroke-width":C.width||2,"stroke-linejoin":"round","stroke-linecap":"round","stroke-dasharray":C.dash||""}));}var b=this.raphael.is(n,"array")?n[S]:n,z=this.set();L=[];for(var R=0,q=r[S].length;R<q;R++){var e=J+l+((s[S]||s[0])[R]-v)*P;var d=I+c-l-(r[S][R]-u)*N;(Raphael.is(b,"array")?b[R]:b)&&z.push(this.g[Raphael.fn.g.markers[this.raphael.is(b,"array")?b[R]:b]](e,d,(C.width||2)*3).attr({fill:K[S],stroke:"none"}));L=L.concat([R?"L":"M",e,d]);}Q.push(z);if(C.shade){U[S].attr({path:L.concat(["L",e,I+c-l,"L",J+l+((s[S]||s[0])[0]-v)*P,I+c-l,"z"]).join(",")});}!C.nostroke&&m.attr({path:L.join(",")});}function D(ae){var ab=[];for(var ac=0,ag=s.length;ac<ag;ac++){ab=ab.concat(s[ac]);}ab.sort();var ah=[],Y=[];for(var ac=0,ag=ab.length;ac<ag;ac++){ab[ac]!=ab[ac-1]&&ah.push(ab[ac])&&Y.push(J+l+(ab[ac]-v)*P);}ab=ah;ag=ab.length;var W=ae||H.set();for(var ac=0;ac<ag;ac++){var V=Y[ac]-(Y[ac]-(Y[ac-1]||J))/2,af=((Y[ac+1]||J+a)-Y[ac])/2+(Y[ac]-(Y[ac-1]||J))/2,x;ae?(x={}):W.push(x=H.rect(V-1,I,Math.max(af+1,1),c).attr({stroke:"none",fill:"#000",opacity:0}));x.values=[];x.symbols=H.set();x.y=[];x.x=Y[ac];x.axis=ab[ac];for(var aa=0,ad=r.length;aa<ad;aa++){ah=s[aa]||s[0];for(var Z=0,y=ah.length;Z<y;Z++){if(ah[Z]==ab[ac]){x.values.push(r[aa][Z]);x.y.push(I+c-l-(r[aa][Z]-u)*N);x.symbols.push(T.symbols[aa][Z]);}}}ae&&ae.call(x);}!ae&&(p=W);}function A(ac){var W=ac||H.set(),x;for(var aa=0,ae=r.length;aa<ae;aa++){for(var Z=0,ab=r[aa].length;Z<ab;Z++){var V=J+l+((s[aa]||s[0])[Z]-v)*P,ad=J+l+((s[aa]||s[0])[Z?Z-1:1]-v)*P,y=I+c-l-(r[aa][Z]-u)*N;ac?(x={}):W.push(x=H.circle(V,y,Math.abs(ad-V)/2).attr({stroke:"none",fill:"#000",opacity:0}));x.x=V;x.y=y;x.value=r[aa][Z];x.line=T.lines[aa];x.shade=T.shades[aa];x.symbol=T.symbols[aa][Z];x.symbols=T.symbols[aa];x.axis=(s[aa]||s[0])[Z];ac&&ac.call(x);}}!ac&&(k=W);}T.push(F,U,Q,w,p,k);T.lines=F;T.shades=U;T.symbols=Q;T.axis=w;T.hoverColumn=function(j,i){!p&&D();p.mouseover(j).mouseout(i);return this;};T.clickColumn=function(i){!p&&D();p.click(i);return this;};T.hrefColumn=function(W){var X=H.raphael.is(arguments[0],"array")?arguments[0]:arguments;if(!(arguments.length-1)&&typeof W=="object"){for(var j in W){for(var y=0,V=p.length;y<V;y++){if(p[y].axis==j){p[y].attr("href",W[j]);}}}}!p&&D();for(var y=0,V=X.length;y<V;y++){p[y]&&p[y].attr("href",X[y]);}return this;};T.hover=function(j,i){!k&&A();k.mouseover(j).mouseout(i);return this;};T.click=function(i){!k&&A();k.click(i);return this;};T.each=function(i){A(i);return this;};T.eachColumn=function(i){D(i);return this;};return T;};
@@ -1,218 +0,0 @@
1
- /*!
2
- * g.Raphael 0.4.1 - Charting library, based on Raphaël
3
- *
4
- * Copyright (c) 2009 Dmitry Baranovskiy (http://g.raphaeljs.com)
5
- * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
6
- */
7
- Raphael.fn.g.linechart = function (x, y, width, height, valuesx, valuesy, opts) {
8
- function shrink(values, dim) {
9
- var k = values.length / dim,
10
- j = 0,
11
- l = k,
12
- sum = 0,
13
- res = [];
14
- while (j < values.length) {
15
- l--;
16
- if (l < 0) {
17
- sum += values[j] * (1 + l);
18
- res.push(sum / k);
19
- sum = values[j++] * -l;
20
- l += k;
21
- } else {
22
- sum += values[j++];
23
- }
24
- }
25
- return res;
26
- }
27
- opts = opts || {};
28
- if (!this.raphael.is(valuesx[0], "array")) {
29
- valuesx = [valuesx];
30
- }
31
- if (!this.raphael.is(valuesy[0], "array")) {
32
- valuesy = [valuesy];
33
- }
34
-
35
- var allx = Array.prototype.concat.apply([], valuesx),
36
- ally = Array.prototype.concat.apply([], valuesy),
37
- xdim = this.g.snapEnds(Math.min.apply(Math, allx), Math.max.apply(Math, allx), valuesx[0].length - 1),
38
- minx = xdim.from,
39
- maxx = xdim.to,
40
- gutter = opts.gutter || 10,
41
- kx = (width - gutter * 2) / (maxx - minx),
42
- ydim = this.g.snapEnds(Math.min.apply(Math, ally), Math.max.apply(Math, ally), valuesy[0].length - 1),
43
- miny = ydim.from,
44
- maxy = ydim.to,
45
- ky = (height - gutter * 2) / (maxy - miny),
46
- len = Math.max(valuesx[0].length, valuesy[0].length),
47
- symbol = opts.symbol || "",
48
- colors = opts.colors || Raphael.fn.g.colors,
49
- that = this,
50
- columns = null,
51
- dots = null,
52
- chart = this.set(),
53
- path = [];
54
-
55
- for (var i = 0, ii = valuesy.length; i < ii; i++) {
56
- len = Math.max(len, valuesy[i].length);
57
- }
58
- var shades = this.set();
59
- for (var i = 0, ii = valuesy.length; i < ii; i++) {
60
- if (opts.shade) {
61
- shades.push(this.path().attr({stroke: "none", fill: colors[i], opacity: opts.nostroke ? 1 : .3}));
62
- }
63
- if (valuesy[i].length > width - 2 * gutter) {
64
- valuesy[i] = shrink(valuesy[i], width - 2 * gutter);
65
- len = width - 2 * gutter;
66
- }
67
- if (valuesx[i] && valuesx[i].length > width - 2 * gutter) {
68
- valuesx[i] = shrink(valuesx[i], width - 2 * gutter);
69
- }
70
- }
71
- var axis = this.set();
72
- if (opts.axis) {
73
- var ax = (opts.axis + "").split(/[,\s]+/);
74
- +ax[0] && axis.push(this.g.axis(x + gutter, y + gutter, width - 2 * gutter, minx, maxx, opts.axisxstep || Math.floor((width - 2 * gutter) / 20), 2));
75
- +ax[1] && axis.push(this.g.axis(x + width - gutter, y + height - gutter, height - 2 * gutter, miny, maxy, opts.axisystep || Math.floor((height - 2 * gutter) / 20), 3));
76
- +ax[2] && axis.push(this.g.axis(x + gutter, y + height - gutter, width - 2 * gutter, minx, maxx, opts.axisxstep || Math.floor((width - 2 * gutter) / 20), 0));
77
- +ax[3] && axis.push(this.g.axis(x + gutter, y + height - gutter, height - 2 * gutter, miny, maxy, opts.axisystep || Math.floor((height - 2 * gutter) / 20), 1));
78
- }
79
- var lines = this.set(),
80
- symbols = this.set(),
81
- line;
82
- for (var i = 0, ii = valuesy.length; i < ii; i++) {
83
- if (!opts.nostroke) {
84
- lines.push(line = this.path().attr({
85
- stroke: colors[i],
86
- "stroke-width": opts.width || 2,
87
- "stroke-linejoin": "round",
88
- "stroke-linecap": "round",
89
- "stroke-dasharray": opts.dash || ""
90
- }));
91
- }
92
- var sym = this.raphael.is(symbol, "array") ? symbol[i] : symbol,
93
- symset = this.set();
94
- path = [];
95
- for (var j = 0, jj = valuesy[i].length; j < jj; j++) {
96
- var X = x + gutter + ((valuesx[i] || valuesx[0])[j] - minx) * kx;
97
- var Y = y + height - gutter - (valuesy[i][j] - miny) * ky;
98
- (Raphael.is(sym, "array") ? sym[j] : sym) && symset.push(this.g[Raphael.fn.g.markers[this.raphael.is(sym, "array") ? sym[j] : sym]](X, Y, (opts.width || 2) * 3).attr({fill: colors[i], stroke: "none"}));
99
- path = path.concat([j ? "L" : "M", X, Y]);
100
- }
101
- symbols.push(symset);
102
- if (opts.shade) {
103
- shades[i].attr({path: path.concat(["L", X, y + height - gutter, "L", x + gutter + ((valuesx[i] || valuesx[0])[0] - minx) * kx, y + height - gutter, "z"]).join(",")});
104
- }
105
- !opts.nostroke && line.attr({path: path.join(",")});
106
- }
107
- function createColumns(f) {
108
- // unite Xs together
109
- var Xs = [];
110
- for (var i = 0, ii = valuesx.length; i < ii; i++) {
111
- Xs = Xs.concat(valuesx[i]);
112
- }
113
- Xs.sort();
114
- // remove duplicates
115
- var Xs2 = [],
116
- xs = [];
117
- for (var i = 0, ii = Xs.length; i < ii; i++) {
118
- Xs[i] != Xs[i - 1] && Xs2.push(Xs[i]) && xs.push(x + gutter + (Xs[i] - minx) * kx);
119
- }
120
- Xs = Xs2;
121
- ii = Xs.length;
122
- var cvrs = f || that.set();
123
- for (var i = 0; i < ii; i++) {
124
- var X = xs[i] - (xs[i] - (xs[i - 1] || x)) / 2,
125
- w = ((xs[i + 1] || x + width) - xs[i]) / 2 + (xs[i] - (xs[i - 1] || x)) / 2,
126
- C;
127
- f ? (C = {}) : cvrs.push(C = that.rect(X - 1, y, Math.max(w + 1, 1), height).attr({stroke: "none", fill: "#000", opacity: 0}));
128
- C.values = [];
129
- C.symbols = that.set();
130
- C.y = [];
131
- C.x = xs[i];
132
- C.axis = Xs[i];
133
- for (var j = 0, jj = valuesy.length; j < jj; j++) {
134
- Xs2 = valuesx[j] || valuesx[0];
135
- for (var k = 0, kk = Xs2.length; k < kk; k++) {
136
- if (Xs2[k] == Xs[i]) {
137
- C.values.push(valuesy[j][k]);
138
- C.y.push(y + height - gutter - (valuesy[j][k] - miny) * ky);
139
- C.symbols.push(chart.symbols[j][k]);
140
- }
141
- }
142
- }
143
- f && f.call(C);
144
- }
145
- !f && (columns = cvrs);
146
- }
147
- function createDots(f) {
148
- var cvrs = f || that.set(),
149
- C;
150
- for (var i = 0, ii = valuesy.length; i < ii; i++) {
151
- for (var j = 0, jj = valuesy[i].length; j < jj; j++) {
152
- var X = x + gutter + ((valuesx[i] || valuesx[0])[j] - minx) * kx,
153
- nearX = x + gutter + ((valuesx[i] || valuesx[0])[j ? j - 1 : 1] - minx) * kx,
154
- Y = y + height - gutter - (valuesy[i][j] - miny) * ky;
155
- f ? (C = {}) : cvrs.push(C = that.circle(X, Y, Math.abs(nearX - X) / 2).attr({stroke: "none", fill: "#000", opacity: 0}));
156
- C.x = X;
157
- C.y = Y;
158
- C.value = valuesy[i][j];
159
- C.line = chart.lines[i];
160
- C.shade = chart.shades[i];
161
- C.symbol = chart.symbols[i][j];
162
- C.symbols = chart.symbols[i];
163
- C.axis = (valuesx[i] || valuesx[0])[j];
164
- f && f.call(C);
165
- }
166
- }
167
- !f && (dots = cvrs);
168
- }
169
- chart.push(lines, shades, symbols, axis, columns, dots);
170
- chart.lines = lines;
171
- chart.shades = shades;
172
- chart.symbols = symbols;
173
- chart.axis = axis;
174
- chart.hoverColumn = function (fin, fout) {
175
- !columns && createColumns();
176
- columns.mouseover(fin).mouseout(fout);
177
- return this;
178
- };
179
- chart.clickColumn = function (f) {
180
- !columns && createColumns();
181
- columns.click(f);
182
- return this;
183
- };
184
- chart.hrefColumn = function (cols) {
185
- var hrefs = that.raphael.is(arguments[0], "array") ? arguments[0] : arguments;
186
- if (!(arguments.length - 1) && typeof cols == "object") {
187
- for (var x in cols) {
188
- for (var i = 0, ii = columns.length; i < ii; i++) if (columns[i].axis == x) {
189
- columns[i].attr("href", cols[x]);
190
- }
191
- }
192
- }
193
- !columns && createColumns();
194
- for (var i = 0, ii = hrefs.length; i < ii; i++) {
195
- columns[i] && columns[i].attr("href", hrefs[i]);
196
- }
197
- return this;
198
- };
199
- chart.hover = function (fin, fout) {
200
- !dots && createDots();
201
- dots.mouseover(fin).mouseout(fout);
202
- return this;
203
- };
204
- chart.click = function (f) {
205
- !dots && createDots();
206
- dots.click(f);
207
- return this;
208
- };
209
- chart.each = function (f) {
210
- createDots(f);
211
- return this;
212
- };
213
- chart.eachColumn = function (f) {
214
- createColumns(f);
215
- return this;
216
- };
217
- return chart;
218
- };
@@ -1,7 +0,0 @@
1
- /*
2
- * g.Raphael 0.4.1 - Charting library, based on Raphaël
3
- *
4
- * Copyright (c) 2009 Dmitry Baranovskiy (http://g.raphaeljs.com)
5
- * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
6
- */
7
- (function(){var a=Math.max,c=Math.min;Raphael.fn.g=Raphael.fn.g||{};Raphael.fn.g.markers={disc:"disc",o:"disc",flower:"flower",f:"flower",diamond:"diamond",d:"diamond",square:"square",s:"square",triangle:"triangle",t:"triangle",star:"star","*":"star",cross:"cross",x:"cross",plus:"plus","+":"plus",arrow:"arrow","->":"arrow"};Raphael.fn.g.shim={stroke:"none",fill:"#000","fill-opacity":0};Raphael.fn.g.txtattr={font:"12px Arial, sans-serif"};Raphael.fn.g.colors=[];var e=[0.6,0.2,0.05,0.1333,0.75,0];for(var b=0;b<10;b++){if(b<e.length){Raphael.fn.g.colors.push("hsb("+e[b]+", .75, .75)");}else{Raphael.fn.g.colors.push("hsb("+e[b-e.length]+", 1, .5)");}}Raphael.fn.g.text=function(f,h,g){return this.text(f,h,g).attr(this.g.txtattr);};Raphael.fn.g.labelise=function(f,h,g){if(f){return(f+"").replace(/(##+(?:\.#+)?)|(%%+(?:\.%+)?)/g,function(i,k,j){if(k){return(+h).toFixed(k.replace(/^#+\.?/g,"").length);}if(j){return(h*100/g).toFixed(j.replace(/^%+\.?/g,"").length)+"%";}});}else{return(+h).toFixed(0);}};Raphael.fn.g.finger=function(l,k,g,m,h,i,j){if((h&&!m)||(!h&&!g)){return j?"":this.path();}i={square:"square",sharp:"sharp",soft:"soft"}[i]||"round";var o;m=Math.round(m);g=Math.round(g);l=Math.round(l);k=Math.round(k);switch(i){case"round":if(!h){var f=~~(m/2);if(g<f){f=g;o=["M",l+0.5,k+0.5-~~(m/2),"l",0,0,"a",f,~~(m/2),0,0,1,0,m,"l",0,0,"z"];}else{o=["M",l+0.5,k+0.5-f,"l",g-f,0,"a",f,f,0,1,1,0,m,"l",f-g,0,"z"];}}else{f=~~(g/2);if(m<f){f=m;o=["M",l-~~(g/2),k,"l",0,0,"a",~~(g/2),f,0,0,1,g,0,"l",0,0,"z"];}else{o=["M",l-f,k,"l",0,f-m,"a",f,f,0,1,1,g,0,"l",0,m-f,"z"];}}break;case"sharp":if(!h){var n=~~(m/2);o=["M",l,k+n,"l",0,-m,a(g-n,0),0,c(n,g),n,-c(n,g),n+(n*2<m),"z"];}else{n=~~(g/2);o=["M",l+n,k,"l",-g,0,0,-a(m-n,0),n,-c(n,m),n,c(n,m),n,"z"];}break;case"square":if(!h){o=["M",l,k+~~(m/2),"l",0,-m,g,0,0,m,"z"];}else{o=["M",l+~~(g/2),k,"l",1-g,0,0,-m,g-1,0,"z"];}break;case"soft":if(!h){f=c(g,Math.round(m/5));o=["M",l+0.5,k+0.5-~~(m/2),"l",g-f,0,"a",f,f,0,0,1,f,f,"l",0,m-f*2,"a",f,f,0,0,1,-f,f,"l",f-g,0,"z"];}else{f=c(Math.round(g/5),m);o=["M",l-~~(g/2),k,"l",0,f-m,"a",f,f,0,0,1,f,-f,"l",g-2*f,0,"a",f,f,0,0,1,f,f,"l",0,m-f,"z"];}}if(j){return o.join(",");}else{return this.path(o);}};Raphael.fn.g.disc=function(f,h,g){return this.circle(f,h,g);};Raphael.fn.g.line=function(f,h,g){return this.rect(f-g,h-g/5,2*g,2*g/5);};Raphael.fn.g.square=function(f,h,g){g=g*0.7;return this.rect(f-g,h-g,2*g,2*g);};Raphael.fn.g.triangle=function(f,h,g){g*=1.75;return this.path("M".concat(f,",",h,"m0-",g*0.58,"l",g*0.5,",",g*0.87,"-",g,",0z"));};Raphael.fn.g.diamond=function(f,h,g){return this.path(["M",f,h-g,"l",g,g,-g,g,-g,-g,g,-g,"z"]);};Raphael.fn.g.flower=function(j,h,f,g){f=f*1.25;var o=f,m=o*0.5;g=+g<3||!g?5:g;var p=["M",j,h+m,"Q"],l;for(var k=1;k<g*2+1;k++){l=k%2?o:m;p=p.concat([+(j+l*Math.sin(k*Math.PI/g)).toFixed(3),+(h+l*Math.cos(k*Math.PI/g)).toFixed(3)]);}p.push("z");return this.path(p.join(","));};Raphael.fn.g.star=function(f,n,m,h,g){h=h||m*0.382;g=g||5;var l=["M",f,n+h,"L"],k;for(var j=1;j<g*2;j++){k=j%2?m:h;l=l.concat([(f+k*Math.sin(j*Math.PI/g)),(n+k*Math.cos(j*Math.PI/g))]);}l.push("z");return this.path(l.join(","));};Raphael.fn.g.cross=function(f,h,g){g=g/2.5;return this.path("M".concat(f-g,",",h,"l",[-g,-g,g,-g,g,g,g,-g,g,g,-g,g,g,g,-g,g,-g,-g,-g,g,-g,-g,"z"]));};Raphael.fn.g.plus=function(f,h,g){g=g/2;return this.path("M".concat(f-g/2,",",h-g/2,"l",[0,-g,g,0,0,g,g,0,0,g,-g,0,0,g,-g,0,0,-g,-g,0,0,-g,"z"]));};Raphael.fn.g.arrow=function(f,h,g){return this.path("M".concat(f-g*0.7,",",h-g*0.4,"l",[g*0.6,0,0,-g*0.4,g,g*0.8,-g,g*0.8,0,-g*0.4,-g*0.6,0],"z"));};Raphael.fn.g.tag=function(f,m,l,k,i){k=k||0;i=i==null?5:i;l=l==null?"$9.99":l;var h=0.5522*i,g=this.set(),j=3;g.push(this.path().attr({fill:"#000",stroke:"#000"}));g.push(this.text(f,m,l).attr(this.g.txtattr).attr({fill:"#fff","font-family":"Helvetica, Arial"}));g.update=function(){this.rotate(0,f,m);var o=this[1].getBBox();if(o.height>=i*2){this[0].attr({path:["M",f,m+i,"a",i,i,0,1,1,0,-i*2,i,i,0,1,1,0,i*2,"m",0,-i*2-j,"a",i+j,i+j,0,1,0,0,(i+j)*2,"L",f+i+j,m+o.height/2+j,"l",o.width+2*j,0,0,-o.height-2*j,-o.width-2*j,0,"L",f,m-i-j].join(",")});}else{var n=Math.sqrt(Math.pow(i+j,2)-Math.pow(o.height/2+j,2));this[0].attr({path:["M",f,m+i,"c",-h,0,-i,h-i,-i,-i,0,-h,i-h,-i,i,-i,h,0,i,i-h,i,i,0,h,h-i,i,-i,i,"M",f+n,m-o.height/2-j,"a",i+j,i+j,0,1,0,0,o.height+2*j,"l",i+j-n+o.width+2*j,0,0,-o.height-2*j,"L",f+n,m-o.height/2-j].join(",")});}this[1].attr({x:f+i+j+o.width/2,y:m});k=(360-k)%360;this.rotate(k,f,m);k>90&&k<270&&this[1].attr({x:f-i-j-o.width/2,y:m,rotation:[180+k,f,m]});return this;};g.update();return g;};Raphael.fn.g.popupit=function(l,k,m,g,t){g=g==null?2:g;t=t||5;l=Math.round(l);k=Math.round(k);var j=m.getBBox(),n=Math.round(j.width/2),i=Math.round(j.height/2),s=[0,n+t*2,0,-n-t*2],o=[-i*2-t*3,-i-t,0,-i-t],f=["M",l-s[g],k-o[g],"l",-t,(g==2)*-t,-a(n-t,0),0,"a",t,t,0,0,1,-t,-t,"l",0,-a(i-t,0),(g==3)*-t,-t,(g==3)*t,-t,0,-a(i-t,0),"a",t,t,0,0,1,t,-t,"l",a(n-t,0),0,t,!g*-t,t,!g*t,a(n-t,0),0,"a",t,t,0,0,1,t,t,"l",0,a(i-t,0),(g==1)*t,t,(g==1)*-t,t,0,a(i-t,0),"a",t,t,0,0,1,-t,t,"l",-a(n-t,0),0,"z"].join(","),q=[{x:l,y:k+t*2+i},{x:l-t*2-n,y:k},{x:l,y:k-t*2-i},{x:l+t*2+n,y:k}][g];m.translate(q.x-n-j.x,q.y-i-j.y);return this.path(f).attr({fill:"#000",stroke:"none"}).insertBefore(m.node?m:m[0]);};Raphael.fn.g.popup=function(f,l,k,g,i){g=g==null?2:g>3?3:g;i=i||5;k=k||"$9.99";var h=this.set(),j=3;h.push(this.path().attr({fill:"#000",stroke:"#000"}));h.push(this.text(f,l,k).attr(this.g.txtattr).attr({fill:"#fff","font-family":"Helvetica, Arial"}));h.update=function(o,n,q){o=o||f;n=n||l;var t=this[1].getBBox(),u=t.width/2,s=t.height/2,y=[0,u+i*2,0,-u-i*2],v=[-s*2-i*3,-s-i,0,-s-i],m=["M",o-y[g],n-v[g],"l",-i,(g==2)*-i,-a(u-i,0),0,"a",i,i,0,0,1,-i,-i,"l",0,-a(s-i,0),(g==3)*-i,-i,(g==3)*i,-i,0,-a(s-i,0),"a",i,i,0,0,1,i,-i,"l",a(u-i,0),0,i,!g*-i,i,!g*i,a(u-i,0),0,"a",i,i,0,0,1,i,i,"l",0,a(s-i,0),(g==1)*i,i,(g==1)*-i,i,0,a(s-i,0),"a",i,i,0,0,1,-i,i,"l",-a(u-i,0),0,"z"].join(","),x=[{x:o,y:n+i*2+s},{x:o-i*2-u,y:n},{x:o,y:n-i*2-s},{x:o+i*2+u,y:n}][g];x.path=m;if(q){this.animate(x,500,">");}else{this.attr(x);}return this;};return h.update(f,l);};Raphael.fn.g.flag=function(f,k,j,i){i=i||0;j=j||"$9.99";var g=this.set(),h=3;g.push(this.path().attr({fill:"#000",stroke:"#000"}));g.push(this.text(f,k,j).attr(this.g.txtattr).attr({fill:"#fff","font-family":"Helvetica, Arial"}));g.update=function(l,o){this.rotate(0,l,o);var n=this[1].getBBox(),m=n.height/2;this[0].attr({path:["M",l,o,"l",m+h,-m-h,n.width+2*h,0,0,n.height+2*h,-n.width-2*h,0,"z"].join(",")});this[1].attr({x:l+m+h+n.width/2,y:o});i=360-i;this.rotate(i,l,o);i>90&&i<270&&this[1].attr({x:l-r-h-n.width/2,y:o,rotation:[180+i,l,o]});return this;};return g.update(f,k);};Raphael.fn.g.label=function(f,i,h){var g=this.set();g.push(this.rect(f,i,10,10).attr({stroke:"none",fill:"#000"}));g.push(this.text(f,i,h).attr(this.g.txtattr).attr({fill:"#fff"}));g.update=function(){var k=this[1].getBBox(),j=c(k.width+10,k.height+10)/2;this[0].attr({x:k.x-j/2,y:k.y-j/2,width:k.width+j,height:k.height+j,r:j});};g.update();return g;};Raphael.fn.g.labelit=function(h){var g=h.getBBox(),f=c(20,g.width+10,g.height+10)/2;return this.rect(g.x-f/2,g.y-f/2,g.width+f,g.height+f,f).attr({stroke:"none",fill:"#000"}).insertBefore(h.node?h:h[0]);};Raphael.fn.g.drop=function(f,k,j,h,i){h=h||30;i=i||0;var g=this.set();g.push(this.path(["M",f,k,"l",h,0,"A",h*0.4,h*0.4,0,1,0,f+h*0.7,k-h*0.7,"z"]).attr({fill:"#000",stroke:"none",rotation:[22.5-i,f,k]}));i=(i+90)*Math.PI/180;g.push(this.text(f+h*Math.sin(i),k+h*Math.cos(i),j).attr(this.g.txtattr).attr({"font-size":h*12/30,fill:"#fff"}));g.drop=g[0];g.text=g[1];return g;};Raphael.fn.g.blob=function(g,m,l,k,i){k=(+k+1?k:45)+90;i=i||12;var f=Math.PI/180,j=i*12/12;var h=this.set();h.push(this.path().attr({fill:"#000",stroke:"none"}));h.push(this.text(g+i*Math.sin((k)*f),m+i*Math.cos((k)*f)-j/2,l).attr(this.g.txtattr).attr({"font-size":j,fill:"#fff"}));h.update=function(t,s,y){t=t||g;s=s||m;var A=this[1].getBBox(),D=a(A.width+j,i*25/12),z=a(A.height+j,i*25/12),o=t+i*Math.sin((k-22.5)*f),B=s+i*Math.cos((k-22.5)*f),q=t+i*Math.sin((k+22.5)*f),C=s+i*Math.cos((k+22.5)*f),F=(q-o)/2,E=(C-B)/2,p=D/2,n=z/2,x=-Math.sqrt(Math.abs(p*p*n*n-p*p*E*E-n*n*F*F)/(p*p*E*E+n*n*F*F)),v=x*p*E/n+(q+o)/2,u=x*-n*F/p+(C+B)/2;if(y){this.animate({x:v,y:u,path:["M",g,m,"L",q,C,"A",p,n,0,1,1,o,B,"z"].join(",")},500,">");}else{this.attr({x:v,y:u,path:["M",g,m,"L",q,C,"A",p,n,0,1,1,o,B,"z"].join(",")});}return this;};h.update(g,m);return h;};Raphael.fn.g.colorValue=function(i,h,g,f){return"hsb("+[c((1-i/h)*0.4,1),g||0.75,f||0.75]+")";};Raphael.fn.g.snapEnds=function(n,o,m){var k=n,p=o;if(k==p){return{from:k,to:p,power:0};}function q(f){return Math.abs(f-0.5)<0.25?~~(f)+0.5:Math.round(f);}var l=(p-k)/m,g=~~(l),j=g,h=0;if(g){while(j){h--;j=~~(l*Math.pow(10,h))/Math.pow(10,h);}h++;}else{while(!g){h=h||1;g=~~(l*Math.pow(10,h))/Math.pow(10,h);h++;}h&&h--;}p=q(o*Math.pow(10,h))/Math.pow(10,h);if(p<o){p=q((o+0.5)*Math.pow(10,h))/Math.pow(10,h);}k=q((n-(h>0?0:0.5))*Math.pow(10,h))/Math.pow(10,h);return{from:k,to:p,power:h};};Raphael.fn.g.axis=function(v,u,o,G,l,J,m,L,n,g){g=g==null?2:g;n=n||"t";J=J||10;var F=n=="|"||n==" "?["M",v+0.5,u,"l",0,0.001]:m==1||m==3?["M",v+0.5,u,"l",0,-o]:["M",v,u+0.5,"l",o,0],z=this.g.snapEnds(G,l,J),K=z.from,B=z.to,I=z.power,H=0,C=this.set();d=(B-K)/J;var s=K,q=I>0?I:0;w=o/J;if(+m==1||+m==3){var h=u,A=(m-1?1:-1)*(g+3+!!(m-1));while(h>=u-o){n!="-"&&n!=" "&&(F=F.concat(["M",v-(n=="+"||n=="|"?g:!(m-1)*g*2),h+0.5,"l",g*2+1,0]));C.push(this.text(v+A,h,(L&&L[H++])||(Math.round(s)==s?s:+s.toFixed(q))).attr(this.g.txtattr).attr({"text-anchor":m-1?"start":"end"}));s+=d;h-=w;}if(Math.round(h+w-(u-o))){n!="-"&&n!=" "&&(F=F.concat(["M",v-(n=="+"||n=="|"?g:!(m-1)*g*2),u-o+0.5,"l",g*2+1,0]));C.push(this.text(v+A,u-o,(L&&L[H])||(Math.round(s)==s?s:+s.toFixed(q))).attr(this.g.txtattr).attr({"text-anchor":m-1?"start":"end"}));}}else{s=K;q=(I>0)*I;A=(m?-1:1)*(g+9+!m);var k=v,w=o/J,D=0,E=0;while(k<=v+o){n!="-"&&n!=" "&&(F=F.concat(["M",k+0.5,u-(n=="+"?g:!!m*g*2),"l",0,g*2+1]));C.push(D=this.text(k,u+A,(L&&L[H++])||(Math.round(s)==s?s:+s.toFixed(q))).attr(this.g.txtattr));var p=D.getBBox();if(E>=p.x-5){C.pop(C.length-1).remove();}else{E=p.x+p.width;}s+=d;k+=w;}if(Math.round(k-w-v-o)){n!="-"&&n!=" "&&(F=F.concat(["M",v+o+0.5,u-(n=="+"?g:!!m*g*2),"l",0,g*2+1]));C.push(this.text(v+o,u+A,(L&&L[H])||(Math.round(s)==s?s:+s.toFixed(q))).attr(this.g.txtattr));}}var M=this.path(F);M.text=C;M.all=this.set([M,C]);M.remove=function(){this.text.remove();this.constructor.prototype.remove.call(this);};return M;};Raphael.el.lighter=function(g){g=g||2;var f=[this.attrs.fill,this.attrs.stroke];this.fs=this.fs||[f[0],f[1]];f[0]=Raphael.rgb2hsb(Raphael.getRGB(f[0]).hex);f[1]=Raphael.rgb2hsb(Raphael.getRGB(f[1]).hex);f[0].b=c(f[0].b*g,1);f[0].s=f[0].s/g;f[1].b=c(f[1].b*g,1);f[1].s=f[1].s/g;this.attr({fill:"hsb("+[f[0].h,f[0].s,f[0].b]+")",stroke:"hsb("+[f[1].h,f[1].s,f[1].b]+")"});};Raphael.el.darker=function(g){g=g||2;var f=[this.attrs.fill,this.attrs.stroke];this.fs=this.fs||[f[0],f[1]];f[0]=Raphael.rgb2hsb(Raphael.getRGB(f[0]).hex);f[1]=Raphael.rgb2hsb(Raphael.getRGB(f[1]).hex);f[0].s=c(f[0].s*g,1);f[0].b=f[0].b/g;f[1].s=c(f[1].s*g,1);f[1].b=f[1].b/g;this.attr({fill:"hsb("+[f[0].h,f[0].s,f[0].b]+")",stroke:"hsb("+[f[1].h,f[1].s,f[1].b]+")"});};Raphael.el.original=function(){if(this.fs){this.attr({fill:this.fs[0],stroke:this.fs[1]});delete this.fs;}};})();
@@ -1,475 +0,0 @@
1
- /*!
2
- * g.Raphael 0.4.1 - Charting library, based on Raphaël
3
- *
4
- * Copyright (c) 2009 Dmitry Baranovskiy (http://g.raphaeljs.com)
5
- * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
6
- */
7
-
8
-
9
- (function () {
10
- var mmax = Math.max,
11
- mmin = Math.min;
12
- Raphael.fn.g = Raphael.fn.g || {};
13
- Raphael.fn.g.markers = {
14
- disc: "disc",
15
- o: "disc",
16
- flower: "flower",
17
- f: "flower",
18
- diamond: "diamond",
19
- d: "diamond",
20
- square: "square",
21
- s: "square",
22
- triangle: "triangle",
23
- t: "triangle",
24
- star: "star",
25
- "*": "star",
26
- cross: "cross",
27
- x: "cross",
28
- plus: "plus",
29
- "+": "plus",
30
- arrow: "arrow",
31
- "->": "arrow"
32
- };
33
- Raphael.fn.g.shim = {stroke: "none", fill: "#000", "fill-opacity": 0};
34
- Raphael.fn.g.txtattr = {font: "12px Arial, sans-serif"};
35
- Raphael.fn.g.colors = [];
36
- var hues = [.6, .2, .05, .1333, .75, 0];
37
- for (var i = 0; i < 10; i++) {
38
- if (i < hues.length) {
39
- Raphael.fn.g.colors.push("hsb(" + hues[i] + ", .75, .75)");
40
- } else {
41
- Raphael.fn.g.colors.push("hsb(" + hues[i - hues.length] + ", 1, .5)");
42
- }
43
- }
44
- Raphael.fn.g.text = function (x, y, text) {
45
- return this.text(x, y, text).attr(this.g.txtattr);
46
- };
47
- Raphael.fn.g.labelise = function (label, val, total) {
48
- if (label) {
49
- return (label + "").replace(/(##+(?:\.#+)?)|(%%+(?:\.%+)?)/g, function (all, value, percent) {
50
- if (value) {
51
- return (+val).toFixed(value.replace(/^#+\.?/g, "").length);
52
- }
53
- if (percent) {
54
- return (val * 100 / total).toFixed(percent.replace(/^%+\.?/g, "").length) + "%";
55
- }
56
- });
57
- } else {
58
- return (+val).toFixed(0);
59
- }
60
- };
61
-
62
- Raphael.fn.g.finger = function (x, y, width, height, dir, ending, isPath) {
63
- // dir 0 for horisontal and 1 for vertical
64
- if ((dir && !height) || (!dir && !width)) {
65
- return isPath ? "" : this.path();
66
- }
67
- ending = {square: "square", sharp: "sharp", soft: "soft"}[ending] || "round";
68
- var path;
69
- height = Math.round(height);
70
- width = Math.round(width);
71
- x = Math.round(x);
72
- y = Math.round(y);
73
- switch (ending) {
74
- case "round":
75
- if (!dir) {
76
- var r = ~~(height / 2);
77
- if (width < r) {
78
- r = width;
79
- path = ["M", x + .5, y + .5 - ~~(height / 2), "l", 0, 0, "a", r, ~~(height / 2), 0, 0, 1, 0, height, "l", 0, 0, "z"];
80
- } else {
81
- path = ["M", x + .5, y + .5 - r, "l", width - r, 0, "a", r, r, 0, 1, 1, 0, height, "l", r - width, 0, "z"];
82
- }
83
- } else {
84
- r = ~~(width / 2);
85
- if (height < r) {
86
- r = height;
87
- path = ["M", x - ~~(width / 2), y, "l", 0, 0, "a", ~~(width / 2), r, 0, 0, 1, width, 0, "l", 0, 0, "z"];
88
- } else {
89
- path = ["M", x - r, y, "l", 0, r - height, "a", r, r, 0, 1, 1, width, 0, "l", 0, height - r, "z"];
90
- }
91
- }
92
- break;
93
- case "sharp":
94
- if (!dir) {
95
- var half = ~~(height / 2);
96
- path = ["M", x, y + half, "l", 0, -height, mmax(width - half, 0), 0, mmin(half, width), half, -mmin(half, width), half + (half * 2 < height), "z"];
97
- } else {
98
- half = ~~(width / 2);
99
- path = ["M", x + half, y, "l", -width, 0, 0, -mmax(height - half, 0), half, -mmin(half, height), half, mmin(half, height), half, "z"];
100
- }
101
- break;
102
- case "square":
103
- if (!dir) {
104
- path = ["M", x, y + ~~(height / 2), "l", 0, -height, width, 0, 0, height, "z"];
105
- } else {
106
- path = ["M", x + ~~(width / 2), y, "l", 1 - width, 0, 0, -height, width - 1, 0, "z"];
107
- }
108
- break;
109
- case "soft":
110
- if (!dir) {
111
- r = mmin(width, Math.round(height / 5));
112
- path = ["M", x + .5, y + .5 - ~~(height / 2), "l", width - r, 0, "a", r, r, 0, 0, 1, r, r, "l", 0, height - r * 2, "a", r, r, 0, 0, 1, -r, r, "l", r - width, 0, "z"];
113
- } else {
114
- r = mmin(Math.round(width / 5), height);
115
- path = ["M", x - ~~(width / 2), y, "l", 0, r - height, "a", r, r, 0, 0, 1, r, -r, "l", width - 2 * r, 0, "a", r, r, 0, 0, 1, r, r, "l", 0, height - r, "z"];
116
- }
117
- }
118
- if (isPath) {
119
- return path.join(",");
120
- } else {
121
- return this.path(path);
122
- }
123
- };
124
-
125
- // Symbols
126
- Raphael.fn.g.disc = function (cx, cy, r) {
127
- return this.circle(cx, cy, r);
128
- };
129
- Raphael.fn.g.line = function (cx, cy, r) {
130
- return this.rect(cx - r, cy - r / 5, 2 * r, 2 * r / 5);
131
- };
132
- Raphael.fn.g.square = function (cx, cy, r) {
133
- r = r * .7;
134
- return this.rect(cx - r, cy - r, 2 * r, 2 * r);
135
- };
136
- Raphael.fn.g.triangle = function (cx, cy, r) {
137
- r *= 1.75;
138
- return this.path("M".concat(cx, ",", cy, "m0-", r * .58, "l", r * .5, ",", r * .87, "-", r, ",0z"));
139
- };
140
- Raphael.fn.g.diamond = function (cx, cy, r) {
141
- return this.path(["M", cx, cy - r, "l", r, r, -r, r, -r, -r, r, -r, "z"]);
142
- };
143
- Raphael.fn.g.flower = function (cx, cy, r, n) {
144
- r = r * 1.25;
145
- var rout = r,
146
- rin = rout * .5;
147
- n = +n < 3 || !n ? 5 : n;
148
- var points = ["M", cx, cy + rin, "Q"],
149
- R;
150
- for (var i = 1; i < n * 2 + 1; i++) {
151
- R = i % 2 ? rout : rin;
152
- points = points.concat([+(cx + R * Math.sin(i * Math.PI / n)).toFixed(3), +(cy + R * Math.cos(i * Math.PI / n)).toFixed(3)]);
153
- }
154
- points.push("z");
155
- return this.path(points.join(","));
156
- };
157
- Raphael.fn.g.star = function (cx, cy, r, r2, rays) {
158
- r2 = r2 || r * .382;
159
- rays = rays || 5;
160
- var points = ["M", cx, cy + r2, "L"],
161
- R;
162
- for (var i = 1; i < rays * 2; i++) {
163
- R = i % 2 ? r : r2;
164
- points = points.concat([(cx + R * Math.sin(i * Math.PI / rays)), (cy + R * Math.cos(i * Math.PI / rays))]);
165
- }
166
- points.push("z");
167
- return this.path(points.join(","));
168
- };
169
- Raphael.fn.g.cross = function (cx, cy, r) {
170
- r = r / 2.5;
171
- return this.path("M".concat(cx - r, ",", cy, "l", [-r, -r, r, -r, r, r, r, -r, r, r, -r, r, r, r, -r, r, -r, -r, -r, r, -r, -r, "z"]));
172
- };
173
- Raphael.fn.g.plus = function (cx, cy, r) {
174
- r = r / 2;
175
- return this.path("M".concat(cx - r / 2, ",", cy - r / 2, "l", [0, -r, r, 0, 0, r, r, 0, 0, r, -r, 0, 0, r, -r, 0, 0, -r, -r, 0, 0, -r, "z"]));
176
- };
177
- Raphael.fn.g.arrow = function (cx, cy, r) {
178
- return this.path("M".concat(cx - r * .7, ",", cy - r * .4, "l", [r * .6, 0, 0, -r * .4, r, r * .8, -r, r * .8, 0, -r * .4, -r * .6, 0], "z"));
179
- };
180
-
181
- // Tooltips
182
- Raphael.fn.g.tag = function (x, y, text, angle, r) {
183
- angle = angle || 0;
184
- r = r == null ? 5 : r;
185
- text = text == null ? "$9.99" : text;
186
- var R = .5522 * r,
187
- res = this.set(),
188
- d = 3;
189
- res.push(this.path().attr({fill: "#000", stroke: "#000"}));
190
- res.push(this.text(x, y, text).attr(this.g.txtattr).attr({fill: "#fff", "font-family": "Helvetica, Arial"}));
191
- res.update = function () {
192
- this.rotate(0, x, y);
193
- var bb = this[1].getBBox();
194
- if (bb.height >= r * 2) {
195
- this[0].attr({path: ["M", x, y + r, "a", r, r, 0, 1, 1, 0, -r * 2, r, r, 0, 1, 1, 0, r * 2, "m", 0, -r * 2 -d, "a", r + d, r + d, 0, 1, 0, 0, (r + d) * 2, "L", x + r + d, y + bb.height / 2 + d, "l", bb.width + 2 * d, 0, 0, -bb.height - 2 * d, -bb.width - 2 * d, 0, "L", x, y - r - d].join(",")});
196
- } else {
197
- var dx = Math.sqrt(Math.pow(r + d, 2) - Math.pow(bb.height / 2 + d, 2));
198
- this[0].attr({path: ["M", x, y + r, "c", -R, 0, -r, R - r, -r, -r, 0, -R, r - R, -r, r, -r, R, 0, r, r - R, r, r, 0, R, R - r, r, -r, r, "M", x + dx, y - bb.height / 2 - d, "a", r + d, r + d, 0, 1, 0, 0, bb.height + 2 * d, "l", r + d - dx + bb.width + 2 * d, 0, 0, -bb.height - 2 * d, "L", x + dx, y - bb.height / 2 - d].join(",")});
199
- }
200
- this[1].attr({x: x + r + d + bb.width / 2, y: y});
201
- angle = (360 - angle) % 360;
202
- this.rotate(angle, x, y);
203
- angle > 90 && angle < 270 && this[1].attr({x: x - r - d - bb.width / 2, y: y, rotation: [180 + angle, x, y]});
204
- return this;
205
- };
206
- res.update();
207
- return res;
208
- };
209
- Raphael.fn.g.popupit = function (x, y, set, dir, size) {
210
- dir = dir == null ? 2 : dir;
211
- size = size || 5;
212
- x = Math.round(x);
213
- y = Math.round(y);
214
- var bb = set.getBBox(),
215
- w = Math.round(bb.width / 2),
216
- h = Math.round(bb.height / 2),
217
- dx = [0, w + size * 2, 0, -w - size * 2],
218
- dy = [-h * 2 - size * 3, -h - size, 0, -h - size],
219
- p = ["M", x - dx[dir], y - dy[dir], "l", -size, (dir == 2) * -size, -mmax(w - size, 0), 0, "a", size, size, 0, 0, 1, -size, -size,
220
- "l", 0, -mmax(h - size, 0), (dir == 3) * -size, -size, (dir == 3) * size, -size, 0, -mmax(h - size, 0), "a", size, size, 0, 0, 1, size, -size,
221
- "l", mmax(w - size, 0), 0, size, !dir * -size, size, !dir * size, mmax(w - size, 0), 0, "a", size, size, 0, 0, 1, size, size,
222
- "l", 0, mmax(h - size, 0), (dir == 1) * size, size, (dir == 1) * -size, size, 0, mmax(h - size, 0), "a", size, size, 0, 0, 1, -size, size,
223
- "l", -mmax(w - size, 0), 0, "z"].join(","),
224
- xy = [{x: x, y: y + size * 2 + h}, {x: x - size * 2 - w, y: y}, {x: x, y: y - size * 2 - h}, {x: x + size * 2 + w, y: y}][dir];
225
- set.translate(xy.x - w - bb.x, xy.y - h - bb.y);
226
- return this.path(p).attr({fill: "#000", stroke: "none"}).insertBefore(set.node ? set : set[0]);
227
- };
228
- Raphael.fn.g.popup = function (x, y, text, dir, size) {
229
- dir = dir == null ? 2 : dir > 3 ? 3 : dir;
230
- size = size || 5;
231
- text = text || "$9.99";
232
- var res = this.set(),
233
- d = 3;
234
- res.push(this.path().attr({fill: "#000", stroke: "#000"}));
235
- res.push(this.text(x, y, text).attr(this.g.txtattr).attr({fill: "#fff", "font-family": "Helvetica, Arial"}));
236
- res.update = function (X, Y, withAnimation) {
237
- X = X || x;
238
- Y = Y || y;
239
- var bb = this[1].getBBox(),
240
- w = bb.width / 2,
241
- h = bb.height / 2,
242
- dx = [0, w + size * 2, 0, -w - size * 2],
243
- dy = [-h * 2 - size * 3, -h - size, 0, -h - size],
244
- p = ["M", X - dx[dir], Y - dy[dir], "l", -size, (dir == 2) * -size, -mmax(w - size, 0), 0, "a", size, size, 0, 0, 1, -size, -size,
245
- "l", 0, -mmax(h - size, 0), (dir == 3) * -size, -size, (dir == 3) * size, -size, 0, -mmax(h - size, 0), "a", size, size, 0, 0, 1, size, -size,
246
- "l", mmax(w - size, 0), 0, size, !dir * -size, size, !dir * size, mmax(w - size, 0), 0, "a", size, size, 0, 0, 1, size, size,
247
- "l", 0, mmax(h - size, 0), (dir == 1) * size, size, (dir == 1) * -size, size, 0, mmax(h - size, 0), "a", size, size, 0, 0, 1, -size, size,
248
- "l", -mmax(w - size, 0), 0, "z"].join(","),
249
- xy = [{x: X, y: Y + size * 2 + h}, {x: X - size * 2 - w, y: Y}, {x: X, y: Y - size * 2 - h}, {x: X + size * 2 + w, y: Y}][dir];
250
- xy.path = p;
251
- if (withAnimation) {
252
- this.animate(xy, 500, ">");
253
- } else {
254
- this.attr(xy);
255
- }
256
- return this;
257
- };
258
- return res.update(x, y);
259
- };
260
- Raphael.fn.g.flag = function (x, y, text, angle) {
261
- angle = angle || 0;
262
- text = text || "$9.99";
263
- var res = this.set(),
264
- d = 3;
265
- res.push(this.path().attr({fill: "#000", stroke: "#000"}));
266
- res.push(this.text(x, y, text).attr(this.g.txtattr).attr({fill: "#fff", "font-family": "Helvetica, Arial"}));
267
- res.update = function (x, y) {
268
- this.rotate(0, x, y);
269
- var bb = this[1].getBBox(),
270
- h = bb.height / 2;
271
- this[0].attr({path: ["M", x, y, "l", h + d, -h - d, bb.width + 2 * d, 0, 0, bb.height + 2 * d, -bb.width - 2 * d, 0, "z"].join(",")});
272
- this[1].attr({x: x + h + d + bb.width / 2, y: y});
273
- angle = 360 - angle;
274
- this.rotate(angle, x, y);
275
- angle > 90 && angle < 270 && this[1].attr({x: x - r - d - bb.width / 2, y: y, rotation: [180 + angle, x, y]});
276
- return this;
277
- };
278
- return res.update(x, y);
279
- };
280
- Raphael.fn.g.label = function (x, y, text) {
281
- var res = this.set();
282
- res.push(this.rect(x, y, 10, 10).attr({stroke: "none", fill: "#000"}));
283
- res.push(this.text(x, y, text).attr(this.g.txtattr).attr({fill: "#fff"}));
284
- res.update = function () {
285
- var bb = this[1].getBBox(),
286
- r = mmin(bb.width + 10, bb.height + 10) / 2;
287
- this[0].attr({x: bb.x - r / 2, y: bb.y - r / 2, width: bb.width + r, height: bb.height + r, r: r});
288
- };
289
- res.update();
290
- return res;
291
- };
292
- Raphael.fn.g.labelit = function (set) {
293
- var bb = set.getBBox(),
294
- r = mmin(20, bb.width + 10, bb.height + 10) / 2;
295
- return this.rect(bb.x - r / 2, bb.y - r / 2, bb.width + r, bb.height + r, r).attr({stroke: "none", fill: "#000"}).insertBefore(set.node ? set : set[0]);
296
- };
297
- Raphael.fn.g.drop = function (x, y, text, size, angle) {
298
- size = size || 30;
299
- angle = angle || 0;
300
- var res = this.set();
301
- res.push(this.path(["M", x, y, "l", size, 0, "A", size * .4, size * .4, 0, 1, 0, x + size * .7, y - size * .7, "z"]).attr({fill: "#000", stroke: "none", rotation: [22.5 - angle, x, y]}));
302
- angle = (angle + 90) * Math.PI / 180;
303
- res.push(this.text(x + size * Math.sin(angle), y + size * Math.cos(angle), text).attr(this.g.txtattr).attr({"font-size": size * 12 / 30, fill: "#fff"}));
304
- res.drop = res[0];
305
- res.text = res[1];
306
- return res;
307
- };
308
- Raphael.fn.g.blob = function (x, y, text, angle, size) {
309
- angle = (+angle + 1 ? angle : 45) + 90;
310
- size = size || 12;
311
- var rad = Math.PI / 180,
312
- fontSize = size * 12 / 12;
313
- var res = this.set();
314
- res.push(this.path().attr({fill: "#000", stroke: "none"}));
315
- res.push(this.text(x + size * Math.sin((angle) * rad), y + size * Math.cos((angle) * rad) - fontSize / 2, text).attr(this.g.txtattr).attr({"font-size": fontSize, fill: "#fff"}));
316
- res.update = function (X, Y, withAnimation) {
317
- X = X || x;
318
- Y = Y || y;
319
- var bb = this[1].getBBox(),
320
- w = mmax(bb.width + fontSize, size * 25 / 12),
321
- h = mmax(bb.height + fontSize, size * 25 / 12),
322
- x2 = X + size * Math.sin((angle - 22.5) * rad),
323
- y2 = Y + size * Math.cos((angle - 22.5) * rad),
324
- x1 = X + size * Math.sin((angle + 22.5) * rad),
325
- y1 = Y + size * Math.cos((angle + 22.5) * rad),
326
- dx = (x1 - x2) / 2,
327
- dy = (y1 - y2) / 2,
328
- rx = w / 2,
329
- ry = h / 2,
330
- k = -Math.sqrt(Math.abs(rx * rx * ry * ry - rx * rx * dy * dy - ry * ry * dx * dx) / (rx * rx * dy * dy + ry * ry * dx * dx)),
331
- cx = k * rx * dy / ry + (x1 + x2) / 2,
332
- cy = k * -ry * dx / rx + (y1 + y2) / 2;
333
- if (withAnimation) {
334
- this.animate({x: cx, y: cy, path: ["M", x, y, "L", x1, y1, "A", rx, ry, 0, 1, 1, x2, y2, "z"].join(",")}, 500, ">");
335
- } else {
336
- this.attr({x: cx, y: cy, path: ["M", x, y, "L", x1, y1, "A", rx, ry, 0, 1, 1, x2, y2, "z"].join(",")});
337
- }
338
- return this;
339
- };
340
- res.update(x, y);
341
- return res;
342
- };
343
-
344
- Raphael.fn.g.colorValue = function (value, total, s, b) {
345
- return "hsb(" + [mmin((1 - value / total) * .4, 1), s || .75, b || .75] + ")";
346
- };
347
-
348
- Raphael.fn.g.snapEnds = function (from, to, steps) {
349
- var f = from,
350
- t = to;
351
- if (f == t) {
352
- return {from: f, to: t, power: 0};
353
- }
354
- function round(a) {
355
- return Math.abs(a - .5) < .25 ? ~~(a) + .5 : Math.round(a);
356
- }
357
- var d = (t - f) / steps,
358
- r = ~~(d),
359
- R = r,
360
- i = 0;
361
- if (r) {
362
- while (R) {
363
- i--;
364
- R = ~~(d * Math.pow(10, i)) / Math.pow(10, i);
365
- }
366
- i ++;
367
- } else {
368
- while (!r) {
369
- i = i || 1;
370
- r = ~~(d * Math.pow(10, i)) / Math.pow(10, i);
371
- i++;
372
- }
373
- i && i--;
374
- }
375
- t = round(to * Math.pow(10, i)) / Math.pow(10, i);
376
- if (t < to) {
377
- t = round((to + .5) * Math.pow(10, i)) / Math.pow(10, i);
378
- }
379
- f = round((from - (i > 0 ? 0 : .5)) * Math.pow(10, i)) / Math.pow(10, i);
380
- return {from: f, to: t, power: i};
381
- };
382
- Raphael.fn.g.axis = function (x, y, length, from, to, steps, orientation, labels, type, dashsize) {
383
- dashsize = dashsize == null ? 2 : dashsize;
384
- type = type || "t";
385
- steps = steps || 10;
386
- var path = type == "|" || type == " " ? ["M", x + .5, y, "l", 0, .001] : orientation == 1 || orientation == 3 ? ["M", x + .5, y, "l", 0, -length] : ["M", x, y + .5, "l", length, 0],
387
- ends = this.g.snapEnds(from, to, steps),
388
- f = ends.from,
389
- t = ends.to,
390
- i = ends.power,
391
- j = 0,
392
- text = this.set();
393
- d = (t - f) / steps;
394
- var label = f,
395
- rnd = i > 0 ? i : 0;
396
- dx = length / steps;
397
- if (+orientation == 1 || +orientation == 3) {
398
- var Y = y,
399
- addon = (orientation - 1 ? 1 : -1) * (dashsize + 3 + !!(orientation - 1));
400
- while (Y >= y - length) {
401
- type != "-" && type != " " && (path = path.concat(["M", x - (type == "+" || type == "|" ? dashsize : !(orientation - 1) * dashsize * 2), Y + .5, "l", dashsize * 2 + 1, 0]));
402
- text.push(this.text(x + addon, Y, (labels && labels[j++]) || (Math.round(label) == label ? label : +label.toFixed(rnd))).attr(this.g.txtattr).attr({"text-anchor": orientation - 1 ? "start" : "end"}));
403
- label += d;
404
- Y -= dx;
405
- }
406
- if (Math.round(Y + dx - (y - length))) {
407
- type != "-" && type != " " && (path = path.concat(["M", x - (type == "+" || type == "|" ? dashsize : !(orientation - 1) * dashsize * 2), y - length + .5, "l", dashsize * 2 + 1, 0]));
408
- text.push(this.text(x + addon, y - length, (labels && labels[j]) || (Math.round(label) == label ? label : +label.toFixed(rnd))).attr(this.g.txtattr).attr({"text-anchor": orientation - 1 ? "start" : "end"}));
409
- }
410
- } else {
411
- label = f;
412
- rnd = (i > 0) * i;
413
- addon = (orientation ? -1 : 1) * (dashsize + 9 + !orientation);
414
- var X = x,
415
- dx = length / steps,
416
- txt = 0,
417
- prev = 0;
418
- while (X <= x + length) {
419
- type != "-" && type != " " && (path = path.concat(["M", X + .5, y - (type == "+" ? dashsize : !!orientation * dashsize * 2), "l", 0, dashsize * 2 + 1]));
420
- text.push(txt = this.text(X, y + addon, (labels && labels[j++]) || (Math.round(label) == label ? label : +label.toFixed(rnd))).attr(this.g.txtattr));
421
- var bb = txt.getBBox();
422
- if (prev >= bb.x - 5) {
423
- text.pop(text.length - 1).remove();
424
- } else {
425
- prev = bb.x + bb.width;
426
- }
427
- label += d;
428
- X += dx;
429
- }
430
- if (Math.round(X - dx - x - length)) {
431
- type != "-" && type != " " && (path = path.concat(["M", x + length + .5, y - (type == "+" ? dashsize : !!orientation * dashsize * 2), "l", 0, dashsize * 2 + 1]));
432
- text.push(this.text(x + length, y + addon, (labels && labels[j]) || (Math.round(label) == label ? label : +label.toFixed(rnd))).attr(this.g.txtattr));
433
- }
434
- }
435
- var res = this.path(path);
436
- res.text = text;
437
- res.all = this.set([res, text]);
438
- res.remove = function () {
439
- this.text.remove();
440
- this.constructor.prototype.remove.call(this);
441
- };
442
- return res;
443
- };
444
-
445
- Raphael.el.lighter = function (times) {
446
- times = times || 2;
447
- var fs = [this.attrs.fill, this.attrs.stroke];
448
- this.fs = this.fs || [fs[0], fs[1]];
449
- fs[0] = Raphael.rgb2hsb(Raphael.getRGB(fs[0]).hex);
450
- fs[1] = Raphael.rgb2hsb(Raphael.getRGB(fs[1]).hex);
451
- fs[0].b = mmin(fs[0].b * times, 1);
452
- fs[0].s = fs[0].s / times;
453
- fs[1].b = mmin(fs[1].b * times, 1);
454
- fs[1].s = fs[1].s / times;
455
- this.attr({fill: "hsb(" + [fs[0].h, fs[0].s, fs[0].b] + ")", stroke: "hsb(" + [fs[1].h, fs[1].s, fs[1].b] + ")"});
456
- };
457
- Raphael.el.darker = function (times) {
458
- times = times || 2;
459
- var fs = [this.attrs.fill, this.attrs.stroke];
460
- this.fs = this.fs || [fs[0], fs[1]];
461
- fs[0] = Raphael.rgb2hsb(Raphael.getRGB(fs[0]).hex);
462
- fs[1] = Raphael.rgb2hsb(Raphael.getRGB(fs[1]).hex);
463
- fs[0].s = mmin(fs[0].s * times, 1);
464
- fs[0].b = fs[0].b / times;
465
- fs[1].s = mmin(fs[1].s * times, 1);
466
- fs[1].b = fs[1].b / times;
467
- this.attr({fill: "hsb(" + [fs[0].h, fs[0].s, fs[0].b] + ")", stroke: "hsb(" + [fs[1].h, fs[1].s, fs[1].b] + ")"});
468
- };
469
- Raphael.el.original = function () {
470
- if (this.fs) {
471
- this.attr({fill: this.fs[0], stroke: this.fs[1]});
472
- delete this.fs;
473
- }
474
- };
475
- })();