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.

3 lines
80 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}function e(a,b){function c(a,b){a.attr("transform",function(a){return"translate("+Math.ceil(b(a)+s)+", 0)"})}function d(a,b){a.attr("transform",function(a){return"translate(0,"+Math.ceil(b(a))+")"})}function e(a){var b=a[0],c=a[a.length-1];return c>b?[b,c]:[c,b]}function f(a){var b,c,d=[];if(a.ticks)return a.ticks.apply(a,k);for(c=a.domain(),b=Math.ceil(c[0]);b<c[1];b++)d.push(b);return d.length>0&&d[0]>0&&d.unshift(d[0]-(d[1]-d[0])),d}function g(){var a,c=m.copy();return b&&(a=m.domain(),c.domain([a[0],a[1]-1])),c}function h(a){return j?j(a):a}function i(i){i.each(function(){function i(a){var b=m(a)+s;return B[0]<b&&b<B[1]?o:0}var j,k,t=a.select(this),u=this.__chart__||m,v=this.__chart__=g(),w=r?r:f(v),x=t.selectAll(".tick").data(w,v),y=x.enter().insert("g",".domain").attr("class","tick").style("opacity",1e-6),z=a.transition(x.exit()).style("opacity",1e-6).remove(),A=a.transition(x).style("opacity",1),B=m.rangeExtent?m.rangeExtent():e(m.range()),C=t.selectAll(".domain").data([0]),D=(C.enter().append("path").attr("class","domain"),a.transition(C));y.append("line"),y.append("text");var E=y.select("line"),F=A.select("line"),G=x.select("text").text(h),H=y.select("text"),I=A.select("text");switch(b?(s=Math.ceil((v(1)-v(0))/2),k=l?0:s):s=k=0,n){case"bottom":j=c,E.attr("y2",o),H.attr("y",Math.max(o,0)+q),F.attr("x1",k).attr("x2",k).attr("y2",i),I.attr("x",0).attr("y",Math.max(o,0)+q),G.attr("dy",".71em").style("text-anchor","middle"),D.attr("d","M"+B[0]+","+p+"V0H"+B[1]+"V"+p);break;case"top":j=c,E.attr("y2",-o),H.attr("y",-(Math.max(o,0)+q)),F.attr("x2",0).attr("y2",-o),I.attr("x",0).attr("y",-(Math.max(o,0)+q)),G.attr("dy","0em").style("text-anchor","middle"),D.attr("d","M"+B[0]+","+-p+"V0H"+B[1]+"V"+-p);break;case"left":j=d,E.attr("x2",-o),H.attr("x",-(Math.max(o,0)+q)),F.attr("x2",-o).attr("y2",0),I.attr("x",-(Math.max(o,0)+q)).attr("y",s),G.attr("dy",".32em").style("text-anchor","end"),D.attr("d","M"+-p+","+B[0]+"H0V"+B[1]+"H"+-p);break;case"right":j=d,E.attr("x2",o),H.attr("x",Math.max(o,0)+q),F.attr("x2",o).attr("y2",0),I.attr("x",Math.max(o,0)+q).attr("y",0),G.attr("dy",".32em").style("text-anchor","start"),D.attr("d","M"+p+","+B[0]+"H0V"+B[1]+"H"+p)}if(v.rangeBand){var J=v,K=J.rangeBand()/2;u=v=function(a){return J(a)+K}}else u.rangeBand?u=v:z.call(j,v);y.call(j,u),A.call(j,v)})}var j,k,l,m=a.scale.linear(),n="bottom",o=6,p=6,q=3,r=null,s=0,t=!0;return i.scale=function(a){return arguments.length?(m=a,i):m},i.orient=function(a){return arguments.length?(n=a in{top:1,right:1,bottom:1,left:1}?a+"":"bottom",i):n},i.tickFormat=function(a){return arguments.length?(j=a,i):j},i.tickCentered=function(a){return arguments.length?(l=a,i):l},i.tickOffset=function(){return s},i.ticks=function(){return arguments.length?(k=arguments,i):k},i.tickCulling=function(a){return arguments.length?(t=a,i):t},i.tickValues=function(a){return arguments.length?(r=a,i):r},i}var f={version:"0.2.1"},g={target:"c3-target",chart:"c3-chart",chartLine:"c3-chart-line",chartLines:"c3-chart-lines",chartBar:"c3-chart-bar",chartBars:"c3-chart-bars",chartText:"c3-chart-text",chartTexts:"c3-chart-texts",chartArc:"c3-chart-arc",chartArcs:"c3-chart-arcs",chartArcsTitle:"c3-chart-arcs-title",chartArcsBackground:"c3-chart-arcs-background",chartArcsGaugeUnit:"c3-chart-arcs-gauge-unit",chartArcsGaugeMax:"c3-chart-arcs-gauge-max",chartArcsGaugeMin:"c3-chart-arcs-gauge-min",selectedCircle:"c3-selected-circle",selectedCircles:"c3-selected-circles",eventRect:"c3-event-rect",eventRects:"c3-event-rects",eventRectsSingle:"c3-event-rects-single",eventRectsMultiple:"c3-event-rects-multiple",zoomRect:"c3-zoom-rect",brush:"c3-brush",focused:"c3-focused",region:"c3-region",regions:"c3-regions",tooltip:"c3-tooltip",tooltipName:"c3-tooltip-name",shape:"c3-shape",shapes:"c3-shapes",line:"c3-line",lines:"c3-lines",bar:"c3-bar",bars:"c3-bars",circle:"c3-circle",circles:"c3-circles",arc:"c3-arc",arcs:"c3-arcs",area:"c3-area",areas:"c3-areas",empty
}function Ye(a,b){var c=0;a.each(function(){++c}).each("end",function(){--c||b.apply(this,arguments)})}function Ze(){var a=[],b=function(b,c){var d=setInterval(function(){var b=0;a.forEach(function(a){if(a.empty())return void(b+=1);try{a.transition()}catch(c){b+=1}}),b===a.length&&(clearInterval(d),c&&c())},10)};return b.add=function(b){a.push(b)},b}function $e(a,b,c){return d(a[b])?a[b]:c}function _e(a){return 10*Math.ceil(a/10)}function af(a,b){var c;return lg.select("body").selectAll(".dummy").data([a]).enter().append("text").classed(b?b:"",!0).text(a).each(function(){c=this.getBoundingClientRect()}).remove(),c}function bf(a){return Ae(a)?"cardinal":ze(a)?"step-after":"linear"}function cf(){return lg.selectAll([])}function df(a,b,c){Kh(b,a.node()),ok.select("."+g.selectedCircles+Bd(b.id)).selectAll("."+g.selectedCircle+"-"+c).data([b]).enter().append("circle").attr("class",function(){return fd(g.selectedCircle,c)}).attr("cx",Zh?ne:me).attr("cy",Zh?me:ne).attr("stroke",function(){return Sj(b)}).attr("r",1.4*pf(b)).transition().duration(100).attr("r",pf)}function ef(a,b,c){Lh(b,a.node()),ok.select("."+g.selectedCircles+Bd(b.id)).selectAll("."+g.selectedCircle+"-"+c).transition().duration(100).attr("r",0).remove()}function ff(a,b,c,d){a?df(b,c,d):ef(b,c,d)}function gf(a,b){Kh(b,a.node()),a.transition().duration(100).style("fill",function(){return lg.rgb(Sj(b)).brighter(.75)})}function hf(a,b){Lh(b,a.node()),a.transition().duration(100).style("fill",function(){return Sj(b)})}function jf(a,b,c,d){a?gf(b,c,d):hf(b,c,d)}function kf(a,b,c,d){jf(a,b,c.data,d)}function lf(a){return"circle"===a.nodeName?ff:lg.select(a).classed(g.bar)?jf:kf}function mf(a){return a.filter(function(a){return b(a.value)})}function nf(a){return Oi&&!ze(a)?"function"==typeof Pi?Pi(a):Pi:0}function of(a){return Ri?Si?Si:1.75*nf(a):nf(a)}function pf(a){return Ti?Ti:4*nf(a)}function qf(a,c){return(c?ok.selectAll("."+g.circles+Bd(c)):ok).selectAll("."+g.circle+(b(a)?"-"+a:""))}function rf(a,b){qf(a,b).classed(g.EXPANDED,!0).attr("r",of)}function sf(a){qf(a).filter(function(){return lg.select(this).classed(g.EXPANDED)}).classed(g.EXPANDED,!1).attr("r",nf)}function tf(a){return ok.selectAll("."+g.bar+(b(a)?"-"+a:""))}function uf(a){tf(a).classed(g.EXPANDED,!0)}function vf(a){tf(a).classed(g.EXPANDED,!1)}function wf(a,b){var c=lg.svg.area(),d=Cf(a,b),e=b?ab:_,f=function(a,b){return sh.length>0?d(a,b)[0][1]:e(a.id)(0)},g=function(a,b){return sh.length>0?d(a,b)[1][1]:e(a.id)(a.value)};return c=Zh?c.x0(f).x1(g).y(Sd):c.x(Sd).y0(f).y1(g),function(a){var b,d=mf(a.values),e=0,f=0;return Be(a)?b=c.interpolate(bf(a))(d):(d[0]&&(e=ch(d[0].x),f=_(a.id)(d[0].value)),b=Zh?"M "+f+" "+e:"M "+e+" "+f),b?b:"M 0 0"}}function xf(a,b){var c=lg.svg.line(),d=Ef(a,b),e=b?ab:_,f=b?Vd:Sd,g=function(a,b){return sh.length>0?d(a,b)[0][1]:e(a.id)(a.value)};return c=Zh?c.x(g).y(f):c.x(f).y(g),Ui||(c=c.defined(function(a){return null!=a.value})),function(a){var d,f=Ui?mf(a.values):a.values,g=b?g:fh,h=e(a.id),i=0,j=0;return ye(a)?d=yh[a.id]?Ff(f,g,h,yh[a.id]):c.interpolate(bf(a))(f):(f[0]&&(i=g(f[0].x),j=h(f[0].value)),d=Zh?"M "+j+" "+i:"M "+i+" "+j),d?d:"M 0 0"}}function yf(a,b){var c=Df(a,b);return function(a,b){var d=c(a,b),e=Zh?1:0,f=Zh?0:1,g="M "+d[0][e]+","+d[0][f]+" L"+d[1][e]+","+d[1][f]+" L"+d[2][e]+","+d[2][f]+" L"+d[3][e]+","+d[3][f]+" z";return g}}function zf(a,b){var c=Df(a,!1),d=b?Af:Bf;return function(a,b){return d(c(a,b),a,this)}}function Af(a,b,c){var d,e,f=c.getBoundingClientRect();return Zh?(e=Ce(b)?4:6,d=a[2][1]+e*(b.value<0?-1:1)):d=a[0][0]+(a[2][0]-a[0][0])/2,d>Hg?Hg-f.width:d}function Bf(a,b,c){var d,e=c.getBoundingClientRect();return d=Zh?(a[0][0]+a[2][0]+.6*e.height)/2:a[2][1]+(b.value<0?e.height:Ce(b)?-3:-6),d<e.height?e.height:d}function Cf(a,b){var c=a.__max__+1,d=je(0,c,a,!!b),e=ke(!!b),f=le(Be,a,!!b),g=b?ab:_;return function(a,b){var c=g(a.id)(0),h=f(a,b)||c,i=d(a),j=e(a);return Zh&&(0<a.value&&c>j||a.value<0&&j>c)&&(j=c),[[i,h],[i,j-(c-h)]]}}function Df(a,b){var c=a.__max__+1,d=oe(ih,c),e=je(d,c,a,!!b),f=ke(!!b),g=le(Ce,a,!!b),h=b?ab:_;return function(a,b){
}function eg(a,b,c){function e(b,c,d){function e(a,b){b||(f=(m-z-l)/2,y>f&&(f=(m-l)/2,z=0,F++)),E[a]=F,D[F]=f,A[a]=z,z+=l}var f,h,i=af(b.textContent,g.legendItem),j=10*Math.ceil((i.width+v)/10),k=10*Math.ceil((i.height+u)/10),l=ck?k:j,m=ck?V():U();return d&&(z=0,F=0,w=0,x=0),Th&&!Uc(c)?void(B[c]=C[c]=E[c]=A[c]=0):(B[c]=j,C[c]=k,(!w||j>=w)&&(w=j),(!x||k>=x)&&(x=k),h=ck?x:w,void(Yh?(Object.keys(B).forEach(function(a){B[a]=w}),Object.keys(C).forEach(function(a){C[a]=x}),f=(m-h*a.length)/2,y>f?(z=0,F=0,a.forEach(function(a){e(a)})):e(c,!0)):e(c)))}var f,h,i,j,k,l,m,n,q,r,s,t,u=4,v=36,w=0,x=0,y=10,z=0,A={},B={},C={},D=[0],E={},F=0,G=qk.selectAll("."+g.legendItemFocused).size();b=b||{},n=$e(b,"withTransition",!0),q=$e(b,"withTransitionForTransform",!0),ck?(f=function(a){return w*E[a]},j=function(a){return D[E[a]]+A[a]}):(f=function(a){return D[E[a]]+A[a]},j=function(a){return x*E[a]}),h=function(a,b){return f(a,b)+14},k=function(a,b){return j(a,b)+9},i=function(a,b){return f(a,b)-4},l=function(a,b){return j(a,b)-7},m=qk.selectAll("."+g.legendItem).data(a).enter().append("g").attr("class",function(a){return fd(g.legendItem,a)}).style("visibility",function(a){return Uc(a)?"visible":"hidden"}).style("cursor","pointer").on("click",function(a){"function"==typeof Vh?Vh(a):mg.toggle(a)}).on("mouseover",function(a){lg.select(this).classed(g.legendItemFocused,!0),Qj||mg.focus(a),"function"==typeof Wh&&Wh(a)}).on("mouseout",function(a){lg.select(this).classed(g.legendItemFocused,!1),Qj||mg.revert(),"function"==typeof Xh&&Xh(a)}),m.append("text").text(function(a){return d(qh[a])?qh[a]:a}).each(function(a,b){e(this,a,0===b)}).style("pointer-events","none").attr("x",ck?h:-200).attr("y",ck?-200:k),m.append("rect").attr("class",g.legendItemEvent).style("fill-opacity",0).attr("x",ck?i:-200).attr("y",ck?-200:l),m.append("rect").attr("class",g.legendItemTile).style("pointer-events","none").style("fill",Sj).attr("x",ck?h:-200).attr("y",ck?-200:j).attr("width",10).attr("height",10),r=qk.selectAll("text").data(a).text(function(a){return d(qh[a])?qh[a]:a}).each(function(a,b){e(this,a,0===b)}),(n?r.transition():r).attr("x",h).attr("y",k),s=qk.selectAll("rect."+g.legendItemEvent).data(a),(n?s.transition():s).attr("width",function(a){return B[a]}).attr("height",function(a){return C[a]}).attr("x",i).attr("y",l),t=qk.selectAll("rect."+g.legendItemTile).data(a),(n?t.transition():t).style("fill",Sj).attr("x",f).attr("y",j),qk.selectAll("."+g.legendItem).classed(g.legendItemHidden,function(a){return!Tc(a)}).transition().style("opacity",function(a){var b=lg.select(this);return Tc(a)?!G||b.classed(g.legendItemFocused)?$f(b):_f(b):gk}),S(w),T(x),R(F),p(),W(),Tf(),o(q,c)}function fg(a){return Sc(mg.data.targets,a.id)}function gg(a){return"data"in a&&Sc(mg.data.targets,a.data.id)}function hg(a){return a?function(b){var c=!1;return[].concat(a).forEach(function(d){("value"in d&&b.value===a.value||"class"in d&&b.class===a.class)&&(c=!0)}),c}:function(){return!0}}function ig(a,b){var c=hg(a),d=function(a){return!c(a)},e=b?g.xgridLines:g.ygridLines,f=b?g.xgridLine:g.ygridLine;ok.select("."+e).selectAll("."+f).filter(c).transition().duration(Dg).style("opacity",0).remove(),b?Ki=Ki.filter(d):Mi=Mi.filter(d)}function jg(a,b,c){var d=!xe(mg.data.targets);Qj=!1,pe(a,b),Vf(c||{withTransitionForAxis:d})}function kg(a){var b=a.mimeType?a.mimeType:"csv";lg.xhr(a.url,function(c,d){var e;e="json"===b?Gc(JSON.parse(d.response),a.keys):Fc(d.response),Hf(e)})}var lg=a.d3?a.d3:"undefined"!=typeof require?require("d3"):void 0,mg={data:{},axis:{},legend:{}},ng={},og=i(["bindto"],"#chart"),pg=i(["size","width"]),qg=i(["size","height"]),rg=i(["padding","left"]),sg=i(["padding","right"]),tg=i(["padding","top"]),ug=i(["padding","bottom"]),vg=i(["zoom","enabled"],!1),wg=i(["zoom","extent"]),xg=i(["zoom","privileged"],!1),yg=i(["interaction","enabled"],!0),zg=i(["onenter"],function(){}),Ag=i(["onleave"],function(){}),Bg=i(["onresize"],function(){}),Cg=i(["onresized"],function(){}),Dg=i(["transition","duration"],350);h("data","data is required in config");var Eg,Fg,Gg,Hg,Ig,Jg,Kg,Lg,Mg,Ng