Quite good looking graph derived from d3.js http://c3js.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
59 KiB

!function(a){"use strict";function b(a){return a||0===a}function c(a){return"undefined"==typeof a}function d(a){return"undefined"!=typeof a}var e={};e.generate=function(e){function f(a,b){if(!(a in e))throw Error(b)}function g(a,b){var c,d,f,g=e;for(c=0;c<a.length;c++){if("object"==typeof g&&!(a[c]in g))return b;if(d=c===a.length-1,f=g[a[c]],!d&&"object"!=typeof f||d&&"object"!=typeof b&&"object"==typeof f)return b;g=f}return g}function h(a){return"url("+document.URL.split("#")[0]+"#"+a+")"}function i(){Xh.attr("transform",Ih.main),Xh.select("."+Me.axisX).attr("transform",Ih.x),Xh.select("."+Me.axisY).attr("transform",Ih.y),Xh.select("."+Me.axisY2).attr("transform",Ih.y2),Xh.select("."+Me.chartArcs).attr("transform",Ih.arc)}function j(){dg&&(Yh.attr("transform",Ih.context),Yh.select("."+Me.axisX).attr("transform",Ih.subx))}function k(a){var b=a!==!1?250:0;gg&&Zh.transition().duration(b).attr("transform",Ih.legend)}function l(a){i(a),j(a),k(a)}function m(){df=p(),ef=q(),ff=O(),gf=N(),Ye={top:kg?u("y2"):Ph,right:s(),bottom:u(kg?"y":"x")+(kg?0:eg)+(Jh?0:ff),left:(kg?eg+Oh:0)+r()},_e=df-Ye.left-Ye.right,bf=ef-Ye.top-Ye.bottom,0>_e&&(_e=0),0>bf&&(bf=0),Ze={top:kg?Ye.top:ef-eg-(Jh?0:ff),right:0/0,bottom:20+(Jh?0:ff),left:kg?Nh:Ye.left},af=kg?Ye.left-Nh-Oh:_e,cf=kg?bf:ef-Ze.top-Ze.bottom,0>af&&(af=0),0>cf&&(cf=0),$e={top:Jh?0:ef-ff,right:0/0,bottom:0,left:Jh?df-gf:0},n(),Jh&&zd(He.data.targets)&&($e.left=_e/2+jf)}function n(){jf=bf/2,hf=.95*jf,kf=yd(He.data.targets)?.6*hf:0}function o(){var a=kg?Me.axisX:Me.axisY,b=Ge.select("."+a).node(),c=b?b.getBoundingClientRect():{right:0},d=Ge.select(Ne).node().getBoundingClientRect(),e=c.right-d.left-r();return e>0?e:0}function p(){return Oe?Oe:v()}function q(){var a=Pe?Pe:w();return a>0?a:320}function r(){return zd(He.data.targets)?0:Qe?Qe:kg||!vg||Ag?1:t("y")}function s(){var a=1;return zd(He.data.targets)?0:Re?Re:Jh?gf+(Eg&&!kg?t("y2"):a):Eg?Jg||kg?a:t("y2"):a}function t(a){var b=db(a);return b.isInner?20+wb(a):40+wb(a)}function u(a){return"y"!==a||vg?"y2"!==a||Eg?(db(a).isInner?30:40)+("y2"===a?-10:0):Ph:gg&&!Jh?10:1}function v(){return+Ge.select(Ne).style("width").replace("px","")}function w(){return+Ge.select(Ne).style("height").replace("px","")}function x(a){return a?-5:-(Ye.left-1)}function y(a){return a?-20:-1}function z(){return x(!kg)}function A(){return y(!kg)}function B(){return x(kg)}function C(){return y(kg)}function D(a){return a?_e+2+4:Ye.left+20}function E(a){return a?80:bf+2}function F(){return D(!kg)}function G(){return E(!kg)}function H(){return D(kg)}function I(){return E(kg)}function J(){var a=kg?bf:_e,b=mc(),c=Rb()*(vd(He.data.targets)?(b-(vh?.25:1))/b:.98);return b>1?a*c/(b-1):a}function K(a){Kh=a}function L(a){Lh=a}function M(a){Mh=a}function N(){return gg?Jh?Lh*(Kh+1):df:0}function O(){return gg?Jh?ef:Mh*(Kh+1):0}function P(){var a,b,c=!xf;pf=kg?1:0,qf=kg?bf:_e,rf=kg?0:bf,sf=kg?_e:1,tf=pf,uf=qf,vf=kg?0:cf,wf=kg?af:1,xf=R(pf,qf,c?void 0:xf.domain(),function(){return Df.tickOffset()}),yf=S(rf,sf),zf=S(rf,sf),Af=R(pf,qf,ai,function(a){return a%1?0:Gf.tickOffset()}),Bf=S(vf,wf),Cf=S(vf,wf),a=Y(),b=Z(),Df=V(xf,Eh,a,b),Gf=V(Af,Hh,a,b),Ef=W(yf,Fh,Bg,Dg),Ff=W(zf,Gh,Kg,Mg),c||(Qh.scale(Af),Se&&Uh.scale(xf)),Q()}function Q(){lf=zb(),mf=Ab(),nf=Ab(.98)}function R(a,b,e,f){var g=(uh?Ge.time.scale():Ge.scale.linear()).range([a,b]);if(g.orgDomain=function(){return g.domain()},d(e)&&g.domain(e),c(f)&&(f=function(){return 0}),vh){var h,i=g;g=function(a){return i(a)+f(a)};for(h in i)g[h]=i[h];g.orgDomain=function(){return i.domain()},g.domain=function(a){return arguments.length?(i.domain(a),g):(a=i.domain(),[a[0],a[1]+1])}}return g}function S(a,b){return Ge.scale.linear().range([a,b])}function T(a){return"y2"===X(a)?zf:yf}function U(a){return"y2"===X(a)?Cf:Bf}function V(a,b,c,d){var e=(vh?xb():Ge.svg.axis()).scale(a).orient(b);return e.tickFormat(c).ticks(d),vh?e.tickCentered(ng):e.tickOffset=function(){var a=kg?bf:_e;return a*Rb()/mc()/2},vh&&e.categories(mg),e}function W(a,b,c,d){return Ge.svg.axis().scale(a).orient(b).tickFormat(c).ticks(d).outerTickSize(0)}function X(a){re
"circle"===this.nodeName?(c=1*m.attr("cx"),d=1*m.attr("cy"),k=Ud,p=c>f&&g>c&&d>h&&i>d):"path"===this.nodeName&&(l=ed(this),c=l.x,d=l.y,e=l.width,j=l.height,k=Xd,p=!(c>g||f>c+e||d>i||h>d+j)),p^o&&(m.classed(Le,!o),m.classed(Ke,!n),k(!n,m,a,b))}))}function oe(a){zd(He.data.targets)||Uf&&(xh=a,Xh.select("."+Me.chart).append("rect").attr("class",Me.dragarea).style("opacity",.1),yh=!0,bg())}function pe(){zd(He.data.targets)||Uf&&(Xh.select("."+Me.dragarea).transition().duration(100).style("opacity",0).remove(),Xh.selectAll("."+Me.shape).classed(Le,!1),yh=!1,cg())}function qe(a){var c,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H=od(),I=zd(He.data.targets),K=sc(He.data.targets);if(0!==K.length){if(a=d(a)?a:{},t=d(a.withY)?a.withY:!0,u=d(a.withSubchart)?a.withSubchart:!0,v=d(a.withTransition)?a.withTransition:!0,w=d(a.withTransform)?a.withTransform:!1,x=d(a.withUpdateXDomain)?a.withUpdateXDomain:!1,y=d(a.withUpdateOrgXDomain)?a.withUpdateOrgXDomain:!1,z=d(a.withLegend)?a.withLegend:!1,E=v?Xe:0,F=d(a.durationForExit)?a.durationForExit:E,G=d(a.durationForAxis)?a.durationForAxis:E,z&&gg&&Ce(He.data.targets,a),y&&(xf.domain(Ge.extent(Vb(K))),ai=xf.domain(),Se&&Uh.scale(xf).updateScaleExtent(),Af.domain(xf.domain()),Qh.scale(Af)),x&&(xf.domain(Qh.empty()?ai:Qh.extent()),Se&&Uh.scale(xf).updateScaleExtent()),yf.domain(Qb(K,"y")),zf.domain(Qb(K,"y2")),Xh.select("."+Me.axisX).style("opacity",I?0:1).transition().duration(G).call(Df),Xh.select("."+Me.axisY).style("opacity",I?0:1).transition().duration(G).call(Ef),Xh.select("."+Me.axisY2).style("opacity",I?0:1).transition().duration(G).call(Ff),A=de(H),C=ee(H,!0),D=ee(H,!1),Xh.select("."+Me.axisX+" ."+Me.axisXLabel).attr("x",kb),Xh.select("."+Me.axisY+" ."+Me.axisYLabel).attr("x",lb).attr("dy",rb),Xh.select("."+Me.axisY2+" ."+Me.axisY2Label).attr("x",mb).attr("dy",sb),Bf.domain(yf.domain()),Cf.domain(zf.domain()),$h.style("display","none"),Xh.select("line."+Me.xgridFocus).style("visibility","hidden"),Ng){if("year"===Og){e=[];for(var L=Vb(),M=L[0].getFullYear(),N=L[1].getFullYear(),O=M;N>=O;O++)e.push(new Date(O+"-01-01 00:00:00"))}else e=xf.ticks(10);c=Xh.select("."+Me.xgrids).selectAll("."+Me.xgrid).data(e),c.enter().append("line").attr("class",Me.xgrid),c.attr("x1",kg?0:function(a){return xf(a)-Df.tickOffset()}).attr("x2",kg?_e:function(a){return xf(a)-Df.tickOffset()}).attr("y1",kg?function(a){return xf(a)-Df.tickOffset()}:Ye.top).attr("y2",kg?function(a){return xf(a)-Df.tickOffset()}:bf).style("opacity",function(){return+Ge.select(this).attr(kg?"y1":"x1")===(kg?bf:0)?0:1}),c.exit().remove()}Pd(Pg)&&(f=Xh.select("."+Me.xgridLines).selectAll("."+Me.xgridLine).data(Pg),g=f.enter().append("g").attr("class",function(a){return Me.xgridLine+(a.class?a.class:"")}),g.append("line").style("opacity",0),g.append("text").attr("text-anchor","end").attr("transform",kg?"":"rotate(-90)").attr("dx",kg?0:-Ye.top).attr("dy",-5).style("opacity",0),f.select("line").transition().duration(E).attr("x1",kg?0:Xc).attr("x2",kg?_e:Xc).attr("y1",kg?Xc:Ye.top).attr("y2",kg?Xc:bf).style("opacity",1),f.select("text").transition().duration(E).attr("x",kg?_e:0).attr("y",Xc).text(function(a){return a.text}).style("opacity",1),f.exit().transition().duration(E).style("opacity",0).remove()),t&&Qg&&(h=Xh.select("."+Me.ygrids).selectAll("."+Me.ygrid).data(yf.ticks(Sg)),h.enter().append("line").attr("class",Me.ygrid),h.attr("x1",kg?yf:0).attr("x2",kg?yf:_e).attr("y1",kg?0:yf).attr("y2",kg?bf:yf),h.exit().remove()),t&&Pd(Rg)&&(i=Xh.select("."+Me.ygridLines).selectAll("."+Me.ygridLine).data(Rg),j=i.enter().append("g").attr("class",function(a){return Me.ygridLine+(a.class?a.class:"")}),j.append("line").style("opacity",0),j.append("text").attr("text-anchor","end").attr("transform",kg?"rotate(-90)":"").attr("dx",kg?0:-Ye.top).attr("dy",-5).style("opacity",0),i.select("line").transition().duration(E).attr("x1",kg?Yc:0).attr("x2",kg?Yc:_e).attr("y1",kg?0:Yc).attr("y2",kg?bf:Yc).style("opacity",1),i.select("text").transition().duration(E).attr("x",kg?0:_e).attr("y",Yc).text(function(a){return a.text}).style("opacity",1