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
78 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.1.42"},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",text
}).remove(),c}function _e(a){return ye(a)?"cardinal":xe(a)?"step-after":"linear"}function af(){return hg.selectAll([])}function bf(a,b,c){Gh(b,a.node()),ik.select("."+g.selectedCircles+Ad(b.id)).selectAll("."+g.selectedCircle+"-"+c).data([b]).enter().append("circle").attr("class",function(){return ed(g.selectedCircle,c)}).attr("cx",Uh?me:le).attr("cy",Uh?le:me).attr("stroke",function(){return Mj(b)}).attr("r",1.4*nf(b)).transition().duration(100).attr("r",nf)}function cf(a,b,c){Hh(b,a.node()),ik.select("."+g.selectedCircles+Ad(b.id)).selectAll("."+g.selectedCircle+"-"+c).transition().duration(100).attr("r",0).remove()}function df(a,b,c,d){a?bf(b,c,d):cf(b,c,d)}function ef(a,b){Gh(b,a.node()),a.transition().duration(100).style("fill",function(){return hg.rgb(Mj(b)).brighter(.75)})}function ff(a,b){Hh(b,a.node()),a.transition().duration(100).style("fill",function(){return Mj(b)})}function gf(a,b,c,d){a?ef(b,c,d):ff(b,c,d)}function hf(a,b,c,d){gf(a,b,c.data,d)}function jf(a){return"circle"===a.nodeName?df:hg.select(a).classed(g.bar)?gf:hf}function kf(a){return a.filter(function(a){return b(a.value)})}function lf(a){return Ji&&!xe(a)?"function"==typeof Ki?Ki(a):Ki:0}function mf(a){return Mi?Ni?Ni:1.75*lf(a):lf(a)}function nf(a){return Oi?Oi:4*lf(a)}function of(a,c){return(c?ik.selectAll("."+g.circles+Ad(c)):ik).selectAll("."+g.circle+(b(a)?"-"+a:""))}function pf(a,b){of(a,b).classed(g.EXPANDED,!0).attr("r",mf)}function qf(a){of(a).filter(function(){return hg.select(this).classed(g.EXPANDED)}).classed(g.EXPANDED,!1).attr("r",lf)}function rf(a){return ik.selectAll("."+g.bar+(b(a)?"-"+a:""))}function sf(a){rf(a).classed(g.EXPANDED,!0)}function tf(a){rf(a).classed(g.EXPANDED,!1)}function uf(a,b){var c=hg.svg.area(),d=Af(a,b),e=b?ab:_,f=function(a,b){return oh.length>0?d(a,b)[0][1]:e(a.id)(0)},g=function(a,b){return oh.length>0?d(a,b)[1][1]:e(a.id)(a.value)};return c=Uh?c.x0(f).x1(g).y(Rd):c.x(Rd).y0(f).y1(g),function(a){var b,d,e=kf(a.values);return ze(a)?c.interpolate(_e(a))(e):(b=$g(e[0].x),d=_(a.id)(e[0].value),Uh?"M "+d+" "+b:"M "+b+" "+d)}}function vf(a,b){var c=hg.svg.line(),d=Cf(a,b),e=b?ab:_,f=b?Ud:Rd,g=function(a,b){return oh.length>0?d(a,b)[0][1]:e(a.id)(a.value)};return c=Uh?c.x(g).y(f):c.x(f).y(g),Pi||(c=c.defined(function(a){return null!=a.value})),function(a){var d=Pi?kf(a.values):a.values,f=b?f:bh,g=e(a.id),h=0,i=0;return we(a)?uh[a.id]?Df(d,f,g,uh[a.id]):c.interpolate(_e(a))(d):(d[0]&&(h=f(d[0].x),i=g(d[0].value)),Uh?"M "+i+" "+h:"M "+h+" "+i)}}function wf(a,b){var c=Bf(a,b);return function(a,b){var d=c(a,b),e=Uh?1:0,f=Uh?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 xf(a,b){var c=Bf(a,!1),d=b?yf:zf;return function(a,b){return d(c(a,b),a,this)}}function yf(a,b){var c;return Uh?(c=Ae(b)?4:6,a[2][1]+c*(b.value<0?-1:1)):a[0][0]+(a[2][0]-a[0][0])/2}function zf(a,b,c){var d=c.getBoundingClientRect();return Uh?(a[0][0]+a[2][0]+.6*d.height)/2:a[2][1]+(b.value<0?d.height:Ae(b)?-3:-6)}function Af(a,b){var c=a.__max__+1,d=ie(0,c,a,!!b),e=je(!!b),f=ke(ze,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 Uh&&(0<a.value&&c>j||a.value<0&&j>c)&&(j=c),[[i,h],[i,j-(c-h)]]}}function Bf(a,b){var c=a.__max__+1,d=ne(eh,c),e=ie(d,c,a,!!b),f=je(!!b),g=ke(Ae,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 Uh&&(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 Cf(a,b){var c=a.__max__+1,d=ie(0,c,a,!!b),e=je(!!b),f=ke(we,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 Uh&&(0<a.value&&c>j||a.value<0&&j>c)&&(j=c),[[i,j-(c-h)]]}}function Df(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:Dj?Oe(f[g].start):f[g].start,u[g].end=c(f[g].end)?a[a.length-1].x:Dj?Oe(f[g].end):f[g].end;for(q=Uh?function(a){return e(a.value)}:function(a){return b(a.x)},r=Uh?function(a){return b(a.x)}:function(a){return e(a.value)},i=Dj?function(a,c,d,f){var
}).on("mouseover",function(a){hg.select(this).classed(g.legendItemFocused,!0),Kj||ig.focus(a),"function"==typeof Rh&&Rh(a)}).on("mouseout",function(a){hg.select(this).classed(g.legendItemFocused,!1),Kj||ig.revert(),"function"==typeof Sh&&Sh(a)}),m.append("text").text(function(a){return d(mh[a])?mh[a]:a}).each(function(a,b){e(this,a,0===b)}).style("pointer-events","none").attr("x",Yj?h:-200).attr("y",Yj?-200:k),m.append("rect").attr("class",g.legendItemEvent).style("fill-opacity",0).attr("x",Yj?i:-200).attr("y",Yj?-200:l),m.append("rect").attr("class",g.legendItemTile).style("pointer-events","none").style("fill",Mj).attr("x",Yj?h:-200).attr("y",Yj?-200:j).attr("width",10).attr("height",10),r=kk.selectAll("text").data(a).text(function(a){return d(mh[a])?mh[a]:a}).each(function(a,b){e(this,a,0===b)}),(n?r.transition():r).attr("x",h).attr("y",k),s=kk.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=kk.selectAll("rect."+g.legendItemTile).data(a),(n?t.transition():t).style("fill",Mj).attr("x",f).attr("y",j),kk.selectAll("."+g.legendItem).classed(g.legendItemHidden,function(a){return!Sc(a)}).transition().style("opacity",function(a){var b=hg.select(this);return Sc(a)?!G||b.classed(g.legendItemFocused)?Yf(b):Zf(b):ak}),S(w),T(x),R(F),p(),W(),Rf(),o(q,c)}function dg(a){return Rc(ig.data.targets,a.id)}function eg(a){return"data"in a&&Rc(ig.data.targets,a.data.id)}function fg(a){var b=a&&a.value?a.value:null,c=a&&a["class"]?a["class"]:null;return b?function(a){return a.value!==b}:c?function(a){return a["class"]!==c}:function(){return!0}}function gg(a,b,c){var d=!ve(ig.data.targets);Kj=!1,oe(a,b),Tf(c||{withTransitionForAxis:d})}var hg=a.d3?a.d3:"undefined"!=typeof require?require("d3"):void 0,ig={data:{},axis:{},legend:{}},jg={},kg=i(["bindto"],"#chart"),lg=i(["size","width"]),mg=i(["size","height"]),ng=i(["padding","left"]),og=i(["padding","right"]),pg=i(["padding","top"]),qg=i(["padding","bottom"]),rg=i(["zoom","enabled"],!1),sg=i(["zoom","extent"]),tg=i(["zoom","privileged"],!1),ug=i(["interaction","enabled"],!0),vg=i(["onenter"],function(){}),wg=i(["onleave"],function(){}),xg=i(["onresize"],function(){}),yg=i(["onresized"],function(){}),zg=i(["transition","duration"],350);h("data","data is required in config");var Ag,Bg,Cg,Dg,Eg,Fg,Gg,Hg,Ig,Jg,Kg,Lg,Mg,Ng,Og,Pg,Qg,Rg,Sg,Tg,Ug,Vg,Wg,Xg,Yg,Zg,$g,_g,ah,bh,ch,dh,eh,fh,gh,hh,ih=i(["data","x"]),jh=i(["data","xs"],{}),kh=i(["data","x_format"]),lh=i(["data","id_converter"],function(a){return a}),mh=i(["data","names"],{}),nh=i(["data","classes"],{}),oh=i(["data","groups"],[]),ph=i(["data","axes"],{}),qh=i(["data","type"]),rh=i(["data","types"],{}),sh=i(["data","labels"],{}),th=i(["data","order"]),uh=i(["data","regions"],{}),vh=i(["data","color"]),wh=i(["data","colors"],{}),xh=i(["data","hide"],!1),yh=i(["data","filter"]),zh=i(["data","selection","enabled"],!1),Ah=i(["data","selection","grouped"],!1),Bh=i(["data","selection","isselectable"],function(){return!0}),Ch=i(["data","selection","multiple"],!0),Dh=i(["data","onclick"],function(){}),Eh=i(["data","onenter"],function(){}),Fh=i(["data","onleave"],function(){}),Gh=i(["data","onselected"],function(){}),Hh=i(["data","onunselected"],function(){}),Ih=i(["data","ondragstart"],function(){}),Jh=i(["data","ondragend"],function(){}),Kh=i(["subchart","show"],!1),Lh=i(["subchart","size","height"],60),Mh=i(["color","pattern"],[]),Nh=i(["color","threshold"],{}),Oh=i(["legend","show"],!0),Ph=i(["legend","position"],"bottom"),Qh=i(["legend","item","onclick"]),Rh=i(["legend","item","onmouseover"]),Sh=i(["legend","item","onmouseout"]),Th=i(["legend","equally"],!1),Uh=i(["axis","rotated"],!1),Vh=i(["axis","x","show"],!0),Wh=i(["axis","x","type"],"indexed"),Xh=i(["axis","x","localtime"],!0),Yh=i(["axis","x","categories"],[]),Zh=i(["axis","x","tick","centered"],!1),$h=i(["axis","x","tick","format"]),_h=i(["axis","x","tick","culling"],{}),ai=i(["axis","x","tick","culling","max"],10),bi=i(["axis","x","tick","count"]),ci=i(["axis","x","t