visage-app 0.1.8 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,475 @@
1
- /*
2
- * g.Raphael 0.4 - Charting library, based on Raphaël
1
+ /*!
2
+ * g.Raphael 0.4.1 - Charting library, based on Raphaël
3
3
  *
4
4
  * Copyright (c) 2009 Dmitry Baranovskiy (http://g.raphaeljs.com)
5
5
  * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
6
6
  */
7
- (function(){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 b=[0.6,0.2,0.05,0.1333,0.75,0];for(var a=0;a<10;a++){if(a<b.length){Raphael.fn.g.colors.push("hsb("+b[a]+", .75, .75)");}else{Raphael.fn.g.colors.push("hsb("+b[a-b.length]+", 1, .5)");}}Raphael.fn.g.text=function(c,f,e){return this.text(c,f,e).attr(this.g.txtattr);};Raphael.fn.g.labelise=function(c,f,e){if(c){return(c+"").replace(/(##+(?:\.#+)?)|(%%+(?:\.%+)?)/g,function(g,i,h){if(i){return(+f).toFixed(i.replace(/^#+\.?/g,"").length);}if(h){return(f*100/e).toFixed(h.replace(/^%+\.?/g,"").length)+"%";}});}else{return(+f).toFixed(0);}};Raphael.fn.g.finger=function(j,i,e,k,f,g,h){if((f&&!k)||(!f&&!e)){return h?"":this.path();}g={square:"square",sharp:"sharp",soft:"soft"}[g]||"round";var m;k=Math.round(k);e=Math.round(e);j=Math.round(j);i=Math.round(i);switch(g){case"round":if(!f){var c=Math.floor(k/2);if(e<c){c=e;m=["M",j+0.5,i+0.5-Math.floor(k/2),"l",0,0,"a",c,Math.floor(k/2),0,0,1,0,k,"l",0,0,"z"];}else{m=["M",j+0.5,i+0.5-c,"l",e-c,0,"a",c,c,0,1,1,0,k,"l",c-e,0,"z"];}}else{var c=Math.floor(e/2);if(k<c){c=k;m=["M",j-Math.floor(e/2),i,"l",0,0,"a",Math.floor(e/2),c,0,0,1,e,0,"l",0,0,"z"];}else{m=["M",j-c,i,"l",0,c-k,"a",c,c,0,1,1,e,0,"l",0,k-c,"z"];}}break;case"sharp":if(!f){var l=Math.floor(k/2);m=["M",j,i+l,"l",0,-k,Math.max(e-l,0),0,Math.min(l,e),l,-Math.min(l,e),l+(l*2<k),"z"];}else{var l=Math.floor(e/2);m=["M",j+l,i,"l",-e,0,0,-Math.max(k-l,0),l,-Math.min(l,k),l,Math.min(l,k),l,"z"];}break;case"square":if(!f){m=["M",j,i+Math.floor(k/2),"l",0,-k,e,0,0,k,"z"];}else{m=["M",j+Math.floor(e/2),i,"l",1-e,0,0,-k,e-1,0,"z"];}break;case"soft":var c;if(!f){c=Math.min(e,Math.round(k/5));m=["M",j+0.5,i+0.5-Math.floor(k/2),"l",e-c,0,"a",c,c,0,0,1,c,c,"l",0,k-c*2,"a",c,c,0,0,1,-c,c,"l",c-e,0,"z"];}else{c=Math.min(Math.round(e/5),k);m=["M",j-Math.floor(e/2),i,"l",0,c-k,"a",c,c,0,0,1,c,-c,"l",e-2*c,0,"a",c,c,0,0,1,c,c,"l",0,k-c,"z"];}}if(h){return m.join(",");}else{return this.path(m);}};Raphael.fn.g.disc=function(c,f,e){return this.circle(c,f,e);};Raphael.fn.g.line=function(c,f,e){return this.rect(c-e,f-e/5,2*e,2*e/5);};Raphael.fn.g.square=function(c,f,e){e=e*0.7;return this.rect(c-e,f-e,2*e,2*e);};Raphael.fn.g.triangle=function(c,f,e){e*=1.75;return this.path("M".concat(c,",",f,"m0-",e*0.58,"l",e*0.5,",",e*0.87,"-",e,",0z"));};Raphael.fn.g.diamond=function(c,f,e){return this.path(["M",c,f-e,"l",e,e,-e,e,-e,-e,e,-e,"z"]);};Raphael.fn.g.flower=function(g,f,c,e){c=c*1.25;var l=c,k=l*0.5;e=+e<3||!e?5:e;var m=["M",g,f+k,"Q"],j;for(var h=1;h<e*2+1;h++){j=h%2?l:k;m=m.concat([+(g+j*Math.sin(h*Math.PI/e)).toFixed(3),+(f+j*Math.cos(h*Math.PI/e)).toFixed(3)]);}m.push("z");return this.path(m.join(","));};Raphael.fn.g.star=function(c,k,j,e){e=e||j*0.5;var h=["M",c,k+e,"L"],g;for(var f=1;f<10;f++){g=f%2?j:e;h=h.concat([(c+g*Math.sin(f*Math.PI*0.2)).toFixed(3),(k+g*Math.cos(f*Math.PI*0.2)).toFixed(3)]);}h.push("z");return this.path(h.join(","));};Raphael.fn.g.cross=function(c,f,e){e=e/2.5;return this.path("M".concat(c-e,",",f,"l",[-e,-e,e,-e,e,e,e,-e,e,e,-e,e,e,e,-e,e,-e,-e,-e,e,-e,-e,"z"]));};Raphael.fn.g.plus=function(c,f,e){e=e/2;return this.path("M".concat(c-e/2,",",f-e/2,"l",[0,-e,e,0,0,e,e,0,0,e,-e,0,0,e,-e,0,0,-e,-e,0,0,-e,"z"]));};Raphael.fn.g.arrow=function(c,f,e){return this.path("M".concat(c-e*0.7,",",f-e*0.4,"l",[e*0.6,0,0,-e*0.4,e,e*0.8,-e,e*0.8,0,-e*0.4,-e*0.6,0],"z"));};Raphael.fn.g.tag=function(c,k,j,i,g){i=i||0;g=g==null?5:g;j=j==null?"$9.99":j;var f=0.5522*g,e=this.set(),h=3;e.push(this.path().attr({fill:"#000",stroke:"none"}));e.push(this.text(c,k,j).attr(this.g.txtattr).attr({fill:"#fff"}));e.update=function(){this.rotate(0,c,k);var m=this[1].getBBox();if(m.height>=g*2){this[0].attr({path:["M",c,k+g,"a",g,g,0,1,1,0,-g*2,g,g,0,1,1,0,g*2,"m",0,-g*2-h,"a",g+h,g+h,0,1,0,0,(g+h)*2,"L",c+g+h,k+m.height/2+h,"l",m.width+2*h,0,0,-m.height-2*h,-m.width-2*h,0,"L",c,k-g-h].join(",")});}else{var l=Math.sqrt(Math.pow(g+h,2)-Math.pow(m.height/2+h,2));this[0].attr({path:["M",c,k+g,"c",-f,0,-g,f-g,-g,-g,0,-f,g-f,-g,g,-g,f,0,g,g-f,g,g,0,f,f-g,g,-g,g,"M",c+l,k-m.height/2-h,"a",g+h,g+h,0,1,0,0,m.height+2*h,"l",g+h-l+m.width+2*h,0,0,-m.height-2*h,"L",c+l,k-m.height/2-h].join(",")});}this[1].attr({x:c+g+h+m.width/2,y:k});i=(360-i)%360;this.rotate(i,c,k);i>90&&i<270&&this[1].attr({x:c-g-h-m.width/2,y:k,rotation:[180+i,c,k]});return this;};e.update();return e;};Raphael.fn.g.popupit=function(j,i,k,e,q){e=e==null?2:e;q=q||5;j=Math.round(j)+0.5;i=Math.round(i)+0.5;var g=k.getBBox(),l=Math.round(g.width/2),f=Math.round(g.height/2),o=[0,l+q*2,0,-l-q*2],m=[-f*2-q*3,-f-q,0,-f-q],c=["M",j-o[e],i-m[e],"l",-q,(e==2)*-q,-Math.max(l-q,0),0,"a",q,q,0,0,1,-q,-q,"l",0,-Math.max(f-q,0),(e==3)*-q,-q,(e==3)*q,-q,0,-Math.max(f-q,0),"a",q,q,0,0,1,q,-q,"l",Math.max(l-q,0),0,q,!e*-q,q,!e*q,Math.max(l-q,0),0,"a",q,q,0,0,1,q,q,"l",0,Math.max(f-q,0),(e==1)*q,q,(e==1)*-q,q,0,Math.max(f-q,0),"a",q,q,0,0,1,-q,q,"l",-Math.max(l-q,0),0,"z"].join(","),n=[{x:j,y:i+q*2+f},{x:j-q*2-l,y:i},{x:j,y:i-q*2-f},{x:j+q*2+l,y:i}][e];k.translate(n.x-l-g.x,n.y-f-g.y);return this.path(c).attr({fill:"#000",stroke:"none"}).insertBefore(k.node?k:k[0]);};Raphael.fn.g.popup=function(c,j,i,e,g){e=e==null?2:e;g=g||5;i=i||"$9.99";var f=this.set(),h=3;f.push(this.path().attr({fill:"#000",stroke:"none"}));f.push(this.text(c,j,i).attr(this.g.txtattr).attr({fill:"#fff"}));f.update=function(m,l,n){m=m||c;l=l||j;var q=this[1].getBBox(),s=q.width/2,o=q.height/2,v=[0,s+g*2,0,-s-g*2],t=[-o*2-g*3,-o-g,0,-o-g],k=["M",m-v[e],l-t[e],"l",-g,(e==2)*-g,-Math.max(s-g,0),0,"a",g,g,0,0,1,-g,-g,"l",0,-Math.max(o-g,0),(e==3)*-g,-g,(e==3)*g,-g,0,-Math.max(o-g,0),"a",g,g,0,0,1,g,-g,"l",Math.max(s-g,0),0,g,!e*-g,g,!e*g,Math.max(s-g,0),0,"a",g,g,0,0,1,g,g,"l",0,Math.max(o-g,0),(e==1)*g,g,(e==1)*-g,g,0,Math.max(o-g,0),"a",g,g,0,0,1,-g,g,"l",-Math.max(s-g,0),0,"z"].join(","),u=[{x:m,y:l+g*2+o},{x:m-g*2-s,y:l},{x:m,y:l-g*2-o},{x:m+g*2+s,y:l}][e];if(n){this[0].animate({path:k},500,">");this[1].animate(u,500,">");}else{this[0].attr({path:k});this[1].attr(u);}return this;};return f.update(c,j);};Raphael.fn.g.flag=function(c,i,h,g){g=g||0;h=h||"$9.99";var e=this.set(),f=3;e.push(this.path().attr({fill:"#000",stroke:"none"}));e.push(this.text(c,i,h).attr(this.g.txtattr).attr({fill:"#fff"}));e.update=function(j,m){this.rotate(0,j,m);var l=this[1].getBBox(),k=l.height/2;this[0].attr({path:["M",j,m,"l",k+f,-k-f,l.width+2*f,0,0,l.height+2*f,-l.width-2*f,0,"z"].join(",")});this[1].attr({x:j+k+f+l.width/2,y:m});g=360-g;this.rotate(g,j,m);g>90&&g<270&&this[1].attr({x:j-r-f-l.width/2,y:m,rotation:[180+g,j,m]});return this;};return e.update(c,i);};Raphael.fn.g.label=function(c,g,f){var e=this.set();e.push(this.rect(c,g,10,10).attr({stroke:"none",fill:"#000"}));e.push(this.text(c,g,f).attr(this.g.txtattr).attr({fill:"#fff"}));e.update=function(){var i=this[1].getBBox(),h=Math.min(i.width+10,i.height+10)/2;this[0].attr({x:i.x-h/2,y:i.y-h/2,width:i.width+h,height:i.height+h,r:h});};e.update();return e;};Raphael.fn.g.labelit=function(f){var e=f.getBBox(),c=Math.min(20,e.width+10,e.height+10)/2;return this.rect(e.x-c/2,e.y-c/2,e.width+c,e.height+c,c).attr({stroke:"none",fill:"#000"}).insertBefore(f[0]);};Raphael.fn.g.drop=function(c,i,h,f,g){f=f||30;g=g||0;var e=this.set();e.push(this.path(["M",c,i,"l",f,0,"A",f*0.4,f*0.4,0,1,0,c+f*0.7,i-f*0.7,"z"]).attr({fill:"#000",stroke:"none",rotation:[22.5-g,c,i]}));g=(g+90)*Math.PI/180;e.push(this.text(c+f*Math.sin(g),i+f*Math.cos(g),h).attr(this.g.txtattr).attr({"font-size":f*12/30,fill:"#fff"}));e.drop=e[0];e.text=e[1];return e;};Raphael.fn.g.blob=function(e,k,j,i,g){i=(+i+1?i:45)+90;g=g||12;var c=Math.PI/180,h=g*12/12;var f=this.set();f.push(this.path().attr({fill:"#000",stroke:"none"}));f.push(this.text(e+g*Math.sin((i)*c),k+g*Math.cos((i)*c)-h/2,j).attr(this.g.txtattr).attr({"font-size":h,fill:"#fff"}));f.update=function(q,p,v){q=q||e;p=p||k;var y=this[1].getBBox(),B=Math.max(y.width+h,g*25/12),x=Math.max(y.height+h,g*25/12),m=q+g*Math.sin((i-22.5)*c),z=p+g*Math.cos((i-22.5)*c),o=q+g*Math.sin((i+22.5)*c),A=p+g*Math.cos((i+22.5)*c),D=(o-m)/2,C=(A-z)/2,n=B/2,l=x/2,u=-Math.sqrt(Math.abs(n*n*l*l-n*n*C*C-l*l*D*D)/(n*n*C*C+l*l*D*D)),t=u*n*C/l+(o+m)/2,s=u*-l*D/n+(A+z)/2;if(v){this.animate({x:t,y:s,path:["M",e,k,"L",o,A,"A",n,l,0,1,1,m,z,"z"].join(",")},500,">");}else{this.attr({x:t,y:s,path:["M",e,k,"L",o,A,"A",n,l,0,1,1,m,z,"z"].join(",")});}return this;};f.update(e,k);return f;};Raphael.fn.g.colorValue=function(g,f,e,c){return"hsb("+[Math.min((1-g/f)*0.4,1),e||0.75,c||0.75]+")";};Raphael.fn.g.snapEnds=function(l,m,k){var h=l,n=m;if(h==n){return{from:h,to:n,power:0};}function o(f){return Math.abs(f-0.5)<0.25?Math.floor(f)+0.5:Math.round(f);}var j=(n-h)/k,c=Math.floor(j),g=c,e=0;if(c){while(g){e--;g=Math.floor(j*Math.pow(10,e))/Math.pow(10,e);}e++;}else{while(!c){e=e||1;c=Math.floor(j*Math.pow(10,e))/Math.pow(10,e);e++;}e&&e--;}var n=o(m*Math.pow(10,e))/Math.pow(10,e);if(n<m){n=o((m+0.5)*Math.pow(10,e))/Math.pow(10,e);}var h=o((l-(e>0?0:0.5))*Math.pow(10,e))/Math.pow(10,e);return{from:h,to:n,power:e};};Raphael.fn.g.axis=function(s,q,m,E,h,H,k,J,l,c){c=c==null?2:c;l=l||"t";H=H||10;var D=l=="|"||l==" "?["M",s+0.5,q,"l",0,0.001]:k==1||k==3?["M",s+0.5,q,"l",0,-m]:["M",s,q+0.5,"l",m,0],v=this.g.snapEnds(E,h,H),I=v.from,z=v.to,G=v.power,F=0,A=this.set();d=(z-I)/H;var p=I,o=G>0?G:0;u=m/H;if(+k==1||+k==3){var e=q,w=(k-1?1:-1)*(c+3+!!(k-1));while(e>=q-m){l!="-"&&l!=" "&&(D=D.concat(["M",s-(l=="+"||l=="|"?c:!(k-1)*c*2),e+0.5,"l",c*2+1,0]));A.push(this.text(s+w,e,(J&&J[F++])||(Math.round(p)==p?p:+p.toFixed(o))).attr(this.g.txtattr).attr({"text-anchor":k-1?"start":"end"}));p+=d;e-=u;}if(Math.round(e+u-(q-m))){l!="-"&&l!=" "&&(D=D.concat(["M",s-(l=="+"||l=="|"?c:!(k-1)*c*2),q-m+0.5,"l",c*2+1,0]));A.push(this.text(s+w,q-m,(J&&J[F])||(Math.round(p)==p?p:+p.toFixed(o))).attr(this.g.txtattr).attr({"text-anchor":k-1?"start":"end"}));}}else{var g=s,p=I,o=G>0?G:0,w=(k?-1:1)*(c+9+!k),u=m/H,B=0,C=0;while(g<=s+m){l!="-"&&l!=" "&&(D=D.concat(["M",g+0.5,q-(l=="+"?c:!!k*c*2),"l",0,c*2+1]));A.push(B=this.text(g,q+w,(J&&J[F++])||(Math.round(p)==p?p:+p.toFixed(o))).attr(this.g.txtattr));var n=B.getBBox();if(C>=n.x-5){A.pop(A.length-1).remove();}else{C=n.x+n.width;}p+=d;g+=u;}if(Math.round(g-u-s-m)){l!="-"&&l!=" "&&(D=D.concat(["M",s+m+0.5,q-(l=="+"?c:!!k*c*2),"l",0,c*2+1]));A.push(this.text(s+m,q+w,(J&&J[F])||(Math.round(p)==p?p:+p.toFixed(o))).attr(this.g.txtattr));}}var K=this.path(D);K.text=A;K.all=this.set([K,A]);K.remove=function(){this.text.remove();this.constructor.prototype.remove.call(this);};return K;};Raphael.el.lighter=function(e){e=e||2;var c=[this.attrs.fill,this.attrs.stroke];this.fs=this.fs||[c[0],c[1]];c[0]=Raphael.rgb2hsb(Raphael.getRGB(c[0]).hex);c[1]=Raphael.rgb2hsb(Raphael.getRGB(c[1]).hex);c[0].b=Math.min(c[0].b*e,1);c[0].s=c[0].s/e;c[1].b=Math.min(c[1].b*e,1);c[1].s=c[1].s/e;this.attr({fill:"hsb("+[c[0].h,c[0].s,c[0].b]+")",stroke:"hsb("+[c[1].h,c[1].s,c[1].b]+")"});};Raphael.el.darker=function(e){e=e||2;var c=[this.attrs.fill,this.attrs.stroke];this.fs=this.fs||[c[0],c[1]];c[0]=Raphael.rgb2hsb(Raphael.getRGB(c[0]).hex);c[1]=Raphael.rgb2hsb(Raphael.getRGB(c[1]).hex);c[0].s=Math.min(c[0].s*e,1);c[0].b=c[0].b/e;c[1].s=Math.min(c[1].s*e,1);c[1].b=c[1].b/e;this.attr({fill:"hsb("+[c[0].h,c[0].s,c[0].b]+")",stroke:"hsb("+[c[1].h,c[1].s,c[1].b]+")"});};Raphael.el.original=function(){if(this.fs){this.attr({fill:this.fs[0],stroke:this.fs[1]});delete this.fs;}};})();
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
+ })();
@@ -19,7 +19,8 @@ var visageBase = new Class({
19
19
  gridBorderColour: '#ccc',
20
20
  shade: false,
21
21
  secureJSON: false,
22
- httpMethod: 'get'
22
+ httpMethod: 'get',
23
+ axis: "0 0 1 1"
23
24
  },
24
25
  initialize: function(element, host, plugin, options) {
25
26
  this.parentElement = element;
@@ -69,6 +70,8 @@ var visageBase = new Class({
69
70
  'class': 'graph-title',
70
71
  'html': header
71
72
  });
73
+ console.log(this);
74
+ console.log(this.parentElement);
72
75
  $(this.parentElement).grab(this.graphHeader);
73
76
  },
74
77
  buildGraphContainer: function() {
@@ -157,12 +160,13 @@ var visageGraph = new Class({
157
160
  var ys = this.ys // y axes
158
161
  var xstep = x.length / 20
159
162
  var shade = this.options.shade
163
+ var axis = this.options.axis
160
164
 
161
165
  this.canvas.g.txtattr.font = "11px 'sans-serif'";
162
166
  this.graph = this.canvas.g.linechart(left, top, width, height, x, ys, {
163
167
  nostroke: false,
164
168
  width: 1.5,
165
- axis: "0 0 1 1",
169
+ axis: axis,
166
170
  colors: colors,
167
171
  axisxstep: xstep,
168
172
  shade: shade
@@ -508,3 +512,49 @@ var visageGraph = new Class({
508
512
  }
509
513
  })
510
514
 
515
+ var visageSparkline = new Class({
516
+ Extends: visageGraph,
517
+ options: {
518
+ width: 450,
519
+ height: 80,
520
+ leftEdge: 1,
521
+ topEdge: 1,
522
+ gridWidth: 449,
523
+ gridHeight: 79,
524
+ columns: 60,
525
+ rows: 8,
526
+ gridBorderColour: '#ccc',
527
+ shade: false,
528
+ secureJSON: false,
529
+ httpMethod: 'get',
530
+ axis: "0 0 0 0"
531
+ },
532
+ graphData: function(data) {
533
+
534
+ this.ys = []
535
+ this.colors = []
536
+ this.instances = []
537
+ this.metrics = []
538
+
539
+ var host = this.options.host
540
+ var plugin = this.options.plugin
541
+
542
+ $each(data[host][plugin], function(instance, iname) {
543
+ $each(instance, function(metric, mname) {
544
+ this.colors.push(metric.color)
545
+ if ( !$defined(this.x) ) {
546
+ this.x = this.buildXAxis(metric)
547
+ }
548
+ this.ys.push(metric.data)
549
+ this.instances.push(iname) // labels
550
+ this.metrics.push(mname) // labels
551
+ }, this);
552
+ }, this);
553
+
554
+ console.log(this.metrics)
555
+ console.log(this.instances)
556
+ console.log(this.ys)
557
+
558
+ this.drawGraph();
559
+ }
560
+ });