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

11 years ago
!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(){Mh.attr("transform",xh.main),Mh.select("."+He.axisX).attr("transform",xh.x),Mh.select("."+He.axisY).attr("transform",xh.y),Mh.select("."+He.axisY2).attr("transform",xh.y2),Mh.select("."+He.chartArcs).attr("transform",xh.arc)}function j(){Yf&&(Nh.attr("transform",xh.context),Nh.select("."+He.axisX).attr("transform",xh.subx))}function k(a){var b=a!==!1?250:0;_f&&Oh.transition().duration(b).attr("transform",xh.legend)}function l(a){i(a),j(a),k(a)}function m(){$e=p(),_e=q(),af=O(),bf=N(),Te={top:dg?u("y2"):Eh,right:s(),bottom:u(dg?"y":"x")+(dg?0:Zf)+(yh?0:af),left:(dg?Zf+Dh:0)+r()},We=$e-Te.left-Te.right,Ye=_e-Te.top-Te.bottom,0>We&&(We=0),0>Ye&&(Ye=0),Ue={top:dg?Te.top:_e-Zf-(yh?0:af),right:0/0,bottom:20+(yh?0:af),left:dg?Ch:Te.left},Xe=dg?Te.left-Ch-Dh:We,Ze=dg?Ye:_e-Ue.top-Ue.bottom,0>Xe&&(Xe=0),0>Ze&&(Ze=0),Ve={top:yh?0:_e-af,right:0/0,bottom:0,left:yh?$e-bf:0},n(),yh&&vd(Ce.data.targets)&&(Ve.left=We/2+df)}function n(){df=Ye/2,cf=.95*df,ef=ud(Ce.data.targets)?.6*cf:0}function o(){var a=dg?He.axisX:He.axisY,b=Be.select("."+a).node(),c=b?b.getBoundingClientRect():{right:0},d=Be.select(Ie).node().getBoundingClientRect(),e=c.right-d.left-r();return e>0?e:0}function p(){return Je?Je:v()}function q(){var a=Ke?Ke:w();return a>0?a:320}function r(){return vd(Ce.data.targets)?0:Le?Le:dg||!og||tg?1:t("y")}function s(){var a=1;return vd(Ce.data.targets)?0:Me?Me:yh?bf+(xg&&!dg?t("y2"):a):xg?Cg||dg?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||og?"y2"!==a||xg?(db(a).isInner?30:40)+("y2"===a?-10:0):Eh:_f&&!yh?10:1}function v(){return+Be.select(Ie).style("width").replace("px","")}function w(){return+Be.select(Ie).style("height").replace("px","")}function x(a){return a?-5:-(Te.left-1)}function y(a){return a?-20:-1}function z(){return x(!dg)}function A(){return y(!dg)}function B(){return x(dg)}function C(){return y(dg)}function D(a){return a?We+2+4:Te.left+20}function E(a){return a?80:Ye+2}function F(){return D(!dg)}function G(){return E(!dg)}function H(){return D(dg)}function I(){return E(dg)}function J(){var a=dg?Ye:We,b=mc(),c=Rb()*(rd(Ce.data.targets)?(b-(mh?.25:1))/b:.98);return b>1?a*c/(b-1):a}function K(a){zh=a}function L(a){Ah=a}function M(a){Bh=a}function N(){return _f?yh?Ah*(zh+1):$e:0}function O(){return _f?yh?_e:Bh*(zh+1):0}function P(){var a,b,c=!sf;kf=dg?1:0,lf=dg?Ye:We,mf=dg?0:Ye,nf=dg?We:1,of=kf,pf=lf,qf=dg?0:Ze,rf=dg?Xe:1,sf=R(kf,lf,c?void 0:sf.domain(),function(){return yf.tickOffset()}),tf=S(mf,nf),uf=S(mf,nf),vf=R(kf,lf,Rh,function(a){return a%1?0:Bf.tickOffset()}),wf=S(qf,rf),xf=S(qf,rf),a=Y(),b=Z(),yf=V(sf,th,a,b),Bf=V(vf,wh,a,b),zf=W(tf,uh,ug,wg),Af=W(uf,vh,Dg,Fg),c||(Fh.scale(vf),Ne&&Jh.scale(sf)),Q()}function Q(){ff=zb(),gf=Ab(),hf=Ab(.98)}function R(a,b,e,f){var g=(lh?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}),mh){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)?uf:tf}function U(a){return"y2"===X(a)?xf:wf}function V(a,b,c,d){var e=(mh?xb():Be.svg.axis()).scale(a).orient(b);return e.tickFormat(c).ticks(d),mh?e.tickCentered(gg):e.tickOffset=function(){var a=dg?Ye:We;return a*Rb()/mc()/2},mh&&e.categories(fg),e}function W(a,b,c,d){return Be.svg.axis().scale(a).orient(b).tickFormat(c).ticks(d).outerTickSize(0)}function X(a){re
}function le(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=kd(),I=vd(Ce.data.targets);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?Se:0,F=d(a.durationForExit)?a.durationForExit:E,G=d(a.durationForAxis)?a.durationForAxis:E,z&&_f&&xe(Ce.data.targets,a),y&&(sf.domain(Be.extent(Vb(Ce.data.targets))),Rh=sf.domain(),Ne&&Jh.scale(sf).updateScaleExtent(),vf.domain(sf.domain()),Fh.scale(vf)),x&&(sf.domain(Fh.empty()?Rh:Fh.extent()),Ne&&Jh.scale(sf).updateScaleExtent()),tf.domain(Qb("y")),uf.domain(Qb("y2")),Mh.select("."+He.axisX).style("opacity",I?0:1).transition().duration(G).call(yf),Mh.select("."+He.axisY).style("opacity",I?0:1).transition().duration(G).call(zf),Mh.select("."+He.axisY2).style("opacity",I?0:1).transition().duration(G).call(Af),A=$d(H),C=_d(H,!0),D=_d(H,!1),Mh.select("."+He.axisX+" ."+He.axisXLabel).attr("x",kb),Mh.select("."+He.axisY+" ."+He.axisYLabel).attr("x",lb).attr("dy",rb),Mh.select("."+He.axisY2+" ."+He.axisY2Label).attr("x",mb).attr("dy",sb),wf.domain(tf.domain()),xf.domain(uf.domain()),Ph.style("display","none"),Mh.select("line."+He.xgridFocus).style("visibility","hidden").attr("y2",Ye),Gg){if("year"===Hg){e=[];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=sf.ticks(10);c=Mh.select("."+He.xgrids).selectAll("."+He.xgrid).data(e),c.enter().append("line").attr("class",He.xgrid),c.attr("x1",dg?0:function(a){return sf(a)-yf.tickOffset()}).attr("x2",dg?We:function(a){return sf(a)-yf.tickOffset()}).attr("y1",dg?function(a){return sf(a)-yf.tickOffset()}:Te.top).attr("y2",dg?function(a){return sf(a)-yf.tickOffset()}:Ye).style("opacity",function(){return+Be.select(this).attr(dg?"y1":"x1")===(dg?Ye:0)?0:1}),c.exit().remove()}Ig&&(f=Mh.select("."+He.xgridLines).selectAll("."+He.xgridLine).data(Ig),g=f.enter().append("g").attr("class",function(a){return He.xgridLine+(a.class?a.class:"")}),g.append("line").style("opacity",0),g.append("text").attr("text-anchor","end").attr("transform",dg?"":"rotate(-90)").attr("dx",dg?0:-Te.top).attr("dy",-5).style("opacity",0),f.select("line").transition().duration(E).attr("x1",dg?0:Tc).attr("x2",dg?We:Tc).attr("y1",dg?Tc:Te.top).attr("y2",dg?Tc:Ye).style("opacity",1),f.select("text").transition().duration(E).attr("x",dg?We:0).attr("y",Tc).text(function(a){return a.text}).style("opacity",1),f.exit().transition().duration(E).style("opacity",0).remove()),t&&Jg&&(h=Mh.select("."+He.ygrids).selectAll("."+He.ygrid).data(tf.ticks(Lg)),h.enter().append("line").attr("class",He.ygrid),h.attr("x1",dg?tf:0).attr("x2",dg?tf:We).attr("y1",dg?0:tf).attr("y2",dg?Ye:tf),h.exit().remove()),t&&Kg&&(i=Mh.select("."+He.ygridLines).selectAll("."+He.ygridLine).data(Kg),j=i.enter().append("g").attr("class",function(a){return He.ygridLine+(a.class?a.class:"")}),j.append("line").style("opacity",0),j.append("text").attr("text-anchor","end").attr("transform",dg?"rotate(-90)":"").attr("dx",dg?0:-Te.top).attr("dy",-5).style("opacity",0),i.select("line").transition().duration(E).attr("x1",dg?Uc:0).attr("x2",dg?Uc:We).attr("y1",dg?0:Uc).attr("y2",dg?Ye:Uc).style("opacity",1),i.select("text").transition().duration(E).attr("x",dg?0:We).attr("y",Uc).text(function(a){return a.text}).style("opacity",1),i.exit().transition().duration(E).style("opacity",0).remove()),l=Mh.selectAll("."+He.bars).selectAll("."+He.bar).data(Dd),l.enter().append("path").attr("d",A).style("stroke","none").style("opacity",0).style("fill",function(a){return rh(a.id)}).attr("class",Ec),l.style("opacity",Mc).transition().duration(E).attr("d",A).style("opacity",1),l.exit().transition().duration(F).style("opacity",0).remove(),n=Mh.selectAll("."+He.texts).selectAll("."+He.text).data(Fd),n.enter().append("text").attr("class",xc).attr("text-anchor",function(a){return dg?a.value<0?"end":"start":"middle"}).style