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
55 KiB

!function(a){"use strict";function b(){function a(a,b){a.attr("transform",function(a){return"translate("+(b(a)+q)+", 0)"})}function b(a,b){a.attr("transform",function(a){return"translate(0,"+b(a)+")"})}function c(a){var b=a[0],c=a[a.length-1];return c>b?[b,c]:[c,b]}function d(a){for(var b=[],c=Math.ceil(a[0]);c<a[1];c++)b.push(c);return b.length>0&&b[0]>0&&b.unshift(b[0]-(b[1]-b[0])),b}function e(a,b){var c=a.length-1;return p>=c||b%Math.ceil(c/p)===0}function f(a){return a<t.length?t[a]:a}function h(a){var b=f(a);return r?r(b):b}function i(f){f.each(function(){var f,i,p=g.select(this),r=d(j.domain()),s=p.selectAll(".tick.major").data(r,String),t=s.enter().insert("g","path").attr("class","tick major").style("opacity",1e-6),u=g.transition(s.exit()).style("opacity",1e-6).remove(),v=g.transition(s).style("opacity",1),w=j.rangeExtent?j.rangeExtent():c(j.range()),x=p.selectAll(".domain").data([0]);x.enter().append("path").attr("class","domain");var y=g.transition(x),z=j.copy(),A=this.__chart__||z;this.__chart__=z,t.append("line"),t.append("text");var B=t.select("line"),C=v.select("line"),D=s.select("text"),E=t.select("text"),F=v.select("text");switch(q=(z(1)-z(0))/2,i=o?0:q,k){case"bottom":f=a,B.attr("y2",l),E.attr("y",Math.max(l,0)+n),C.attr("x1",i).attr("x2",i).attr("y2",l),F.attr("x",0).attr("y",Math.max(l,0)+n),D.attr("dy",".71em").style("text-anchor","middle"),D.text(function(a){return e(r,a)?h(a):""}),y.attr("d","M"+w[0]+","+m+"V0H"+w[1]+"V"+m);break;case"left":f=b,B.attr("x2",-l),E.attr("x",-(Math.max(l,0)+n)),C.attr("x2",-l).attr("y2",0),F.attr("x",-(Math.max(l,0)+n)).attr("y",q),D.attr("dy",".32em").style("text-anchor","end"),D.text(function(a){return e(r,a)?h(a):""}),y.attr("d","M"+-m+","+w[0]+"H0V"+w[1]+"H"+-m)}if(j.ticks)t.call(f,A),v.call(f,z),u.call(f,z);else{var G=z.rangeBand()/2,H=function(a){return z(a)+G};t.call(f,H),v.call(f,H)}})}var j=g.scale.linear(),k="bottom",l=6,m=6,n=3,o=!1,p=10,q=0,r=null,s=!0,t=[];return i.scale=function(a){return arguments.length?(j=a,i):j},i.orient=function(a){return arguments.length?(k=a in{top:1,right:1,bottom:1,left:1}?a+"":"bottom",i):k},i.categories=function(a){return arguments.length?(t=a,i):t},i.tickCentered=function(a){return arguments.length?(o=a,i):o},i.tickFormat=function(a){return arguments.length?(r=a,i):r},i.tickOffset=function(){return q},i.ticks=function(a){return arguments.length?(p=a,i):p},i.tickCulling=function(a){return arguments.length?(s=a,i):s},i}function c(a){return a||0===a}function d(a){return"undefined"==typeof a}function e(a){return"undefined"!=typeof a}var f=a.c3={},g=a.d3;f.generate=function(f){function h(a,b){if(!(a in f))throw Error(b)}function i(a,b){for(var c=f,d=0;d<a.length;d++){if(!(a[d]in c))return b;c=c[a[d]]}return c}function j(a){return"url("+document.URL.split("#")[0]+"#"+a+")"}function k(){Ch.attr("transform",oh.main),Ch.select(".x.axis").attr("transform",oh.x),Ch.select(".y.axis").attr("transform",oh.y),Ch.select(".y2.axis").attr("transform",oh.y2),Ch.select(".chart-arcs").attr("transform",oh.arc)}function l(){Pf&&(Dh.attr("transform",oh.context),Dh.select(".x.axis").attr("transform",oh.subx))}function m(a){var b=a!==!1?250:0;Sf&&Eh.transition().duration(b).attr("transform",oh.legend)}function n(a){k(a),l(a),m(a)}function o(){We=r(),Xe=s(),Ye=Q(),Ze=P(),Pe={top:Wf&&lg?w("y2"):5,right:u(),bottom:w(Wf?"y":"x")+(Wf?0:Qf)+(ph?0:Ye),left:(Wf?Qf+uh:0)+t()},Se=We-Pe.left-Pe.right,Ue=Xe-Pe.top-Pe.bottom,Qe={top:Wf?Pe.top:Xe-Qf-(ph?0:Ye),right:0/0,bottom:20+(ph?0:Ye),left:Wf?th:Pe.left},Te=Wf?Pe.left-th-uh:Se,Ve=Wf?Ue:Xe-Qe.top-Qe.bottom,Re={top:ph?0:Xe-Ye,right:0/0,bottom:0,left:ph?We-Ze:0},p(),ph&&sd(ze.data.targets)&&(Re.left=Se/2+_e)}function p(){_e=Ue/2,$e=.95*_e,af=rd(ze.data.targets)?.6*$e:0}function q(){var a=Wf?".x.axis":".y.axis",b=g.select(a).node().getBoundingClientRect(),c=g.select(Ee).node().getBoundingClientRect();return b.right-c.left-t()}function r(){return Fe?Fe:x()}function s(){var a=Ge?Ge:y();return a>0?a:320}function t(){return sd(ze.data.targets)?0:He?He:Wf||hg?1:v("y")}function u(){var a=1;return sd(ze.data.targets)?0:Ie?
for(var K=Wb(),M=K[0].getFullYear(),N=K[1].getFullYear(),O=M;N>=O;O++)d.push(new Date(O+"-01-01 00:00:00"))}else d=of.ticks(10);b=Ch.select(".xgrids").selectAll(".xgrid").data(d),b.enter().append("line").attr("class","xgrid"),b.attr("x1",Wf?0:function(a){return of(a)-uf.tickOffset()}).attr("x2",Wf?Se:function(a){return of(a)-uf.tickOffset()}).attr("y1",Wf?function(a){return of(a)-uf.tickOffset()}:Pe.top).attr("y2",Wf?function(a){return of(a)-uf.tickOffset()}:Ue).style("opacity",function(){return+g.select(this).attr(Wf?"y1":"x1")===(Wf?Ue:0)?0:1}),b.exit().remove()}wg&&(f=Ch.select(".xgrid-lines").selectAll(".xgrid-line").data(wg),h=f.enter().append("g").attr("class",function(a){return"xgrid-line xgrid-line-"+(a["class"]?a["class"]:"")}),h.append("line").style("opacity",0),h.append("text").attr("text-anchor","end").attr("transform",Wf?"":"rotate(-90)").attr("dx",Wf?0:-Pe.top).attr("dy",-5).style("opacity",0),f.select("line").transition().duration(F).attr("x1",Wf?0:Rc).attr("x2",Wf?Se:Rc).attr("y1",Wf?Rc:Pe.top).attr("y2",Wf?Rc:Ue).style("opacity",1),f.select("text").transition().duration(F).attr("x",Wf?Se:0).attr("y",Rc).text(function(a){return a.text}).style("opacity",1),f.exit().transition().duration(F).style("opacity",0).remove()),u&&xg&&(i=Ch.select(".ygrids").selectAll(".ygrid").data(pf.ticks(zg)),i.enter().append("line").attr("class","ygrid"),i.attr("x1",Wf?pf:0).attr("x2",Wf?pf:Se).attr("y1",Wf?0:pf).attr("y2",Wf?Ue:pf),i.exit().remove()),u&&yg&&(j=Ch.select(".ygrid-lines").selectAll(".ygrid-line").data(yg),k=j.enter().append("g").attr("class",function(a){return"ygrid-line ygrid-line-"+(a.class?a.class:"")}),k.append("line").style("opacity",0),k.append("text").attr("text-anchor","end").attr("transform",Wf?"rotate(-90)":"").attr("dx",Wf?0:-Pe.top).attr("dy",-5).style("opacity",0),j.select("line").transition().duration(F).attr("x1",Wf?Sc:0).attr("x2",Wf?Sc:Se).attr("y1",Wf?0:Sc).attr("y2",Wf?Ue:Sc).style("opacity",1),j.select("text").transition().duration(F).attr("x",Wf?0:Se).attr("y",Sc).text(function(a){return a.text}).style("opacity",1),j.exit().transition().duration(F).style("opacity",0).remove()),m=Ch.selectAll(".-bars").selectAll(".-bar").data(Ad),m.enter().append("path").attr("d",B).style("stroke","none").style("opacity",0).style("fill",function(a){return ih(a.id)}).attr("class",Hc),m.style("opacity",Kc).transition().duration(F).attr("d",B).style("opacity",1),m.exit().transition().duration(G).style("opacity",0).remove(),o=Ch.selectAll(".-texts").selectAll(".-text").data(Cd),o.enter().append("text").attr("class",xc).attr("text-anchor",function(a){return Wf?a.value<0?"end":"start":"middle"}).style("stroke","none").style("fill-opacity",0).text(function(a){return Uc(a.value)}),o.style("fill-opacity",Lc).transition().duration(F).attr("x",D).attr("y",E).style("fill-opacity",Nc),o.exit().transition().duration(G).style("fill-opacity",0).remove(),Ch.selectAll(".-line").style("opacity",Kc).transition().duration(F).attr("d",wh).style("opacity",1),Ch.selectAll(".-area").style("opacity",0).transition().duration(F).attr("d",xh).style("opacity",Ih),l=Ch.selectAll(".-circles").selectAll(".-circle").data(Bd),l.enter().append("circle").attr("class",Gc).style("opacity",0).attr("r",Bg),l.style("opacity",Kc).transition().duration(F).style("opacity",Mc).attr("cx",Wf?gd:fd).attr("cy",Wf?fd:gd),l.exit().remove(),Ch.selectAll(".chart-arc").select(".-arc").attr("transform",x?"scale(0)":"").style("opacity",function(a){return a===this._current?0:1}).transition().duration(F).attrTween("d",function(a){var b=zb(a);if(!b)return function(){return"M 0 0"};var c=g.interpolate(this._current,b);return this._current=c(0),function(a){return Cb(c(a),!0)}}).attr("transform",x?"scale(1)":"").style("opacity",1),Ch.selectAll(".chart-arc").select("text").attr("transform",Db).style("opacity",0).transition().duration(F).text(Gb).style("opacity",function(a){return zd(a.data)?1:0}),Ch.select(".chart-arcs-title").style("opacity",rd(ze.data.targets)?1:0),Pf&&(null!==g.event&&"zoom"===g.event.type&&vh.extent(of.orgDomain()).update(),v&&(Dh.select(".x.axis").st