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
69 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}var e={version:"0.1.34"},f={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",xgridLine:"c3-xgrid-line",xgridLines:"c3-xgrid-lines",xgridFocus:"c3-xgrid-focus",ygrid:"c3-ygrid",ygrids:"c3-ygrids",ygridLine:"c3-ygrid-line",ygridLines:"c3-ygrid-lines",axisX:"c3-axis-x",axisXLabel:"c3-axis-x-label",axisY:"c3-axis-y",axisYLabel:"c3-axis-y-label",axisY2:"c3-axis-y2",axisY2Label:"c3-axis-y2-label",legendItem:"c3-legend-item",legendItemEvent:"c3-legend-item-event",legendItemTile:"c3-legend-item-tile",legendItemHidden:"c3-legend-item-hidden",legendItemFocused:"c3-legend-item-focused",dragarea:"c3-dragarea",EXPANDED:"_expanded_",SELECTED:"_selected_",INCLUDED:"_included_"};e.generate=function(e){function g(a,b){if(!(a in e))throw Error(b)}function h(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)return b;g=f}return g}function i(a){return"url("+document.URL.split("#")[0]+"#"+a+")"}function j(a,b){var c,d,e;b&&b.axisX?c=b.axisX:(c=pj.select("."+f.axisX),a&&(c=c.transition())),b&&b.axisY?d=b.axisY:(d=pj.select("."+f.axisY),a&&(d=d.transition())),b&&b.axisY2?e=b.axisY2:(e=pj.select("."+f.axisY2),a&&(e=e.transition())),pj.attr("transform",_i.main),c.attr("transform",_i.x),d.attr("transform",_i.y),e.attr("transform",_i.y2),pj.select("."+f.chartArcs).attr("transform",_i.arc)}function k(a,b){var c;b&&b.axisSubX?c=b.axisSubX:(c=qj.select("."+f.axisX),a&&(c=c.transition())),qj.attr("transform",_i.context),c.attr("transform",_i.subx)}function l(a){(a?rj.transition():rj).attr("transform",_i.legend)}function m(a,b){j(a,b),bh&&k(a,b),l(a)}function n(){var a=Q(),b=P(),c=aj?0:a,d=kh?0:w("x"),e=bh?ch+d:0;bg=r(),cg=s(),kh?(Wf={top:w("y2")+Mf,right:u(),bottom:w("y")+c+Nf,left:e+t()},Xf={top:Wf.top,right:0/0,bottom:20+c,left:fj}):(Wf={top:4+Mf,right:u(),bottom:d+e+c+Nf,left:t()},Xf={top:cg-e-c,right:0/0,bottom:d+c,left:Wf.left}),Yf={top:aj?0:cg-a,right:0/0,bottom:0,left:aj?bg-b:0},Zf=bg-Wf.left-Wf.right,_f=cg-Wf.top-Wf.bottom,0>Zf&&(Zf=0),0>_f&&(_f=0),$f=kh?Wf.left-fj-gj:Zf,ag=kh?_f:cg-Xf.top-Xf.bottom,0>$f&&($f=0),0>ag&&(ag=0),p(),aj&&he(Ff.data.targets)&&(Yf.left=Zf/2+eg)}function o(){pj.select("line."+f.xgridFocus).attr("x1",kh?0:-10).attr("x2",kh?Zf:-10).attr("y1",kh?-10:Wf.top).attr("y2",kh?-10:_f)}function p(){eg=_f/2,dg=.95*eg,fg=ge(Ff.data.targets)?.6*dg:0}function q(){var a=kh?f.axisX:f.axisY,b=pj.select("."+a).node(),c=b?b.getBoundingClientRect():{right:0},d=Ef.select(Hf).node().getBoundingClientRect(),e=c.right-d.left-t();return e>0?e:0}function r(){return If?If:x()}function s(){var a=Jf?Jf:y();return a>0?a:320}function t(){return he(Ff.data.targets)?0:Kf?Kf:kh?lh?v("x"):1:!Dh||Ih?1:v("y")}function u(){var a=1;return he(Ff.data.targets)?0:Lf?Lf:aj?P()+20+(Mh&&!kh?v("y2"):a):Mh?Rh||kh?a:v("y2"):a}function v(a){var b=jb(a);return b.isInner?20+Cb(a):40+Cb(a)}function w(a){return"x"!==a||lh?"x"===a&&Ah?Ah:"y"!==a||Dh?"y2"!==a||Mh?(jb(a).isInner?30:40)+("y2"===a?-10:0):hj:eh&&!aj?10:1:0}function x(){return+Ef.select(Hf).style("width").replace("px","")}fu
}sj.html(zi(Ff.data.targets.map(function(a){return pc(a.values[Bi])}),$(),zd(he(Ff.data.targets)),Si)),sj.style("top",Ci.top).style("left",Ci.left).style("display","block")}null==a.onresize&&(a.onresize=mf()),a.onresize.add&&(a.onresize.add(Tf),a.onresize.add(function(){of({withLegend:!0,withTransition:!1,withTransitionForTransform:!1})}),a.onresize.add(Uf))}function cf(a){a.append("rect").attr("class",id).style("cursor",Sg&&Tg?"pointer":null).on("mouseover",function(a,b){if(!Ni&&!he(Ff.data.targets)){var c,d,e=Ff.data.targets.map(function(a){return pc(a.values[b])});if(Object.keys(Gg).length>0){d=[];for(var g in Gg)for(c=0;c<e.length;c++)if(e[c].id===g){d.push(e[c]),e.shift(c);break}e=d.concat(e)}ci&&Se(b),Ve(b),pj.selectAll("."+f.shape+"-"+b).each(function(a){Xg(a)})}}).on("mouseout",function(a,b){he(Ff.data.targets)||(Vd(),Td(),Te(b),We(),pj.selectAll("."+f.shape+"-"+b).each(function(a){Yg(a)}))}).on("mousemove",function(a,b){var c;Ni||he(Ff.data.targets)||(c=Ic(Ff.data.targets).map(function(a){return pc(a.values[b])}),Sd(c,Ef.mouse(this)),Ud(c),Sg&&(Tg||pj.selectAll("."+f.shape+"-"+b).filter(function(a){return Ug(a)}).each(function(){var a=Ef.select(this).classed(f.EXPANDED,!0);"circle"===this.nodeName&&a.attr("r",Pe),nj.select("."+f.eventRect+"-"+b).style("cursor",null)}).filter(function(a){return"circle"===this.nodeName?xe(this,Qe(a)):"path"===this.nodeName?ye(this):void 0}).each(function(){var a=Ef.select(this);a.classed(f.EXPANDED)||(a.classed(f.EXPANDED,!0),"circle"===this.nodeName&&a.attr("r",Qe)),nj.select("."+f.eventRect+"-"+b).style("cursor","pointer")})))}).on("click",function(a,b){return he(Ff.data.targets)?void 0:Oi?void(Oi=!1):void pj.selectAll("."+f.shape+"-"+b).each(function(a){ef(this,a,b)})}).call(Ef.behavior.drag().origin(Object).on("drag",function(){ff(Ef.mouse(this))}).on("dragstart",function(){gf(Ef.mouse(this))}).on("dragend",function(){hf()})).call(mj).on("dblclick.zoom",null)}function df(a){a.append("rect").attr("x",0).attr("y",0).attr("width",Zf).attr("height",_f).attr("class",f.eventRect).on("mouseout",function(){he(Ff.data.targets)||(Vd(),Td(),Te())}).on("mousemove",function(){var a,b,c,d,e=Ic(Ff.data.targets);Ni||he(e)||(a=Ef.mouse(this),b=Ld(e,a),b&&(c=le(b)?[b]:Nd(e,b.x),d=c.map(function(a){return pc(a)}),Sd(d,a),ci&&(Te(),Se(b.index,b.id)),Ud(d),De(b,a)<100?(nj.select("."+f.eventRect).style("cursor","pointer"),Pi||(Xg(b),Pi=!0)):(nj.select("."+f.eventRect).style("cursor",null),Yg(b),Pi=!1)))}).on("click",function(){var a,b,c=Ic(Ff.data.targets);he(c)||(a=Ef.mouse(this),b=Ld(c,a),b&&De(b,a)<100&&pj.select("."+f.circles+"-"+od(b.id)).select("."+f.circle+"-"+b.index).each(function(){ef(this,b,b.index)}))}).call(Ef.behavior.drag().origin(Object).on("drag",function(){ff(Ef.mouse(this))}).on("dragstart",function(){gf(Ef.mouse(this))}).on("dragend",function(){hf()})).call(mj).on("dblclick.zoom",null)}function ef(a,b,c){var d,e,g=Ef.select(a),h=g.classed(f.SELECTED);"circle"===a.nodeName?(d=xe(a,1.5*Qe(b)),e=He):"path"===a.nodeName&&(g.classed(f.bar)?(d=ye(a),e=Ke):(d=!0,e=Le)),(Tg||d)&&(Sg&&Ug(b)&&(Vg||pj.selectAll("."+f.shapes+(Tg?od(b.id):"")).selectAll("."+f.shape).each(function(a,b){var c=Ef.select(this);c.classed(f.SELECTED)&&e(!1,c.classed(f.SELECTED,!1),a,b)}),g.classed(f.SELECTED,!h),e(!h,g,b,c)),Wg(b,a))}function ff(a){var b,c,d,e,g,h,i,j;he(Ff.data.targets)||Sg&&(!Of||mj.altDomain)&&Vg&&(b=Mi[0],c=Mi[1],d=a[0],e=a[1],g=Math.min(b,d),h=Math.max(b,d),i=Tg?Wf.top:Math.min(c,e),j=Tg?_f:Math.max(c,e),pj.select("."+f.dragarea).attr("x",g).attr("y",i).attr("width",h-g).attr("height",j-i),pj.selectAll("."+f.shapes).selectAll("."+f.shape).filter(function(a){return Ug(a)}).each(function(a,b){var c,d,e,k,l,m,n=Ef.select(this),o=n.classed(f.SELECTED),p=n.classed(f.INCLUDED),q=!1;"circle"===this.nodeName?(c=1*n.attr("cx"),d=1*n.attr("cy"),l=He,q=c>g&&h>c&&d>i&&j>d):"path"===this.nodeName&&(m=Od(this),c=m.x,d=m.y,e=m.width,k=m.height,l=Ke,q=!(c>h||g>c+e||d>j||i>d+k)),q^p&&(n.classed(f.INCLUDED,!p),n.classed(f.SELECTED,!o),l(!o,n,a,b))}))}function gf(a){he(Ff.data.targets)||Sg&&(Mi=a,pj.select("."
i&&j&&Ug(c)&&k&&h(!1,e.classed(f.SELECTED,!1),c,d)})},Ff.toLine=function(a){Df(a,"line")},Ff.toSpline=function(a){Df(a,"spline")},Ff.toBar=function(a){Df(a,"bar")},Ff.toScatter=function(a){Df(a,"scatter")},Ff.toArea=function(a){Df(a,"area")},Ff.toAreaSpline=function(a){Df(a,"area-spline")},Ff.toPie=function(a){Df(a,"pie",{withTransform:!0})},Ff.toDonut=function(a){Df(a,"donut",{withTransform:!0})},Ff.groups=function(a){return c(a)?Ig:(Ig=a,jf(),Ig)},Ff.xgrids=function(a){return a?(Xh=a,jf(),Xh):Xh},Ff.xgrids.add=function(a){return a?Ff.xgrids(Xh.concat(a)):void 0},Ff.xgrids.remove=function(a){var b=Cf(a);return Ff.xgrids(Xh.filter(b))},Ff.ygrids=function(a){return a?(Zh=a,jf(),Zh):Zh},Ff.ygrids.add=function(a){return a?Ff.ygrids(Zh.concat(a)):void 0},Ff.ygrids.remove=function(a){var b=Cf(a);return Ff.ygrids(Zh.filter(b))},Ff.regions=function(a){return c(a)?vi:(vi=a,jf(),vi)},Ff.regions.add=function(a){return c(a)?vi:(vi=vi.concat(a),jf(),vi)},Ff.regions.remove=function(a,c){var e=[].concat(a);return c=d(c)?c:{},e.forEach(function(a){var d=b(c.duration)?c.duration:0;nj.selectAll("."+a).transition().duration(d).style("fill-opacity",0).remove(),vi=vi.filter(function(b){return b.classes.indexOf(a)<0})}),vi},Ff.data.get=function(a){var b=Ff.data.getAsTarget(a);return d(b)?b.values.map(function(a){return a.value}):void 0},Ff.data.getAsTarget=function(a){var b=Fc(function(b){return b.id===a});return b.length>0?b[0]:void 0},Ff.data.names=function(a){return arguments.length?(Object.keys(a).forEach(function(b){Gg[b]=a[b]}),jf({withLegend:!0}),Gg):Gg},Ff.data.colors=function(a){return arguments.length?(Object.keys(a).forEach(function(b){Qg[b]=a[b]}),jf({withLegend:!0}),Qg):Qg},Ff.x=function(a){return arguments.length&&(qc(Ff.data.targets,a),jf({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),Ff.data.xs},Ff.xs=function(a){return arguments.length&&(rc(Ff.data.targets,a),jf({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),Ff.data.xs},Ff.axis.labels=function(a){arguments.length&&(Object.keys(a).forEach(function(b){bb(b,a[b])}),Db())},Ff.axis.max=function(a){arguments.length&&("object"==typeof a?(b(a.y)&&(Eh=+a.y),b(a.y2)&&(Nh=+a.y2)):Eh=Nh=+a,jf())},Ff.axis.min=function(a){arguments.length&&("object"==typeof a?(b(a.y)&&(Fh=+a.y),b(a.y2)&&(Oh=+a.y2)):Fh=Oh=+a,jf())},Ff.axis.range=function(a){arguments.length&&("undefined"!=typeof a.max&&Ff.axis.max(a.max),"undefined"!=typeof a.min&&Ff.axis.min(a.min))},Ff.legend.show=function(a){xf(Dc(a)),jf({withLegend:!0})},Ff.legend.hide=function(a){yf(Dc(a)),jf({withLegend:!0})},Ff.resize=function(a){If=a?a.width:null,Jf=a?a.height:null,of({withLegend:!0,withTransition:!1,withTransitionForTransform:!1})},Ff.destroy=function(){Ff.data.targets=void 0,Ff.data.xs={},tj.html(""),a.onresize=null},"url"in e.data)Ef.xhr(e.data.url,function(a,b){var c,d=Ef.csv.parseRows(b.response);1===d.length?(c=[{}],d[0].forEach(function(a){c[0][a]=null})):c=Ef.csv.parse(b.response),bf(c)});else if("rows"in e.data)bf(tc(e.data.rows));else{if(!("columns"in e.data))throw Error("url or rows or columns is required.");bf(uc(e.data.columns))}return Ff},"function"==typeof a.define&&a.define.amd?a.define("c3",["d3"],e):a.c3=e}(window);