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
65 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.29"},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",bar:"c3-bar",bars:"c3-bars",circle:"c3-circle",circles:"c3-circles",arc:"c3-arc",area:"c3-area",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",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||d&&"object"!=typeof b&&"object"==typeof f&&null!==f)return b;g=f}return g}function i(a){return"url("+document.URL.split("#")[0]+"#"+a+")"}function j(a){var b=a!==!1?250:0;Gi.attr("transform",ri.main),Gi.select("."+f.axisX).transition().duration(b).attr("transform",ri.x),Gi.select("."+f.axisY).transition().duration(b).attr("transform",ri.y),Gi.select("."+f.axisY2).attr("transform",ri.y2),Gi.select("."+f.chartArcs).attr("transform",ri.arc)}function k(){Gg&&(Hi.attr("transform",ri.context),Hi.select("."+f.axisX).attr("transform",ri.subx))}function l(a){var b=a!==!1?250:0;Ii.transition().duration(b).attr("transform",ri.legend)}function m(a){j(a),k(a),l(a)}function n(){var a=Q(),b=P();Hf=r(),If=s(),Af={top:Ng?w("y2"):yi,right:u(),bottom:w(Ng?"y":"x")+(Ng?0:Hg)+(si?0:a),left:(Ng?Hg+xi:0)+t()},Df=Hf-Af.left-Af.right,Ff=If-Af.top-Af.bottom,0>Df&&(Df=0),0>Ff&&(Ff=0),Bf={top:Ng?Af.top:If-Hg-(si?0:a),right:0/0,bottom:20+(si?0:a),left:Ng?wi:Af.left},Ef=Ng?Af.left-wi-xi:Df,Gf=Ng?Ff:If-Bf.top-Bf.bottom,0>Ef&&(Ef=0),0>Gf&&(Gf=0),Cf={top:si?0:If-a,right:0/0,bottom:0,left:si?Hf-b:0},p(),si&&Yd(nf.data.targets)&&(Cf.left=Df/2+Kf)}function o(){Gi.select("line."+f.xgridFocus).attr("x1",Ng?0:-10).attr("x2",Ng?Df:-10).attr("y1",Ng?-10:Af.top).attr("y2",Ng?-10:Ff)}function p(){Kf=Ff/2,Jf=.95*Kf,Lf=Xd(nf.data.targets)?.6*Jf:0}function q(){var a=Ng?f.axisX:f.axisY,b=mf.select("."+a).node(),c=b?b.getBoundingClientRect():{right:0},d=mf.select(pf).node().getBoundingClientRect(),e=c.right-d.left-t();return e>0?e:0}function r(){return qf?qf:x()}function s(){var a=rf?rf:y();return a>0?a:320}function t(){return Yd(nf.data.targets)?0:sf?sf:Ng||!$g||dh?1:v("y")}function u(){var a=1;return Yd(nf.data.targets)?0:tf?tf:si?P()+(hh&&!Ng?v("y2"):a):hh?mh||Ng?a:v("y2"):a}function v(a){var b=gb(a);return b.isInner?20+zb(a):40+zb(a)}function w(a){return"y"!==a||$g?"y2"!==a||hh?(gb(a).isInner?30:40)+("y2"===a?-10:0):yi:Jg&&!si?10:1}function x(){return+mf.select(pf).style("width").replace("px","")}function y(){return+mf.select(pf).style("height").replace("px","")}function z(a){return a?-5:-(Af.left-1)}function A(a){return a?-20:-1}function B(){return z(!Ng)}function C(){return A(!Ng)}function D(){return z(Ng)}function E(){return A(Ng)}function F(a){return a?Df+2+4:Af.left+20}functio
}Ji.html(Th(nf.data.targets.map(function(a){return lc(a.values[Vh])}),$(),rd,ji)),Ji.style("top",Wh.top).style("left",Wh.left).style("display","block")}null==a.onresize&&(a.onresize=Ue()),a.onresize.add&&a.onresize.add(function(){We({withLegend:!0,withTransition:!1,withTransitionForTransform:!1})})}function Le(a){a.append("rect").attr("class",ad).style("cursor",vg&&wg?"pointer":null).on("mouseover",function(a,b){if(!fi&&!Yd(nf.data.targets)){var c,d,e=nf.data.targets.map(function(a){return lc(a.values[b])});if(Object.keys(kg).length>0){d=[];for(var g in kg)for(c=0;c<e.length;c++)if(e[c].id===g){d.push(e[c]),e.shift(c);break}e=d.concat(e)}zh&&ze(b),Ce(b),Gi.selectAll("."+f.shape+"-"+b).each(function(a){Ag(a)})}}).on("mouseout",function(a,b){Yd(nf.data.targets)||(Kd(),Id(),Ae(b),De(),Gi.selectAll("."+f.shape+"-"+b).each(function(a){Bg(a)}))}).on("mousemove",function(a,b){var c;fi||Yd(nf.data.targets)||(c=Dc(nf.data.targets).map(function(a){return lc(a.values[b])}),Hd(c,mf.mouse(this)),Jd(c),vg&&(wg||Gi.selectAll("."+f.shape+"-"+b).filter(function(a){return xg(a)}).each(function(){var a=mf.select(this).classed(f.EXPANDED,!0);"circle"===this.nodeName&&a.attr("r",Ah),Ei.select("."+f.eventRect+"-"+b).style("cursor",null)}).filter(function(){return"circle"===this.nodeName?je(this,Bh):"path"===this.nodeName?ke(this):void 0}).each(function(){var a=mf.select(this);a.classed(f.EXPANDED)||(a.classed(f.EXPANDED,!0),"circle"===this.nodeName&&a.attr("r",Bh)),Ei.select("."+f.eventRect+"-"+b).style("cursor","pointer")})))}).on("click",function(a,b){return Yd(nf.data.targets)?void 0:gi?void(gi=!1):void Gi.selectAll("."+f.shape+"-"+b).each(function(a){Ne(this,a,b)})}).call(mf.behavior.drag().origin(Object).on("drag",function(){Oe(mf.mouse(this))}).on("dragstart",function(){Pe(mf.mouse(this))}).on("dragend",function(){Qe()})).call(Di).on("dblclick.zoom",null)}function Me(a){a.append("rect").attr("x",0).attr("y",0).attr("width",Df).attr("height",Ff).attr("class",f.eventRect).on("mouseout",function(){Yd(nf.data.targets)||(Kd(),Id(),Ae())}).on("mousemove",function(){var a,b,c,d;fi||Yd(nf.data.targets)||(a=mf.mouse(this),b=Ad(nf.data.targets,a),c=Cd(nf.data.targets,b.x),d=c.map(function(a){return lc(a)}),Hd(d,a),zh&&(Ae(),ze(b.index,b.id)),Jd(d),pe(b,a)<100?(Ei.select("."+f.eventRect).style("cursor","pointer"),hi||(Ag(b),hi=!0)):(Ei.select("."+f.eventRect).style("cursor",null),Bg(b),hi=!1))}).on("click",function(){var a,b;Yd(nf.data.targets)||(a=mf.mouse(this),b=Ad(nf.data.targets,a),pe(b,a)<100&&Gi.select("."+f.circles+"-"+gd(b.id)).select("."+f.circle+"-"+b.index).each(function(){Ne(this,b,b.index)}))}).call(mf.behavior.drag().origin(Object).on("drag",function(){Oe(mf.mouse(this))}).on("dragstart",function(){Pe(mf.mouse(this))}).on("dragend",function(){Qe()})).call(Di).on("dblclick.zoom",null)}function Ne(a,b,c){var d,e=mf.select(a),g=e.classed(f.SELECTED),h=!1;"circle"===a.nodeName?(h=je(a,1.5*Bh),d=te):"path"===a.nodeName&&(h=ke(a),d=we),(wg||h)&&(vg&&xg(b)&&(yg||Gi.selectAll("."+f.shapes+(wg?gd(b.id):"")).selectAll("."+f.shape).each(function(a,b){var c=mf.select(this);c.classed(f.SELECTED)&&d(!1,c.classed(f.SELECTED,!1),a,b)}),e.classed(f.SELECTED,!g),d(!g,e,b,c)),zg(b,a))}function Oe(a){var b,c,d,e,g,h,i,j;Yd(nf.data.targets)||vg&&(!uf||Di.altDomain)&&yg&&(b=ei[0],c=ei[1],d=a[0],e=a[1],g=Math.min(b,d),h=Math.max(b,d),i=wg?Af.top:Math.min(c,e),j=wg?Ff:Math.max(c,e),Gi.select("."+f.dragarea).attr("x",g).attr("y",i).attr("width",h-g).attr("height",j-i),Gi.selectAll("."+f.shapes).selectAll("."+f.shape).filter(function(a){return xg(a)}).each(function(a,b){var c,d,e,k,l,m,n=mf.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=te,q=c>g&&h>c&&d>i&&j>d):"path"===this.nodeName&&(m=Dd(this),c=m.x,d=m.y,e=m.width,k=m.height,l=we,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 Pe(a){Yd(nf.data.targets)||vg&&(ei=a,Gi.select("."+f.chart).append("rect").attr("class",f.dragarea).style("opacity",.1),fi=!0,Eg())}functi
}),gf(xc(nf.data.targets),{withTransition:!0}),kg):kg},nf.x=function(a){return arguments.length&&(mc(nf.data.targets,a),Re({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),nf.data.xs},nf.xs=function(a){return arguments.length&&(nc(nf.data.targets,a),Re({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),nf.data.xs},nf.axis.labels=function(a){arguments.length&&(Object.keys(a).forEach(function(b){bb(b,a[b])}),Ab())},nf.axis.max=function(a){arguments.length&&("object"==typeof a?(b(a.y)&&(_g=+a.y),b(a.y2)&&(ih=+a.y2)):_g=ih=+a,Re())},nf.axis.min=function(a){arguments.length&&("object"==typeof a?(b(a.y)&&(ah=+a.y),b(a.y2)&&(jh=+a.y2)):ah=jh=+a,Re())},nf.axis.range=function(a){arguments.length&&("undefined"!=typeof a.max&&nf.axis.max(a.max),"undefined"!=typeof a.min&&nf.axis.min(a.min))},nf.legend.show=function(a){Jg||(Jg=!0,Ii.style("visibility","visible")),ef(yc(a)),Re({withTransitionForHorizontalAxis:!1})},nf.legend.hide=function(a){Jg&&me(a)&&(Jg=!1,Ii.style("visibility","hidden")),ff(yc(a)),Re({withTransitionForHorizontalAxis:!1})},nf.resize=function(a){qf=a?a.width:null,rf=a?a.height:null,We({withLegend:!0,withTransition:!1,withTransitionForTransform:!1})},nf.destroy=function(){nf.data.targets=void 0,nf.data.xs={},Ki.html(""),a.onresize=null},"url"in e.data)mf.csv(e.data.url,function(a,b){Ke(b)});else if("rows"in e.data)Ke(pc(e.data.rows));else{if(!("columns"in e.data))throw Error("url or rows or columns is required.");Ke(qc(e.data.columns))}return nf},"function"==typeof a.define&&a.define.amd?a.define("c3",["d3"],e):a.c3=e}(window);