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
71 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.round(b(a)+s)+", 0)"})}function d(a,b){a.attr("transform",function(a){return"translate(0,"+Math.round(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){var c=b&&a<u.length?u[a]:a;return j?j(c):c}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.round((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,u=[];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.categories=function(a){return arguments.length?(u=a,i):u},i}var f={version:"0.1.41"},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",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",text:"c3-text",texts:"c3-texts",grid:"c3-grid",xgrid:"c3-xgrid",xgrids:"c3-xgrids",xgridLi
}function gf(a,b,c){var d=c.getBoundingClientRect();return zh?(a[0][0]+a[2][0]+.6*d.height)/2:a[2][1]+(b.value<0?d.height:pe(b)?-3:-6)}function hf(a,b){var c=a.__max__+1,d=fe(Mg,c),e=ce(d,c,a,!!b),f=de(!!b),g=ee(a,!!b),h=b?ab:_;return function(a,b){var c=h(a.id)(0),i=g(a,b)||c,j=e(a),k=f(a);return zh&&(0<a.value&&c>k||a.value<0&&k>c)&&(k=c),[[j,i],[j,k-(c-i)],[j+d,k-(c-i)],[j+d,i]]}}function jf(a,b,e,f){var g,h,i,j,k,l,m,n,o,p,q,r,s=-1,t="M",u=[];if(d(f))for(g=0;g<f.length;g++)u[g]={},u[g].start=c(f[g].start)?a[0].x:Yi?Be(f[g].start):f[g].start,u[g].end=c(f[g].end)?a[a.length-1].x:Yi?Be(f[g].end):f[g].end;for(q=zh?function(a){return e(a.value)}:function(a){return b(a.x)},r=zh?function(a){return b(a.x)}:function(a){return e(a.value)},i=Yi?function(a,c,d,f){var g=a.x.getTime(),h=c.x-a.x,i=new Date(g+h*d),j=new Date(g+h*(d+f));return"M"+b(i)+" "+e(k(d))+" "+b(j)+" "+e(k(d+f))}:function(a,c,d,f){return"M"+b(j(d),!0)+" "+e(k(d))+" "+b(j(d+f),!0)+" "+e(k(d+f))},g=0;g<a.length;g++){if(c(u)||!Ee(a[g].x,u))t+=" "+q(a[g])+" "+r(a[g]);else for(j=Y(a[g-1].x,a[g].x,Yi),k=Y(a[g-1].value,a[g].value),l=b(a[g].x)-b(a[g-1].x),m=e(a[g].value)-e(a[g-1].value),n=Math.sqrt(Math.pow(l,2)+Math.pow(m,2)),o=2/n,p=2*o,h=o;1>=h;h+=p)t+=i(a[g-1],a[g],h,o);s=a[g].x}return t}function kf(b){var c=new MutationObserver(function(d){d.forEach(function(d){if("childList"===d.type&&d.previousSibling){c.disconnect();var e=a.setInterval(function(){b.node().parentNode&&(a.clearInterval(e),tf({withUpdateTranslate:!0,withTransform:!0,withUpdateXDomain:!0,withUpdateOrgXDomain:!0,withTransition:!1,withLegend:!0}),b.transition().style("opacity",1))},10)}})});c.observe(b.node(),{attributes:!0,childList:!0,characterData:!0})}function lf(b){var c,d,e,f=!0;if(Jj=Pf.select(Sf),Jj.empty()&&(Jj=Pf.select(document.createElement("div")).style("opacity",0),kf(Jj),f=!1),Jj.html("").classed("c3",!0),Qf.data.xs={},Qf.data.targets=Ac(b),eh&&(Qf.data.targets=Qf.data.targets.filter(eh)),dh&&Pc(dh===!0?Hc(Qf.data.targets):dh),p(),W(),Gg.domain(Pf.extent(ec(Qf.data.targets))),Hg.domain(ac(Qf.data.targets,"y")),Ig.domain(ac(Qf.data.targets,"y2")),Jg.domain(Gg.domain()),Kg.domain(Hg.domain()),Lg.domain(Ig.domain()),Kj=Gg.domain(),yj.scale(Jg),Zf&&Cj.scale(Gg),Dj=Jj.append("svg").style("overflow","hidden").on("mouseenter",bg).on("mouseleave",cg),Ej=Dj.append("defs"),Ej.append("clipPath").attr("id",Si).append("rect"),Ej.append("clipPath").attr("id",Ti).append("rect"),Ej.append("clipPath").attr("id",Ui).append("rect"),xf(),Fj=Dj.append("g").attr("transform",pj.main),Gj=Dj.append("g").attr("transform",pj.context),Hj=Dj.append("g").attr("transform",pj.legend),qh||Gj.style("visibility","hidden"),th||(Hj.style("visibility","hidden"),jj=Hc(Qf.data.targets)),Ij=Jj.style("position","relative").append("div").style("position","absolute").style("pointer-events","none").style("z-index","10").style("display","none"),Kf(Hc(Qf.data.targets),{withTransform:!1,withTransitionForTransform:!1}),d=Fj.append("g").attr("clip-path",Vi).attr("class",g.grid),ii&&d.append("g").attr("class",g.xgrids),Ge(ki)&&d.append("g").attr("class",g.xgridLines),qi&&d.append("g").attr("class",g.xgridFocus).append("line").attr("class",g.xgridFocus),li&&d.append("g").attr("class",g.ygrids),Ge(mi)&&d.append("g").attr("class",g.ygridLines),Fj.append("g").attr("clip-path",Vi).attr("class",g.regions),Fj.append("g").attr("clip-path",Vi).attr("class",g.chart),c=Fj.select("."+g.chart).append("g").attr("class",g.eventRects).style("fill-opacity",0).style("cursor",Zf?zh?"ns-resize":"ew-resize":null),Fj.select("."+g.chart).append("g").attr("class",g.chartBars),Fj.select("."+g.chart).append("g").attr("class",g.chartLines),Fj.select("."+g.chart).append("g").attr("class",g.chartArcs).attr("transform",pj.arc).append("text").attr("class",g.chartArcsTitle).style("text-anchor","middle").text(Wb()),Fj.select("."+g.chart).append("g").attr("class",g.chartTexts),Zf&&Fj.insert("rect",_f?null:"g."+g.grid).attr("class",g.zoomRect).attr("width",jg).attr("height",lg).style("opacity",0).style("cursor",zh?"ns-resize":"ew-resize").call(Cj).on("dblclick.zoom",n
}],[":%S",function(a){return a.getSeconds()}],["%I:%M",function(a){return a.getMinutes()}],["%I %p",function(a){return a.getHours()}],["%-m/%-d",function(a){return a.getDay()&&1!==a.getDate()}],["%-m/%-d",function(a){return 1!==a.getDate()}],["%-m/%-d",function(a){return a.getMonth()}],["%Y/%-m/%-d",function(){return!0}]]),ij=[],jj=[],kj={},lj=zh?"left":"bottom",mj=zh?Xh?"top":"bottom":Xh?"right":"left",nj=zh?ei?"bottom":"top":ei?"left":"right",oj=zh?"left":"bottom",pj={main:function(){return"translate("+k(gg.left)+","+k(gg.top)+")"},context:function(){return"translate("+k(hg.left)+","+k(hg.top)+")"},legend:function(){return"translate("+ig.left+","+ig.top+")"},x:function(){return"translate(0,"+(zh?0:lg)+")"},y:function(){return"translate(0,"+(zh?lg:0)+")"},y2:function(){return"translate("+(zh?0:jg)+","+(zh?1:0)+")"},subx:function(){return"translate(0,"+(zh?0:mg)+")"},arc:function(){return"translate("+sg/2+","+tg/2+")"}},qj="right"===uh,rj=0,sj=0,tj=0,uj=.15,vj=30,wj=zh&&!Ah?0:30,xj=5;xg=Pf.layout.pie().value(function(a){return a.values.reduce(function(a,b){return a+b.value},0)});var yj,zj=cf(Gg,Jd,_),Aj=cf(Jg,Md,ab),Bj=function(){var a;return a=zh?Pf.svg.area().x0(function(a){return _(a.id)(0)}).x1(function(a){return _(a.id)(a.value)}).y(Jd):Pf.svg.area().x(Jd).y0(function(a){return _(a.id)(0)}).y1(function(a){return _(a.id)(a.value)}),function(b){var c,d,e=Ue(b.values);return he([b],"area")||he([b],"area-spline")?(a.interpolate(oe(b)?"cardinal":"linear"),a(e)):(c=e[0]?Gg(e[0].x):0,d=e[0]?_(b.id)(e[0].value):0,zh?"M "+d+" "+c:"M "+c+" "+d)}}(),Cj=function(){};yj=Pf.svg.brush().on("brush",uf),yj.update=function(){return Gj&&Gj.select("."+g.brush).call(this),this},yj.scale=function(a){return zh?this.y(a):this.x(a)},Zf&&(Cj=Pf.behavior.zoom().on("zoomstart",function(){Cj.altDomain=Pf.event.sourceEvent.altKey?Gg.orgDomain():null}).on("zoom",Zf?vf:null),Cj.scale=function(a){return zh?this.y(a):this.x(a)},Cj.orgScaleExtent=function(){var a=$f?$f:[1,10];return[a[0],Math.max(Ec()/a[1],a[1])]},Cj.updateScaleExtent=function(){var a=fc(Gg.orgDomain())/fc(Kj),b=this.orgScaleExtent();return this.scaleExtent([b[0]*a,b[1]*a]),this});var Dj,Ej,Fj,Gj,Hj,Ij,Jj,Kj,Lj,Mj={};if(Qf.focus=function(a){function b(a){Mc(a).transition().duration(100).style("opacity",1)}var c=Dj.selectAll(td(a)),d=c.filter(Lf),e=c.filter(Mf);Qf.revert(),Qf.defocus(),b(d.classed(g.focused,!0)),b(e),me(Qf.data.targets)&&Sb(a,!0),Gf(a,!0)},Qf.defocus=function(a){function b(a){Mc(a).transition().duration(100).style("opacity",.3)}var c=Dj.selectAll(td(a)),d=c.filter(Lf),e=c.filter(Mf);Qf.revert(),b(d.classed(g.focused,!1)),b(e),me(Qf.data.targets)&&Tb(a),Gf(a,!1)},Qf.revert=function(a){function b(a){Mc(a).transition().duration(100).style("opacity",1)}var c=Dj.selectAll(td(a)),d=c.filter(Lf),e=c.filter(Mf);b(d.classed(g.focused,!1)),b(e),me(Qf.data.targets)&&Tb(a),Hf()},Qf.show=function(a,b){a=Ic(a),b=b||{},Qc(a),Dj.selectAll(ud(a)).transition().style("opacity",1),b.withLegend&&If(a),tf({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0})},Qf.hide=function(a,b){a=Ic(a),b=b||{},Pc(a),Dj.selectAll(ud(a)).transition().style("opacity",0),b.withLegend&&Jf(a),tf({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0})},Qf.toggle=function(a){Kc(a)?Qf.hide(a):Qf.show(a)},Qf.unzoom=function(){yj.clear().update(),tf({withUpdateXDomain:!0})},Qf.load=function(a){return a.xs&&sc(a.xs),"classes"in a&&Object.keys(a.classes).forEach(function(b){Vg[b]=a.classes[b]}),"categories"in a&&Zi&&(Dh=a.categories,Mg.categories(Dh)),"cacheIds"in a&&gc(a.cacheIds)?void Bf(ic(a.cacheIds),a.done):void("unload"in a?Df(Ic("boolean"==typeof a.unload&&a.unload?null:a.unload),function(){Cf(a)}):Cf(a))},Qf.unload=function(a,b){Df(Ic(a),function(){tf({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0}),"function"==typeof b&&b()})},Qf.selected=function(a){return Pf.merge(Fj.selectAll("."+g.shapes+sd(a)).selectAll("."+g.shape).filter(function(){return Pf.select(this).classed(g.SELECTED)}).map(function(a){return a.map(function(a){var b=a.__data__;return b.data?b.data:b})}))},Qf.select=f