/
charts.min.js
70 lines (70 loc) · 34.4 KB
/
charts.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
(function(){var global=window;if(global.module==undefined)global.module=function(r,D){var B=global[r];if(B==undefined)global[r]=B={};D(B)};
module("Charts",function(r){var D;D=function(){function g(b){var a,c,d,e;c={};e=g.DEFAULTS;for(a in e){d=e[a];c[a]=d}for(a in b){d=b[a];if(b.hasOwnProperty(a))c[a]=d}return c}g.DEFAULTS={dot_size:5,dot_color:"#00aadd",dot_stroke_color:"#fff",dot_stroke_size:2,line_width:3,line_color:"#00aadd",smoothing:0.4,fill_area:true,area_color:"#00aadd",area_opacity:0.2,show_x_labels:true,show_y_labels:true,label_max:true,label_min:true,max_x_labels:10,max_y_labels:3,font_family:"Helvetica, Arial, sans-serif",
x_label_size:14,y_label_size:14,label_format:"%m/%d",show_grid:false,x_padding:45,y_padding:40,multi_axis:false,scale:"linear",y_axis_scale:[],render:"line",bar_width:20};g.merge=function(b,a){var c,d,e;if(b==null)b={};if(a==null)a={};d={};for(c in b){e=b[c];d[c]=e}for(c in a){e=a[c];if(a.hasOwnProperty(c))d[c]=e}return d};return g}();(function(){function g(b,a,c,d,e){this.r=b;this.width=a;this.height=c;this.points=d;this.options=e}g.prototype.draw=function(){var b,a,c,d,e,f,h,i,j;b=Math.round(this.points.length/
this.options.step_size);a=this.height-this.options.y_padding;e=this.width-this.options.x_padding;h=Math.round(a/b);f=this.options.y_padding;d=this.r.set();j=this.points;c=i=0;for(j=j.length;i<j;c=++i)if(c%this.options.step_size===0){c=this.points[c].x;d.push(this.r.path("M "+c+", "+this.options.y_padding+" L "+c+", "+a+" Z"))}for(i=0;0<=b?i<=b:i>=b;0<=b?++i:--i){f<=a&&d.push(this.r.path("M "+this.options.x_padding+", "+f+" L "+e+", "+f+" Z"));f+=h}return d.attr({stroke:"#ccc","stroke-width":1}).toBack()};
return g})();var B;B=function(){function g(b,a,c,d){this.r=b;this.point=a;this.opts=c;this.scale_factor=d!=null?d:1.5;this.element=this.r.circle(a.x,a.y,this.opts.dot_size);this.style_dot();this.attach_handlers()}g.prototype.style_dot=function(){this.element.attr({fill:this.opts.dot_color,stroke:this.opts.dot_stroke_color,"stroke-width":this.opts.dot_stroke_size});return this.element.toFront()};g.prototype.activate=function(){this.element.attr({fill:"#333"});return this.element.animate({r:this.opts.dot_size*
this.scale_factor},200)};g.prototype.deactivate=function(){this.element.attr({fill:this.opts.dot_color});return this.element.animate({r:this.opts.dot_size},200)};g.prototype.attach_handlers=function(){var b=this;this.element.mouseover(function(){return b.activate()});return this.element.mouseout(function(){return b.deactivate()})};g.prototype.hide=function(){return this.element.hide()};return g}();var N;N=function(){function g(b){var a,c,d,e;c={};e=g.DEFAULTS;for(a in e){d=e[a];c[a]=d}for(a in b){d=
b[a];if(b.hasOwnProperty(a))c[a]=d}return c}g.DEFAULTS={line_width:4,line_color:"#000",area_color:"#00aadd",area_width:20,area_opacity:0.2,bar_margin:8,show_average:true,average_width:4,average_height:8,average_color:"#000",font_family:"Helvetica, Arial, sans-serif",x_label_size:14,y_label_size:14,x_padding:45,y_padding:40};g.merge=function(b,a){var c,d,e;if(b==null)b={};if(a==null)a={};d={};for(c in b){e=b[c];d[c]=e}for(c in a){e=a[c];if(a.hasOwnProperty(c))d[c]=e}return d};return g}();var z,E,F;
F=function(g,b){var a,c;if(b==null)b=2;c=b>0?Math.pow(10,b):1;if(g>1E6){a=g/1E6;a=Math.round(a*c)/c;return a+"m"}else if(g>1E3){a=g/1E3;return Math.round(a*c)/c+"k"}else return Math.round(g*c)/c};E=function(){function g(b,a){this.r=b;this.format=a!=null?a:"";this.num=0;this.font_family="Helvetica, Arial, sans-serif";this.color="#333"}g.prototype.x=function(b){this.x_func=b;return this};g.prototype.y=function(b){this.y_func=b;return this};g.prototype.size=function(b){this.size=b;return this};g.prototype.attr=
function(b){this.options=b;return this};g.prototype.draw=function(b){b=new z(this.r,this.x_func(this.num),this.y_func(this.num),b,this.format,this.size,this.font_family,this.color,this.options);this.num+=1;return b.draw()};return g}();z=function(){function g(b,a,c,d,e,f,h,i,j){this.r=b;this.x=a;this.y=c;this.text=d;this.format=e!=null?e:"";this.size=f!=null?f:14;this.font_family=h!=null?h:"Helvetica, Arial, sans-serif";this.color=i!=null?i:"#333";this.options=j!=null?j:void 0}g.prototype.is_date=
function(b){return Object.prototype.toString.call(b)==="[object Date]"};g.prototype.parse_date=function(){var b,a,c,d,e;a=this.format.match(/%([a-zA-Z])/g);b=this.format;d=0;for(e=a.length;d<e;d++){c=a[d];b=b.replace(c,this.parse_format(c))}return b};g.prototype.meridian_indicator=function(b){return b.getHours()>=12?"pm":"am"};g.prototype.to_12_hour_clock=function(b){b=b.getHours()%12;return b===0?12:b};g.prototype.fmt_minutes=function(b){b=b.getMinutes();return b<10?"0"+b:b};g.prototype.parse_format=
function(b){switch(b){case "%m":return this.text.getMonth()+1;case "%d":return this.text.getDate();case "%Y":return this.text.getFullYear();case "%H":return this.text.getHours();case "%M":return this.fmt_minutes(this.text);case "%I":return this.to_12_hour_clock(this.text);case "%p":return this.meridian_indicator(this.text)}};g.prototype.draw=function(){var b;this.element=this.r.text(this.x,this.y,this.is_date(this.text)?this.parse_date(this.text):typeof this.text==="number"?F(this.text):this.text);
b=this.element.getBBox().width;this.element.attr({fill:this.color,"font-size":this.size,"font-weight":"normal","text-anchor":"middle","font-family":this.font_family});if(this.options!=null)this.element.attr(this.options);else{b=this.x<b?b/2+5:this.x;this.element.attr({x:b})}return this.element};return g}();var v;v=function(){function g(b,a){var c,d,e;d={};for(c in a){e=a[c];d[c]=e}for(c in b){e=b[c];if(b.hasOwnProperty(c))d[c]=e}return d}g.merge=function(b,a){var c,d,e;if(b==null)b={};if(a==null)a=
{};d={};for(c in b){e=b[c];d[c]=e}for(c in a){e=a[c];if(a.hasOwnProperty(c))d[c]=e}return d};return g}();var O,t={}.hasOwnProperty,s=function(g,b){function a(){this.constructor=g}for(var c in b)if(t.call(b,c))g[c]=b[c];a.prototype=b.prototype;g.prototype=new a;g.__super__=b.prototype;return g};O=function(g){function b(a){return b.__super__.constructor.call(this,a,b.DEFAULTS)}s(b,g);b.DEFAULTS={bar_margin:30,bar_bg_color:"#bdced3",bar1_color:"90-#2f5e78-#4284a8",bar2_color:"90-#173e53-#225d7c",raw_value_bar_color:"#9eb7bf",
x_padding:160,x_padding_right:100,y_padding:50,bg_bar_padding:14,rounding:3,dash_width:3,label_size:14,font_family:"Helvetica, Arial, sans-serif"};return b}(v);var G;G=function(){function g(b){var a,c,d,e;c={};e=g.DEFAULTS;for(a in e){d=e[a];c[a]=d}for(a in b){d=b[a];if(b.hasOwnProperty(a))c[a]=d}return c}g.DEFAULTS={bar_width:20,bar_spacing:20,bar_color:"#00aadd",rounding:0,font_family:"Helvetica, Arial, sans-serif",show_x_labels:true,show_y_labels:true,x_label_size:14,x_label_color:"#333",y_label_size:14,
y_label_color:"#333",show_grid:false,x_padding:25,y_padding:40};g.merge=function(b,a){var c,d,e;if(b==null)b={};if(a==null)a={};d={};for(c in b){e=b[c];d[c]=e}for(c in a){e=a[c];if(a.hasOwnProperty(c))d[c]=e}return d};return g}();var H,A,x,P=function(g,b){return function(){return g.apply(b,arguments)}};A=function(){function g(){this.scale=P(this.scale,this)}g.prototype.domain=function(b){this.domain_min=Math.min.apply(Math.min,b);this.domain_max=Math.max.apply(Math.max,b);return this};g.prototype.range=
function(b){this.range_min=Math.min.apply(Math.min,b);this.range_max=Math.max.apply(Math.max,b);return this.scale};g.prototype.scale=function(b){var a;a=this.domain_max-this.domain_min;b=(this.domain_max*this.range_min-this.domain_min*this.range_max)/a+b*((this.range_max-this.range_min)/a);return a===0?this.range_min:b};return g}();H=function(){function g(b){this.base=b!=null?b:10;return this.scale=P(this.scale,this)}g.prototype.scale=function(b){var a;a=Math.log;return a(b)/a(this.base)};return g}();
x=function(){function g(){}g.get_ranges_for_points=function(b){var a,c,d,e,f;c=[];d=[];e=0;for(f=b.length;e<f;e++){a=b[e];c.push(a.x);d.push(a.y)}b=Math.max.apply(Math.max,c);a=Math.max.apply(Math.max,d);c=Math.min.apply(Math.min,c);d=Math.min.apply(Math.min,d);return[b,c,a,d]};g.threshold=function(b,a){return b>a?a:b};return g}();r.Scaling=x;r.Scaler=A;var m;m=function(){function g(b,a,c){this.y=a;this.options=c!=null?c:{};if(this.is_date(b)){this.x=b.getTime();this.is_date_type=true}else this.x=
b}g.prototype.is_date=function(b){return Object.prototype.toString.call(b)==="[object Date]"};return g}();r.Point=m;var I;Raphael.fn.triangle=function(g,b,a){a*=1.75;return this.path("M".concat(g,",",b,"m0-",a*0.58,"l",a*0.5,",",a*0.87,"-",a,",0z"))};I=function(){function g(b){this.r=b}g.prototype.black_nub=function(b,a,c,d,e){var f,h,i,j,k,l;if(a==null)a=10;if(c==null)c=8;if(e==null)e=0;f=b.getBBox();d=f.x;l=f.y;b=f.width;f=f.height;h=d+b/2;k=b+2*a;i=f+2*c;j=this.r.set();j.push(this.r.rect(h-k/2,
l-c,k,i,e));j.push(this.r.triangle(d+b+a+2,l+2+0.5*f,4).rotate(90));return j.attr({fill:"#333",stroke:"none"}).toBack()};g.prototype.straight_line=function(b,a){return this.r.path("M"+b.x+","+b.y+"L"+a.x+","+a.y)};g.prototype.vertical_dashed_line=function(b,a,c,d){var e,f,h;if(c==null)c=3;if(d==null)d=10;f=Math.floor((a.y-b.y)/d);a=this.r.set();e=h=0;for(f=f-1;0<=f?h<=f:h>=f;e=0<=f?++h:--h)if(e%2===0){e=this.r.rect(b.x-0.5*c,e*d+b.y,c,d);a.push(e)}return a};g.prototype.get_points_along_top_of_bbox=
function(b,a){var c,d,e;if(a==null)a=0;c=b.getBBox();d=c.x;e=c.x+c.width;c=c.y+a;return[new m(d,c),new m(e,c)]};g.prototype.one_px_highlight=function(b){b=this.get_points_along_top_of_bbox(b,2);this.straight_line(b[0],b[1]).attr({"stroke-width":1,stroke:"rgba(255,255,255,0.3)"});return this.straight_line};g.prototype.one_px_shadow=function(b){b=this.get_points_along_top_of_bbox(b);this.straight_line(b[0],b[1]).attr({"stroke-width":0.5,stroke:"rgba(0,0,0,0.5)"});return this.straight_line};return g}();
r.Effects=I;var C;C=function(){function g(b,a,c,d){var e,f,h=this;this.r=b;if(d==null)d=true;if(typeof c==="number")c=Math.round(c*100)/100;e=a.getBBox();f=e.x;b=e.y;e=f+e.width/2;this.text=this.r.text(e,b-22.5,c);this.text.attr({fill:"#fff","font-size":14,"text-anchor":"middle",opacity:0,"font-weight":"bold"});c=this.text.getBBox().width+20;this.popup=this.r.set();this.popup.push(this.r.rect(e-c/2,b-35,c,25,5));this.triangle=this.r.triangle(e,b-10+4,4).rotate(180);this.popup.push(this.triangle);
this.popup.attr({fill:"rgba(0,0,0,.4)",opacity:0,stroke:"none"});this.popup.toFront();this.text.toFront();if(d===true){a.mouseover(function(){return h.show()});a.mouseout(function(){return h.hide()})}}g.prototype.animate_opacity=function(b,a,c){var d=this;if(c==null)c=200;return b.animate({opacity:a,"fill-opacity":a},c,function(){if(a===0){d.text.toBack();return d.popup.toBack()}})};g.prototype.hide=function(){this.animate_opacity(this.popup,0);return this.animate_opacity(this.text,0)};g.prototype.show=
function(){this.popup.toFront();this.text.toFront();this.animate_opacity(this.popup,0.9);return this.animate_opacity(this.text,1)};g.prototype.translate=function(b,a){this.popup.translate(b,a);this.text.translate(b,a);return this.triangle.translate(-2*b,a)};return g}();r.Tooltip=C;var Q;Q=function(){function g(b,a,c,d,e,f){this.r=b;this.raw_points=a;this.scaled_points=c;this.height=d;this.width=e;this.options=f!=null?f:{};this.effective_height=this.height-this.options.y_padding;this.x_offset=this.options.bar_width/
2}g.prototype.draw=function(){return this.draw_bars()};g.prototype.draw_bars=function(){var b,a,c,d,e,f,h,i,j,k;e=this.r.set();f=[];c=a=0;k=this.scaled_points;b=i=0;for(j=k.length;i<j;b=++i){d=k[b];h=d.x-this.x_offset;d=this.r.rect(h,d.y,this.options.bar_width,this.effective_height-d.y);e.push(d);f.push(new C(this.r,d,this.raw_points[b].y));if(this.raw_points[b].y>=this.raw_points[a].y)a=b;if(this.raw_points[b].y<this.raw_points[c].y)c=b}e.attr({fill:this.options.line_color,stroke:"none"});this.options.label_max&&
f[a].show();if(this.options.label_min)return f[c].show()};return g}();var J;J=function(){function g(){}g.create_path=function(b,a){var c,d,e,f,h,i;if(a==null)a=0.5;f="M"+b[0].x+", "+b[0].y;e=h=0;for(i=b.length;h<i;e=++h)if(e!==0){d=g.get_control_points(b,e-1,a);c=d[0];d=d[1];f+="C"+c.x+","+c.y+" "+d.x+","+d.y+" "+b[e].x+","+b[e].y}return f};g.get_control_points=function(b,a,c,d){var e,f,h,i;if(d==null)d=3;f=this.get_prev_and_next_points(b,a);e=f[0];f=f[1];a=this.get_prev_and_next_points(b,a+1);b=
a[0];h=a[1];a=this.get_tangent(e,f);e=a[0];a=a[1];i=this.get_tangent(b,h);h=i[0];i=i[1];e=b.x+e*c/d;b=b.y+a*c/d;a=f.x-h*c/d;c=f.y-i*c/d;d=new m(e,b);c=new m(a,c);return[d,c]};g.get_prev_and_next_points=function(b,a){var c,d;d=a-1;c=a+1;if(d<0)d=0;if(c>=b.length)c=b.length-1;return[b[d],b[c]]};g.get_tangent=function(b,a){return[a.x-b.x,a.y-b.y]};return g}();r.Bezier=J;var R;R=function(){function g(b,a,c,d,e,f){this.r=b;this.raw_points=a;this.scaled_points=c;this.height=d;this.width=e;this.options=
f!=null?f:{}}g.prototype.draw=function(){var b;b=J.create_path(this.scaled_points,this.options.smoothing);this.options.fill_area&&this.draw_area(b);this.draw_curve(b);this.options.dot_size>0&&this.draw_dots_and_tooltips(this.scaled_points,this.raw_points)};g.prototype.draw_curve=function(b){return this.r.path(b).attr({stroke:this.options.line_color,"stroke-width":this.options.line_width}).toFront()};g.prototype.draw_area=function(b){var a,c,d;c=this.scaled_points;d=this.height-this.options.y_padding;
a=c[c.length-1];c=c[0];b+="L "+a.x+", "+d+" ";b+="L "+c.x+", "+d+" ";b+="Z";b=this.r.path(b);b.attr({fill:this.options.area_color,"fill-opacity":this.options.area_opacity,stroke:"none"});return b.toBack()};g.prototype.draw_dots_and_tooltips=function(){var b,a,c,d,e,f,h,i,j,k,l;i=this.scaled_points;h=this.raw_points;j=[];a=[];b=k=d=c=0;for(l=i.length;k<l;b=++k){e=i[b];f=h[b];if(f.y>=h[c].y)c=b;if(f.y<h[d].y)d=b;b=new B(this.r,e,this.options);e=new C(this.r,b.element,f.options.tooltip||f.y);a.push(b);
j.push(e);f.options.no_dot===true&&b.hide();if(f.options.show_dot===true){b.activate();e.show()}}if(this.options.label_max){j[c].show();a[c].activate()}if(this.options.label_min){j[d].show();return a[d].activate()}};return g}();var w,S;S=function(g){return g.tagName!==void 0?true:false};w=function(){function g(b,a){var c,d;c=S(b)?b:document.getElementById(b);d=this.get_dimensions(c);this.width=d[0];this.height=d[1];this.r=Raphael(c,this.width,this.height);this.options=a}g.prototype.get_dimensions=
function(b){var a;a=parseInt(b.style.width);b=parseInt(b.style.height);return[a,b]};g.prototype.clear=function(){return this.r.clear()};return g}();var T,U,V,K;t={}.hasOwnProperty;s=function(g,b){function a(){this.constructor=g}for(var c in b)if(t.call(b,c))g[c]=b[c];a.prototype=b.prototype;g.prototype=new a;g.__super__=b.prototype;return g};U=function(g){function b(a){return b.__super__.constructor.call(this,a,b.DEFAULTS)}s(b,g);b.DEFAULTS={main_circle_radius:70,child_radius_multiplier:0.15,hover_scale_multiplier:1.2,
inactive_opacity:0.4,outer_radius_multiplier:1.35,outer_radius2_multiplier:1.5,bounce_radius:1.2,fill_color:"#00a6dd"};return b}(v);K=function(g,b,a){return new m(b*Math.cos(a)+g.x,b*Math.sin(a)+g.y)};V=function(g,b,a,c,d){var e;e=function(f,h,i,j){if(j==null)j=void 0;return f.animate({x:h.x,y:h.y,cx:h.x,cy:h.y},i,"<",j)};return e(g,b,c,function(){return e(g,a,d)})};T=function(g){function b(a,c){if(c==null)c={};b.__super__.constructor.call(this,a,new U(c));this.center_point=new m(this.width/2,this.height/
2);this.main_radius=this.options.main_circle_radius;this.child_radius=this.main_radius*this.options.child_radius_multiplier;this.outer_radius=this.main_radius*this.options.outer_radius_multiplier;this.outer_radius2=this.outer_radius*this.options.outer_radius2_multiplier;this.bounce_radius=this.outer_radius*this.options.bounce_radius;this.children=[]}s(b,g);b.prototype.add_hover=function(a){var c,d,e=this;c=function(){a[0].animate({r:e.options.hover_scale_multiplier*e.child_radius,opacity:1,"stroke-width":2,
stroke:"rgba(0,0,0,.4)"},200);a[1].animate({"font-size":22,opacity:1,fill:"#fff"},200);return a._label.animate({opacity:1},200)};d=function(){a[0].animate({r:e.child_radius,opacity:e.options.inactive_opacity,stroke:"none","stroke-width":0},200);a[1].animate({opacity:0},200);return a._label.animate({opacity:0},200)};a._activate=c;a._deactivate=d;return a.hover(c,d)};b.prototype.add=function(a){return this.children.push(a)};b.prototype.create_circles_along_radius=function(a,c,d,e){var f,h,i,j,k,l,o,
n,p;j=2*Math.PI/24;p=[];h=o=0;for(n=a.length;o<n;h=++o){i=a[h];h=h*j;f=K(this.center_point,d,h);k=f.x;l=f.y;f=this.draw_circle(this.center_point.x,this.center_point.y,c,16);f._realx=k;f._realy=l;f._radians=h;f.attr({opacity:this.options.inactive_opacity}).toFront();f[1].attr({opacity:0});this.add_label_to_circle(i,f);this.add_hover(f);p.push(e(i,f))}return p};b.prototype.bounce_circles=function(a,c){var d,e,f,h,i,j,k;if(c){k=[];h=i=0;for(j=c.length;i<j;h=++i){f=c[h];e=f._radians;d=K(this.center_point,
this.bounce_radius,e);e=d.x;d=d.y;e=new m(e,d);if(a._active){d=c.length-h;h=this.center_point;f.toBack()}else{d=h;h=new m(f._realx,f._realy);f.toFront()}d=100+d*10;k.push(V(f,e,h,d,100))}return k}};b.prototype.add_click_to_circle=function(a,c){var d,e=this;if(c==null)c=false;d=function(){var f,h,i,j,k;if(a._active){a.hover(a._activate,a._deactivate);h=0;if(a._children){k=a._children;i=0;for(j=k.length;i<j;i++){f=k[i];if(f._active){f._deactivate();f._click_handler()}}}}else{a.unhover(a._activate,a._deactivate);
h=45}e.bounce_circles(a,a._children);a.animate({transform:"r"+h},200);return a._active=!a._active};a._click_handler=d;return a.click(d)};b.prototype.add_label_to_circle=function(a,c){var d,e,f;d=this.r.text(c._realx,c._realy,a.label).attr({"font-size":14});e=this.r.text(c._realx,c._realy+15,F(a.value)).attr({"font-size":12,fill:this.options.fill_color}).toBack();f=this.r.set();f.push(d);f.push(e);if(c._realx>this.center_point.x){d="start";e=30}else{d="end";e=-30}f.attr({"text-anchor":d,x:c._realx+
e,opacity:0});return c._label=f};b.prototype.add_grandchildren=function(a,c){if(a.children){c._children=[];return this.create_circles_along_radius(a.children,this.child_radius,this.outer_radius2,function(d,e){c._active=false;return c._children.push(e)})}};b.prototype.draw_circle=function(a,c,d,e){var f,h;f={fill:this.options.fill_color,stroke:"none"};h=this.r.set();h.push(this.r.circle(a,c,d).attr(f));h.push(this.r.text(a,c,"+").attr({"font-size":e,fill:"#fff"}));return h.attr({cursor:"pointer"}).toFront()};
b.prototype.draw=function(){var a,c=this;a=this.draw_circle(this.center_point.x,this.center_point.y,this.main_radius,100);a._active=false;a._children=[];this.add_click_to_circle(a,true);this.create_circles_along_radius(this.children,this.child_radius,this.outer_radius,function(d,e){c.add_grandchildren(d,e);c.add_click_to_circle(e);return a._children.push(e)});return a.toFront()};return b}(w);r.PathMenu=T;var W,X;t={}.hasOwnProperty;s=function(g,b){function a(){this.constructor=g}for(var c in b)if(t.call(b,
c))g[c]=b[c];a.prototype=b.prototype;g.prototype=new a;g.__super__=b.prototype;return g};X=function(g,b,a,c,d){var e,f,h;f=360/c*a;e=(90-f)*Math.PI/180;h=g+d*Math.cos(e);e=b-d*Math.sin(e);return{path:c===a?[["M",g,b-d],["A",d,d,0,1,1,g-0.01,b-d]]:[["M",g,b-d],["A",d,d,0,+(f>180),1,h,e]]}};W=function(g){function b(a){return b.__super__.constructor.call(this,a,b.DEFAULTS)}s(b,g);b.DEFAULTS={radius:55,stroke_width:30,font_color:"#333333",label_color:"#333333",fill_color:"#fff",stroke_color:"#81ae14",
background_color:"#222222",text_shadow:false};return b}(v);v=function(g){function b(a,c,d,e){this.label=c;this.value=d;if(e==null)e={};b.__super__.constructor.call(this,a,new W(e));this.center_point=new m(this.width/2,this.height/2);this.r.customAttributes.arc=X}s(b,g);b.prototype.draw=function(){var a;a=this.r.path().attr({"stroke-width":this.options.stroke_width,stroke:this.options.stroke_color,arc:[this.center_point.x,this.center_point.y,0,100,this.options.radius]});this.r.circle(this.center_point.x,
this.center_point.y,this.options.radius).attr({fill:this.options.fill_color,stroke:"none","stroke-width":0});this.r.text(this.center_point.x,this.center_point.y,Math.round(this.value*100/100)+"%").attr({"font-size":this.options.radius/2.5,fill:this.options.font_color,"font-weight":"bold"});this.r.text(this.center_point.x,this.center_point.y+1.8*this.options.radius,this.label).attr({"font-size":this.options.radius/2.5,"font-weight":"bold",fill:this.options.label_color});this.options.text_shadow&&this.r.text(this.center_point.x,
this.center_point.y+1.8*this.options.radius+1,this.label).attr({"font-size":this.options.radius/2.5,"font-weight":"bold",fill:this.options.text_shadow}).toBack();return a.animate({arc:[this.center_point.x,this.center_point.y,this.value,100,this.options.radius]},1500,"<")};return b}(w);r.CircleProgress=v;t={}.hasOwnProperty;s=function(g,b){function a(){this.constructor=g}for(var c in b)if(t.call(b,c))g[c]=b[c];a.prototype=b.prototype;g.prototype=new a;g.__super__=b.prototype;return g};v=function(g){function b(a,
c){if(c==null)c={};b.__super__.constructor.call(this,a,new D(c));this.padding=26;this.all_points=[];this.line_indices=[];this.line_options=[]}s(b,g);b.prototype.add_line=function(a){var c,d,e,f,h;c=a.data;if(!(c.length<1)){e=[];f=0;for(h=c.length;f<h;f++){d=c[f];d.length===3?e.push(new m(d[0],d[1],d[2])):e.push(new m(d[0],d[1]))}c=this.all_points.length;this.line_indices.push([c,c+e.length-1]);this.all_points.push.apply(this.all_points,e);this.line_options.push(D.merge(this.options,a.options))}};
b.prototype.draw_grid=function(a,c){var d,e,f,h,i,j,k;if(a==null)a=[];if(c==null)c=[];i=function(l,o,n){return l.attr({stroke:o,"stroke-width":n})};f=this.options.multi_axis?this.options.x_padding*2:this.options.x_padding;d=this.height-this.options.y_padding;h=this.width-f;f=this.r.set();j=0;for(k=a.length;j<k;j++){e=a[j];f.push(this.r.path("M "+e+", "+this.options.y_padding+" L "+e+", "+d+" Z"))}j=0;for(k=c.length;j<k;j++){e=c[j];f.push(this.r.path("M "+this.options.x_padding+", "+e+" L "+h+", "+
e+" Z"))}if(this.options.multi_axis===true&&this.line_options.length===2){e=this.options.x_padding;e=this.r.path("M "+e+", "+this.options.y_padding+" L "+e+", "+d+" Z");h=this.width-this.options.x_padding*2;d=this.r.path("M "+h+", "+this.options.y_padding+" L "+h+", "+d+" Z");i(e,this.line_options[0].line_color,2).toBack();i(d,this.line_options[1].line_color,2).toBack()}return i(f,"#ccc",1).toBack()};b.prototype.create_scalers=function(a){var c,d,e,f,h,i,j,k,l,o=this;f=void 0;e=void 0;h=void 0;f=
void 0;i=void 0;if(this.options.scale==="log"){d=new H;e=function(){var n,p,q;q=[];n=0;for(p=a.length;n<p;n++){j=a[n];q.push(new m(j.x,d(j.y)))}return q}();i=x.get_ranges_for_points(e);e=i[0];h=i[1];f=i[2];i=i[3]}else{i=x.get_ranges_for_points(a);e=i[0];h=i[1];f=i[2];i=i[3]}if(this.options.y_axis_scale.length===2){f=this.options.y_axis_scale;i=f[0];f=f[1]}k=this.options.multi_axis?this.options.x_padding*2:this.options.x_padding;e=(new A).domain([h,e]).range([this.options.x_padding,this.width-k]);
l=(new A).domain([i,f]).range([this.options.y_padding,this.height-this.options.y_padding]);c=function(n){return o.height-l(n)};f=this.options.scale==="log"?function(n){return c(d(n))}:c;return[e,f]};b.prototype.create_scalers_for_single_point=function(){var a=this;return[function(){return 0.5*(a.width-a.options.x_padding)},function(){return 0.5*(a.height-a.options.y_padding)}]};b.prototype._draw_y_labels=function(a,c){var d,e,f,h,i,j,k,l,o;if(c==null)c=0;d=this.options.label_format;j=this.options.y_label_size;
e=this.options.font_family;i=j+5;i=this.options.multi_axis&&c>0?c:c+i;if(a.length===1){h=this.create_scalers_for_single_point();k=h[1]}else{h=this.create_scalers(a);k=h[1]}h=[];f=l=0;for(o=a.length;l<o;f=++l){f=a[f];(new z(this.r,i,k(f.y),f.y,d,j,e)).draw();h.push(k(f.y))}return h};b.prototype.calc_y_label_step_size=function(a,c,d){if(d==null)d=this.options.max_y_labels;a=(c-a)/(d-1);if(c>1){a=Math.round(a);if(a===0)a=1}return a};b.prototype.draw_y_labels=function(a,c){var d,e,f,h,i,j;if(c==null)c=
0;f=x.get_ranges_for_points(a);h=f[2];e=f[3];if(this.options.y_axis_scale.length===2){h=this.options.y_axis_scale;e=h[0];h=h[1]}if(h===e)return this._draw_y_labels([new m(0,h)],c);f=[];if(this.options.scale==="log"){d=new H;j=d(e);d=d(h);d=(d-j)/(this.options.max_y_labels-1);e=e;for(i=0;e<=h&&i<this.options.max_y_labels;){e=Math.pow(10,j+d*i);f.push(new m(0,e));i+=1}}else{j=e;for(d=this.calc_y_label_step_size(e,h);j<=h;){f.push(new m(0,j));j+=d}}if(h>1)f[f.length-1].y=Math.round(h);return this._draw_y_labels(f,
c)};b.prototype.draw_x_label=function(a,c){var d,e,f;d=this.options.label_format;f=this.options.x_label_size;e=this.options.font_family;return(new z(this.r,c.x,this.height-f,a.is_date_type===true?new Date(a.x):Math.round(a.x),d,f,e)).draw()};b.prototype.draw_x_labels=function(a,c){var d,e,f,h,i,j;e=[];h=this.options.max_x_labels;this.draw_x_label(a[0],c[0]);e.push(c[0].x);if(!(h<2)){f=c.length-1;this.draw_x_label(a[f],c[f]);e.push(c[f].x);if(!(h<3)){f=c.length-2;h=f/(h-1);d=Math.round(h);if(h!==d)h=
d+1;for(d=h;d<f;){j=a[d];i=c[d];this.draw_x_label(j,i);e.push(i.x);d+=h}return e}}};b.prototype.draw_line=function(a,c,d){return this.options.render==="bar"?(new Q(this.r,a,c,this.height,this.width,d)).draw():(new R(this.r,a,c,this.height,this.width,d)).draw()};b.prototype.clear=function(){b.__super__.clear.call(this);this.all_points=[];this.line_indices=[];return this.line_options=[]};b.prototype.draw=function(){var a,c,d,e,f,h,i,j,k,l,o,n;if(!(this.all_points.length<1)){this.r.clear();d=this.all_points.length>
1?this.create_scalers(this.all_points):this.create_scalers_for_single_point();j=d[0];k=d[1];n=this.line_indices;d=l=0;for(o=n.length;l<o;d=++l){c=n[d];a=c[0];c=c[1];i=this.all_points.slice(a,c+1||9E9);if(this.options.multi_axis){a=this.all_points.length>2?this.create_scalers(i):this.create_scalers_for_single_point();e=a[0];f=a[1]}else{e=j;f=k}c=function(){var p,q,u;u=[];p=0;for(q=i.length;p<q;p++){h=i[p];u.push(new m(e(h.x),f(h.y)))}return u}();a=this.line_options[d];this.draw_line(i,c,a);if(d===
0){if(this.options.show_x_labels===true)this.x_label_coordinates=this.draw_x_labels(i,c);if(this.options.multi_axis&&this.options.show_y_labels===true)this.y_label_coordinates=this.draw_y_labels(i);else if(this.options.show_y_labels===true)this.y_label_coordinates=this.draw_y_labels(this.all_points);this.options.show_grid===true&&this.draw_grid(this.x_label_coordinates,this.y_label_coordinates)}else d===1&&this.options.multi_axis&&this.options.show_y_labels===true&&this.draw_y_labels(i,this.width-
this.options.x_padding)}}};return b}(w);r.LineChart=v;var Y,Z,$;t={}.hasOwnProperty;s=function(g,b){function a(){this.constructor=g}for(var c in b)if(t.call(b,c))g[c]=b[c];a.prototype=b.prototype;g.prototype=new a;g.__super__=b.prototype;return g};Z=function(g,b,a){return{label:g,raw_value:b,index_value:a}};$=function(g,b,a){return{label:g,index_value:b,opacity:a}};Y=function(g){function b(a,c){if(c==null)c={};b.__super__.constructor.call(this,a,new O(c));this.effects=new I(this.r);this.bars=[];this.guides=
[];this.index=100}s(b,g);b.prototype.add=function(a,c,d){return this.bars.push(Z(a,c,d))};b.prototype.add_guide_line=function(a,c,d){if(d==null)d=1;return this.guides.push($(a,c,d))};b.prototype.add_raw_label=function(a){var c,d=this;c=(new E(this.r)).x(function(){return d.width-10}).y(function(e){return e*15+15}).size(this.options.label_size).attr({fill:"#333","text-anchor":"end","font-weight":"bold"});c.draw(a);return c.draw("(raw value)").attr({"font-weight":"normal","font-size":10})};b.prototype.set_bar_height=
function(){return this.bar_height=(this.height-this.options.y_padding)/this.bars.length-this.options.bar_margin};b.prototype.set_threshold=function(){var a,c;c=function(){var d,e,f,h;f=this.guides;h=[];d=0;for(e=f.length;d<e;d++){a=f[d];h.push(a.index_value)}return h}.call(this);return this.threshold=Math.max.apply(Math.max,c)};b.prototype.format_tooltip=function(a){return a/100+"x"};b.prototype.draw_raw_bar=function(a,c){var d,e;d=Math.floor(7);e=this.options.x_padding_right-10;this.r.rect(this.width-
e,c-d,this.width-this.options.x_padding_right,this.bar_height+14,this.options.rounding).attr({fill:this.options.raw_value_bar_color,stroke:"none"});return this.effects.straight_line(new m(this.width-e,this.options.y_padding-10),new m(this.width-e,this.height)).attr({stroke:"rgba(0,0,0,0.25)","stroke-width":0.1})};b.prototype.draw_bg_bar=function(a,c,d){c(a);c=this.options.bg_bar_padding;a=Math.floor(c/2);return this.r.rect(this.options.x_padding-a,d-a,this.width,this.bar_height+c,this.options.rounding).attr({fill:this.options.bar_bg_color,
stroke:"none"}).toBack()};b.prototype.shade_bar=function(a,c){if(c==null)c=this.options.bar1_color;a.attr({fill:c,stroke:"none"});this.effects.one_px_shadow(a);return this.effects.one_px_highlight(a)};b.prototype.render_bar=function(a,c,d,e){if(e==null)e=this.options.bar1_color;a=this.r.rect(a,c,d,this.bar_height,this.options.rounding);this.shade_bar(a,e);return a};b.prototype.draw_bar=function(a,c,d){var e,f,h;h=c(x.threshold(a,this.threshold));if(a>this.index){e=c(this.index);c=this.render_bar(this.options.x_padding,
d,e-this.options.x_padding);d=this.render_bar(e,d,h-e,this.options.bar2_color);f=new C(this.r,d,this.format_tooltip(a));f.translate(d.getBBox().width/2,0);c.mouseover(function(){return f.show()});return c.mouseout(function(){return f.hide()})}else{d=this.render_bar(this.options.x_padding,d,h-this.options.x_padding);f=new C(this.r,d,this.format_tooltip(a));return f.translate(d.getBBox().width/2,0)}};b.prototype.draw_guide_line=function(a,c,d,e){var f,h;if(e==null)e=1;h=new m(d,this.options.y_padding);
f=new m(d,this.height);this.effects.vertical_dashed_line(h,f,this.options.dash_width).attr({fill:"rgba(0,0,0,"+e+")",stroke:"none"});e=(new E(this.r)).x(function(){return d}).y(function(i){return i*15+15}).size(this.options.label_size).attr({fill:"rgba(0,0,0,"+e+")"});e.draw(a).attr({"font-weight":"bold"});return e.draw(c).attr({"font-size":10})};b.prototype.sort_bars_by_index=function(){var a,c;c=function(){var d,e,f,h;f=this.bars;h=[];d=0;for(e=f.length;d<e;d++){a=f[d];h.push(a)}return h}.call(this);
c.sort(function(d,e){return e.index_value-d.index_value});return c};b.prototype.clear=function(){b.__super__.clear.call(this);this.bars=[];return this.guides=[]};b.prototype.draw=function(){var a,c,d,e,f,h,i,j,k,l,o,n,p,q=this;this.set_bar_height();this.set_threshold();h=this.bar_height+this.options.bar_margin;d=this.bar_height/2;l=this.options.y_padding;j=this.options.x_padding;c=(new E(this.r)).y(function(u){return u*h+l+d}).x(function(){return j-30}).size(12).attr({fill:"#fff","text-anchor":"end"});
f=(new E(this.r)).y(function(u){return u*h+l+d}).x(function(){return q.width-10}).size(this.options.label_size).attr({fill:"#333","text-anchor":"end"});i=(new A).domain([0,this.threshold]).range([this.options.x_padding,this.width-this.options.x_padding_right]);k=function(u){return u*(q.bar_height+q.options.bar_margin)+q.options.y_padding};p=this.sort_bars_by_index();e=o=0;for(n=p.length;o<n;e=++o){a=p[e];this.draw_bg_bar(a.index_value,i,k(e));this.draw_raw_bar(a.raw_value,k(e));this.draw_bar(a.index_value,
i,k(e));f.draw(a.raw_value);a=c.draw(a.label);this.effects.black_nub(a)}o=this.guides;n=[];f=0;for(k=o.length;f<k;f++){c=o[f];n.push(this.draw_guide_line(c.label,c.index_value,i(c.index_value),c.opacity))}return n};return b}(w);r.IndexChart=function(g,b){return new Y(g,b)};var y;t={}.hasOwnProperty;s=function(g,b){function a(){this.constructor=g}for(var c in b)if(t.call(b,c))g[c]=b[c];a.prototype=b.prototype;g.prototype=new a;g.__super__=b.prototype;return g};y=function(g,b,a,c){return{label:g,value:b,
average:a,comparison:c}};v=function(g){function b(a,c){if(c==null)c={};b.__super__.constructor.call(this,a,new N(c));this.bars=[]}s(b,g);b.prototype.add=function(){return this.bars.push(y.apply(y,arguments))};b.prototype.draw_background=function(a,c){return this.r.rect(this.options.x_padding,c,a.x,this.options.area_width).attr({fill:this.options.area_color,stroke:"none"})};b.prototype.draw_line=function(a,c){return this.r.rect(this.options.x_padding,c.y-this.options.line_width/2,a.x,this.options.line_width).attr({fill:this.options.line_color,
stroke:"none"})};b.prototype.draw_average=function(a,c){return this.r.rect(a.x-this.options.average_width/2,c-this.options.average_height/2,this.options.average_width,this.options.average_height).attr({fill:this.options.average_color,stroke:"none"})};b.prototype.draw_label=function(){};b.prototype.clear=function(){b.__super__.clear.call(this);return this.bars=[]};b.prototype.draw=function(){var a,c,d,e,f,h,i,j,k,l;k=this.bars;l=[];a=i=0;for(j=k.length;i<j;a=++i){y=k[a];e=[new m(y.comparison,0),new m(y.value,
0),new m(y.average,0),new m(0,0)];d=x.get_ranges_for_points(e);c=d[0];d=d[1];h=(new A).domain([d,c]).range([this.options.x_padding,this.width-this.options.x_padding]);c=function(){var o,n,p;p=[];o=0;for(n=e.length;o<n;o++){f=e[o];p.push(new m(h(f.x),0))}return p}();d=a*(this.options.area_width+this.options.bar_margin);this.draw_background(c[0],d);a=d+this.options.area_width/2;this.draw_line(c[1],new m(c[0].x,a));this.draw_average(c[2],a);l.push((new z(this.r,0,d+this.options.area_width/2,y.label,
"",this.size=14,this.options.font_family)).draw())}return l};return b}(w);r.BulletChart=v;t={}.hasOwnProperty;s=function(g,b){function a(){this.constructor=g}for(var c in b)if(t.call(b,c))g[c]=b[c];a.prototype=b.prototype;g.prototype=new a;g.__super__=b.prototype;return g};w=function(g){function b(a,c){if(c==null)c={};b.__super__.constructor.call(this,a,new G(c));this.effective_height=this.height-this.options.y_padding;this.bar_options=[];this.bars=[];this.values=[]}s(b,g);b.prototype.add=function(a){var c,
d;c=a.label;d=a.value;this.bar_options.push(G.merge(this.options,a.options));this.values.push(d);return this.bars.push({label:c,value:d})};b.prototype.render_bar=function(a,c,d,e){this.r.rect(d.x,d.y,this.options.bar_width,this.effective_height-d.y,this.options.rounding).attr({fill:e.bar_color,stroke:"none"});(new z(this.r,d.x+this.options.bar_width/2,this.height-(this.options.x_label_size+5),a,"",this.options.x_label_size,this.options.font_family,this.options.x_label_color)).draw();return(new z(this.r,
d.x+this.options.bar_width/2,d.y-this.options.y_label_size-5,c,"",this.options.y_label_size,this.options.font_family,this.options.y_label_color)).draw()};b.prototype.clear=function(){b.__super__.clear.call(this);this.bars=[];return this.values=[]};b.prototype.draw=function(){var a,c,d,e,f,h,i,j,k,l,o,n,p=this;e=function(){var q,u,L,M;L=this.values;M=[];c=q=0;for(u=L.length;q<u;c=++q){i=L[c];M.push(new m(c,i))}return M}.call(this);e.push(new m(0,0));d=x.get_ranges_for_points(e);a=d[2];d=d[3];j=(new A).domain([d,
a]).range([this.options.y_padding,this.height-this.options.y_padding]);d=function(q){return p.height-j(q)};o=this.bars;n=[];c=k=0;for(l=o.length;k<l;c=++k){a=o[c];f=c*(this.options.bar_width+this.options.bar_spacing)+this.options.x_padding;h=d(e[c].y);f=new m(f,h);n.push(this.render_bar(a.label,a.value,f,this.bar_options[c]))}return n};return b}(w);r.BarChart=w});})();