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){var c=a.__max__+1,d=ee(Lg,c),e=be(d,c,a,!!b),f=ce(!!b),g=de(a,!!b),h=b?_:$;return function(a,b){var c=h(a.id)(0),i=g(a,b)||c,j=e(a),k=f(a);return yh&&(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 hf(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:Xi?Ae(f[g].start):f[g].start,u[g].end=c(f[g].end)?a[a.length-1].x:Xi?Ae(f[g].end):f[g].end;for(q=yh?function(a){return e(a.value)}:function(a){return b(a.x)},r=yh?function(a){return b(a.x)}:function(a){return e(a.value)},i=Xi?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)||!De(a[g].x,u))t+=" "+q(a[g])+" "+r(a[g]);else for(j=X(a[g-1].x,a[g].x,Xi),k=X(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 jf(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),sf({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 kf(b){var c,d,e,f=!0;if(Ij=Of.select(Rf),Ij.empty()&&(Ij=Of.select(document.createElement("div")).style("opacity",0),jf(Ij),f=!1),Ij.html("").classed("c3",!0),Pf.data.xs={},Pf.data.targets=zc(b),dh&&(Pf.data.targets=Pf.data.targets.filter(dh)),ch&&Oc(ch===!0?Gc(Pf.data.targets):ch),p(),V(),Fg.domain(Of.extent(dc(Pf.data.targets))),Gg.domain(_b(Pf.data.targets,"y")),Hg.domain(_b(Pf.data.targets,"y2")),Ig.domain(Fg.domain()),Jg.domain(Gg.domain()),Kg.domain(Hg.domain()),Jj=Fg.domain(),xj.scale(Ig),Yf&&Bj.scale(Fg),Cj=Ij.append("svg").style("overflow","hidden").on("mouseenter",ag).on("mouseleave",bg),Dj=Cj.append("defs"),Dj.append("clipPath").attr("id",Ri).append("rect"),Dj.append("clipPath").attr("id",Si).append("rect"),Dj.append("clipPath").attr("id",Ti).append("rect"),wf(),Ej=Cj.append("g").attr("transform",oj.main),Fj=Cj.append("g").attr("transform",oj.context),Gj=Cj.append("g").attr("transform",oj.legend),ph||Fj.style("visibility","hidden"),sh||(Gj.style("visibility","hidden"),ij=Gc(Pf.data.targets)),Hj=Ij.style("position","relative").append("div").style("position","absolute").style("pointer-events","none").style("z-index","10").style("display","none"),Jf(Gc(Pf.data.targets),{withTransform:!1,withTransitionForTransform:!1}),d=Ej.append("g").attr("clip-path",Ui).attr("class",g.grid),hi&&d.append("g").attr("class",g.xgrids),Fe(ji)&&d.append("g").attr("class",g.xgridLines),pi&&d.append("g").attr("class",g.xgridFocus).append("line").attr("class",g.xgridFocus),ki&&d.append("g").attr("class",g.ygrids),Fe(li)&&d.append("g").attr("class",g.ygridLines),Ej.append("g").attr("clip-path",Ui).attr("class",g.regions),Ej.append("g").attr("clip-path",Ui).attr("class",g.chart),c=Ej.select("."+g.chart).append("g").attr("class",g.eventRects).style("fill-opacity",0).style("cursor",Yf?yh?"ns-resize":"ew-resize":null),Ej.select("."+g.chart).append("g").attr("class",g.chartBars),Ej.select("."+g.chart).append("g").attr("class",g.chartLines),Ej.select("."+g.chart).append("g").attr("class",g.chartArcs).attr("transform",oj.arc).append("text").attr("class",g.chartArcsTitle).style("text-anchor","middle").text(Vb()),Ej.select("."+g.chart).append("g").attr("class",g.chartTexts),Yf&&Ej.insert("rect",$f?null:"g."+g.grid).attr("class",g.zoomRect).attr("width",ig).attr("height",kg).style("opacity",0).style("cursor",yh?"ns-resize":"ew-resize").call(Bj).on("dblclick.zoom",null),Ph&&xj.extent("function"!=typeof Ph?Ph:Ph(dc())),jj.x=Ej.append("g").attr("class",g.axisX).attr("clip-path",Vi).attr("transform",o
}],[":%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}]]),hj=[],ij=[],jj={},kj=yh?"left":"bottom",lj=yh?Wh?"top":"bottom":Wh?"right":"left",mj=yh?di?"bottom":"top":di?"left":"right",nj=yh?"left":"bottom",oj={main:function(){return"translate("+k(fg.left)+","+k(fg.top)+")"},context:function(){return"translate("+k(gg.left)+","+k(gg.top)+")"},legend:function(){return"translate("+hg.left+","+hg.top+")"},x:function(){return"translate(0,"+(yh?0:kg)+")"},y:function(){return"translate(0,"+(yh?kg:0)+")"},y2:function(){return"translate("+(yh?0:ig)+","+(yh?1:0)+")"},subx:function(){return"translate(0,"+(yh?0:lg)+")"},arc:function(){return"translate("+rg/2+","+sg/2+")"}},pj="right"===th,qj=0,rj=0,sj=0,tj=.15,uj=30,vj=yh&&!zh?0:30,wj=5;wg=Of.layout.pie().value(function(a){return a.values.reduce(function(a,b){return a+b.value},0)});var xj,yj=bf(Fg,Id,$),zj=bf(Ig,Ld,_),Aj=function(){var a;return a=yh?Of.svg.area().x0(function(a){return $(a.id)(0)}).x1(function(a){return $(a.id)(a.value)}).y(Id):Of.svg.area().x(Id).y0(function(a){return $(a.id)(0)}).y1(function(a){return $(a.id)(a.value)}),function(b){var c,d,e=Te(b.values);return ge([b],"area")||ge([b],"area-spline")?(a.interpolate(ne(b)?"cardinal":"linear"),a(e)):(c=e[0]?Fg(e[0].x):0,d=e[0]?$(b.id)(e[0].value):0,yh?"M "+d+" "+c:"M "+c+" "+d)}}(),Bj=function(){};xj=Of.svg.brush().on("brush",tf),xj.update=function(){return Fj&&Fj.select("."+g.brush).call(this),this},xj.scale=function(a){return yh?this.y(a):this.x(a)},Yf&&(Bj=Of.behavior.zoom().on("zoomstart",function(){Bj.altDomain=Of.event.sourceEvent.altKey?Fg.orgDomain():null}).on("zoom",Yf?uf:null),Bj.scale=function(a){return yh?this.y(a):this.x(a)},Bj.orgScaleExtent=function(){var a=Zf?Zf:[1,10];return[a[0],Math.max(Dc()/a[1],a[1])]},Bj.updateScaleExtent=function(){var a=ec(Fg.orgDomain())/ec(Jj),b=this.orgScaleExtent();return this.scaleExtent([b[0]*a,b[1]*a]),this});var Cj,Dj,Ej,Fj,Gj,Hj,Ij,Jj,Kj,Lj={};if(Pf.focus=function(a){function b(a){Lc(a).transition().duration(100).style("opacity",1)}var c=Cj.selectAll(sd(a)),d=c.filter(Kf),e=c.filter(Lf);Pf.revert(),Pf.defocus(),b(d.classed(g.focused,!0)),b(e),le(Pf.data.targets)&&Rb(a,!0),Ff(a,!0)},Pf.defocus=function(a){function b(a){Lc(a).transition().duration(100).style("opacity",.3)}var c=Cj.selectAll(sd(a)),d=c.filter(Kf),e=c.filter(Lf);Pf.revert(),b(d.classed(g.focused,!1)),b(e),le(Pf.data.targets)&&Sb(a),Ff(a,!1)},Pf.revert=function(a){function b(a){Lc(a).transition().duration(100).style("opacity",1)}var c=Cj.selectAll(sd(a)),d=c.filter(Kf),e=c.filter(Lf);b(d.classed(g.focused,!1)),b(e),le(Pf.data.targets)&&Sb(a),Gf()},Pf.show=function(a,b){a=Hc(a),b=b||{},Pc(a),Cj.selectAll(td(a)).transition().style("opacity",1),b.withLegend&&Hf(a),sf({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0})},Pf.hide=function(a,b){a=Hc(a),b=b||{},Oc(a),Cj.selectAll(td(a)).transition().style("opacity",0),b.withLegend&&If(a),sf({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0})},Pf.toggle=function(a){Jc(a)?Pf.hide(a):Pf.show(a)},Pf.unzoom=function(){xj.clear().update(),sf({withUpdateXDomain:!0})},Pf.load=function(a){return a.xs&&rc(a.xs),"classes"in a&&Object.keys(a.classes).forEach(function(b){Ug[b]=a.classes[b]}),"categories"in a&&Yi&&(Ch=a.categories,Lg.categories(Ch)),"cacheIds"in a&&fc(a.cacheIds)?void Af(hc(a.cacheIds),a.done):void("unload"in a?Cf(Hc("boolean"==typeof a.unload&&a.unload?null:a.unload),function(){Bf(a)}):Bf(a))},Pf.unload=function(a,b){Cf(Hc(a),function(){sf({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0}),"function"==typeof b&&b()})},Pf.selected=function(a){return Of.merge(Ej.selectAll("."+g.shapes+rd(a)).selectAll("."+g.shape).filter(function(){return Of.select(this).classed(g.SELECTED)}).map(function(a){return a.map(function(a){var b=a.__data__;return b.data?b.data:b})}))},Pf.select=fu