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
56 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){for(var c=e,d=0;d<a.length;d++){if(!(a[d]in c))return b;c=c[a[d]]}return c}function h(a){return"url("+document.URL.split("#")[0]+"#"+a+")"}function i(){Lh.attr("transform",wh.main),Lh.select(".x.axis").attr("transform",wh.x),Lh.select(".y.axis").attr("transform",wh.y),Lh.select(".y2.axis").attr("transform",wh.y2),Lh.select(".chart-arcs").attr("transform",wh.arc)}function j(){Xf&&(Mh.attr("transform",wh.context),Mh.select(".x.axis").attr("transform",wh.subx))}function k(a){var b=a!==!1?250:0;$f&&Nh.transition().duration(b).attr("transform",wh.legend)}function l(a){i(a),j(a),k(a)}function m(){Ze=p(),$e=q(),_e=O(),af=N(),Se={top:cg?u("y2"):Dh,right:s(),bottom:u(cg?"y":"x")+(cg?0:Yf)+(xh?0:_e),left:(cg?Yf+Ch:0)+r()},Ve=Ze-Se.left-Se.right,Xe=$e-Se.top-Se.bottom,0>Ve&&(Ve=0),0>Xe&&(Xe=0),Te={top:cg?Se.top:$e-Yf-(xh?0:_e),right:0/0,bottom:20+(xh?0:_e),left:cg?Bh:Se.left},We=cg?Se.left-Bh-Ch:Ve,Ye=cg?Xe:$e-Te.top-Te.bottom,0>We&&(We=0),0>Ye&&(Ye=0),Ue={top:xh?0:$e-_e,right:0/0,bottom:0,left:xh?Ze-af:0},n(),xh&&td(Ce.data.targets)&&(Ue.left=Ve/2+cf)}function n(){cf=Xe/2,bf=.95*cf,df=sd(Ce.data.targets)?.6*bf:0}function o(){var a=cg?".x.axis":".y.axis",b=Be.select(a).node(),c=b?b.getBoundingClientRect():{right:0},d=Be.select(He).node().getBoundingClientRect(),e=c.right-d.left-r();return e>0?e:0}function p(){return Ie?Ie:v()}function q(){var a=Je?Je:w();return a>0?a:320}function r(){return td(Ce.data.targets)?0:Ke?Ke:cg||!ng||sg?1:t("y")}function s(){var a=1;return td(Ce.data.targets)?0:Le?Le:xh?af+(wg&&!cg?t("y2"):a):wg?Bg||cg?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||ng?"y2"!==a||wg?(db(a).isInner?30:40)+("y2"===a?-10:0):Dh:$f&&!xh?10:1}function v(){return+Be.select(He).style("width").replace("px","")}function w(){return+Be.select(He).style("height").replace("px","")}function x(a){return a?-5:-(Se.left-1)}function y(a){return a?-20:-1}function z(){return x(!cg)}function A(){return y(!cg)}function B(){return x(cg)}function C(){return y(cg)}function D(a){return a?Ve+2+4:Se.left+20}function E(a){return a?80:Xe+2}function F(){return D(!cg)}function G(){return E(!cg)}function H(){return D(cg)}function I(){return E(cg)}function J(){var a=cg?Xe:Ve,b=Rb(),c=mc();return c>1?a*b/(c-1):a}function K(a){yh=a}function L(a){zh=a}function M(a){Ah=a}function N(){return $f?xh?zh*(yh+1):Ze:0}function O(){return $f?xh?$e:Ah*(yh+1):0}function P(){var a,b,c=!rf;jf=cg?1:0,kf=cg?Xe:Ve,lf=cg?0:Xe,mf=cg?Ve:1,nf=jf,of=kf,pf=cg?0:Ye,qf=cg?We:1,rf=R(jf,kf,c?void 0:rf.domain(),function(){return xf.tickOffset()}),sf=S(lf,mf),tf=S(lf,mf),uf=R(jf,kf,Qh,function(a){return a%1?0:Af.tickOffset()}),vf=S(pf,qf),wf=S(pf,qf),a=Y(),b=Z(),xf=V(rf,sh,a,b),Af=V(uf,vh,a,b),yf=W(sf,th,tg,vg),zf=W(tf,uh,Cg,Eg),c||(Eh.scale(uf),Me&&Ih.scale(rf)),Q()}function Q(){ef=zb(),ff=Ab(),gf=Ab(.98)}function R(a,b,e,f){var g=(kh?Be.time.scale():Be.scale.linear()).range([a,b]);if(g.orgDomain=function(){return g.domain()},d(e)&&g.domain(e),c(f)&&(f=function(){return 0}),lh){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 Be.scale.linear().range([a,b])}function T(a){return"y2"===X(a)?tf:sf}function U(a){return"y2"===X(a)?wf:vf}function V(a,b,c,d){var e=(lh?xb():Be.svg.axis()).scale(a).orient(b);return e.tickFormat(c).ticks(d),lh?e.tickCentered(fg):e.tickOffset=function(){var a=cg?Xe:Ve;return a*Rb()/mc()/2},lh&&e.categories(eg),e}function W(a,b,c,d){return Be.svg.axis().scale(a).orient(b).tickFormat(c).ticks(d).outerTickSize(0)}function X(a){return a in Hf?Hf[a]:"y"}function Y(){var a=kh?rh:lh?vc:null;return gg&&("function"==typeof gg?a=gg:kh&&(a=function(a){return Be.time.format(gg)(a)})),a}function Z(){var a=mc();return hg&
for(var K=Vb(),L=K[0].getFullYear(),M=K[1].getFullYear(),N=L;M>=N;N++)e.push(new Date(N+"-01-01 00:00:00"))}else e=rf.ticks(10);c=Lh.select(".xgrids").selectAll(".xgrid").data(e),c.enter().append("line").attr("class","xgrid"),c.attr("x1",cg?0:function(a){return rf(a)-xf.tickOffset()}).attr("x2",cg?Ve:function(a){return rf(a)-xf.tickOffset()}).attr("y1",cg?function(a){return rf(a)-xf.tickOffset()}:Se.top).attr("y2",cg?function(a){return rf(a)-xf.tickOffset()}:Xe).style("opacity",function(){return+Be.select(this).attr(cg?"y1":"x1")===(cg?Xe:0)?0:1}),c.exit().remove()}Hg&&(f=Lh.select(".xgrid-lines").selectAll(".xgrid-line").data(Hg),g=f.enter().append("g").attr("class",function(a){return"xgrid-line xgrid-line-"+(a["class"]?a["class"]:"")}),g.append("line").style("opacity",0),g.append("text").attr("text-anchor","end").attr("transform",cg?"":"rotate(-90)").attr("dx",cg?0:-Se.top).attr("dy",-5).style("opacity",0),f.select("line").transition().duration(E).attr("x1",cg?0:Rc).attr("x2",cg?Ve:Rc).attr("y1",cg?Rc:Se.top).attr("y2",cg?Rc:Xe).style("opacity",1),f.select("text").transition().duration(E).attr("x",cg?Ve:0).attr("y",Rc).text(function(a){return a.text}).style("opacity",1),f.exit().transition().duration(E).style("opacity",0).remove()),t&&Ig&&(h=Lh.select(".ygrids").selectAll(".ygrid").data(sf.ticks(Kg)),h.enter().append("line").attr("class","ygrid"),h.attr("x1",cg?sf:0).attr("x2",cg?sf:Ve).attr("y1",cg?0:sf).attr("y2",cg?Xe:sf),h.exit().remove()),t&&Jg&&(i=Lh.select(".ygrid-lines").selectAll(".ygrid-line").data(Jg),j=i.enter().append("g").attr("class",function(a){return"ygrid-line ygrid-line-"+(a.class?a.class:"")}),j.append("line").style("opacity",0),j.append("text").attr("text-anchor","end").attr("transform",cg?"rotate(-90)":"").attr("dx",cg?0:-Se.top).attr("dy",-5).style("opacity",0),i.select("line").transition().duration(E).attr("x1",cg?Sc:0).attr("x2",cg?Sc:Ve).attr("y1",cg?0:Sc).attr("y2",cg?Xe:Sc).style("opacity",1),i.select("text").transition().duration(E).attr("x",cg?0:Ve).attr("y",Sc).text(function(a){return a.text}).style("opacity",1),i.exit().transition().duration(E).style("opacity",0).remove()),l=Lh.selectAll(".-bars").selectAll(".-bar").data(Bd),l.enter().append("path").attr("d",A).style("stroke","none").style("opacity",0).style("fill",function(a){return qh(a.id)}).attr("class",Hc),l.style("opacity",Kc).transition().duration(E).attr("d",A).style("opacity",1),l.exit().transition().duration(F).style("opacity",0).remove(),n=Lh.selectAll(".-texts").selectAll(".-text").data(Dd),n.enter().append("text").attr("class",xc).attr("text-anchor",function(a){return cg?a.value<0?"end":"start":"middle"}).style("stroke","none").style("fill-opacity",0).text(function(a){return Uc(a.value)}),n.style("fill-opacity",Lc).transition().duration(E).attr("x",C).attr("y",D).style("fill-opacity",Nc),n.exit().transition().duration(F).style("fill-opacity",0).remove(),Lh.selectAll(".-line").style("opacity",Kc).transition().duration(E).attr("d",Fh).style("opacity",1),Lh.selectAll(".-area").style("opacity",0).transition().duration(E).attr("d",Gh).style("opacity",Rh),k=Lh.selectAll(".-circles").selectAll(".-circle").data(Cd),k.enter().append("circle").attr("class",Gc).style("opacity",0).attr("r",Mg),k.style("opacity",Kc).transition().duration(E).style("opacity",Mc).attr("cx",cg?hd:gd).attr("cy",cg?gd:hd),k.exit().remove(),Lh.selectAll(".chart-arc").select(".-arc").attr("transform",w?"scale(0)":"").style("opacity",function(a){return a===this._current?0:1}).transition().duration(E).attrTween("d",function(a){var b=yb(a);if(!b)return function(){return"M 0 0"};var c=Be.interpolate(this._current,b);return this._current=c(0),function(a){return Bb(c(a),!0)}}).attr("transform",w?"scale(1)":"").style("opacity",1),Lh.selectAll(".chart-arc").select("text").attr("transform",Cb).style("opacity",0).transition().duration(E).text(Fb).style("opacity",function(a){return Ad(a.data)?1:0}),Lh.select(".chart-arcs-title").style("opacity",sd(Ce.data.targets)?1:0),Xf&&(null!==Be.event&&"zoom"===Be.event.type&&Eh.extent(rf.orgDomain()).update(),u&&(Mh.select(".x.axis"