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
66 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.31"},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;Si.attr("transform",Di.main),Si.select("."+f.axisX).transition().duration(b).attr("transform",Di.x),Si.select("."+f.axisY).transition().duration(b).attr("transform",Di.y),Si.select("."+f.axisY2).attr("transform",Di.y2),Si.select("."+f.chartArcs).attr("transform",Di.arc)}function k(){Jg&&(Ti.attr("transform",Di.context),Ti.select("."+f.axisX).attr("transform",Di.subx))}function l(a){var b=a!==!1?250:0;Ui.transition().duration(b).attr("transform",Di.legend)}function m(a){j(a),k(a),l(a)}function n(){var a=Q(),b=P();Kf=r(),Lf=s(),Df={top:Sg?w("y2"):Ki,right:u(),bottom:w(Sg?"y":"x")+(Sg?0:Kg)+(Ei?0:a),left:(Sg?Kg+Ji:0)+t()},Gf=Kf-Df.left-Df.right,If=Lf-Df.top-Df.bottom,0>Gf&&(Gf=0),0>If&&(If=0),Ef={top:Sg?Df.top:Lf-Kg-(Ei?0:a),right:0/0,bottom:20+(Ei?0:a),left:Sg?Ii:Df.left},Hf=Sg?Df.left-Ii-Ji:Gf,Jf=Sg?If:Lf-Ef.top-Ef.bottom,0>Hf&&(Hf=0),0>Jf&&(Jf=0),Ff={top:Ei?0:Lf-a,right:0/0,bottom:0,left:Ei?Kf-b:0},p(),Ei&&Yd(of.data.targets)&&(Ff.left=Gf/2+Nf)}function o(){Si.select("line."+f.xgridFocus).attr("x1",Sg?0:-10).attr("x2",Sg?Gf:-10).attr("y1",Sg?-10:Df.top).attr("y2",Sg?-10:If)}function p(){Nf=If/2,Mf=.95*Nf,Of=Xd(of.data.targets)?.6*Mf:0}function q(){var a=Sg?f.axisX:f.axisY,b=nf.select("."+a).node(),c=b?b.getBoundingClientRect():{right:0},d=nf.select(qf).node().getBoundingClientRect(),e=c.right-d.left-t();return e>0?e:0}function r(){return rf?rf:x()}function s(){var a=sf?sf:y();return a>0?a:320}function t(){return Yd(of.data.targets)?0:tf?tf:Sg||!gh||lh?1:v("y")}function u(){var a=1;return Yd(of.data.targets)?0:uf?uf:Ei?P()+(ph&&!Sg?v("y2"):a):ph?uh||Sg?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||gh?"y2"!==a||ph?(gb(a).isInner?30:40)+("y2"===a?-10:0):Ki:Mg&&!Ei?10:1}function x(){return+nf.select(qf).style("width").replace("px","")}function y(){return+nf.select(qf).style("height").replace("px","")}function z(a){return a?-5:-(Df.left-1)}function A(a){return a?-20:-1}function B(){return z(!Sg)}function C(){return A(!Sg)}function D(){return z(Sg)}function E(){return A(Sg)}function F(a){return a?Gf+2+4:Df.left+20}functio
}Vi.html(ci(of.data.targets.map(function(a){return lc(a.values[ei])}),$(),rd,ui)),Vi.style("top",fi.top).style("left",fi.left).style("display","block")}null==a.onresize&&(a.onresize=Ve()),a.onresize.add&&(a.onresize.add(Af),a.onresize.add(function(){Xe({withLegend:!0,withTransition:!1,withTransitionForTransform:!1})}),a.onresize.add(Bf))}function Me(a){a.append("rect").attr("class",ad).style("cursor",yg&&zg?"pointer":null).on("mouseover",function(a,b){if(!qi&&!Yd(of.data.targets)){var c,d,e=of.data.targets.map(function(a){return lc(a.values[b])});if(Object.keys(ng).length>0){d=[];for(var g in ng)for(c=0;c<e.length;c++)if(e[c].id===g){d.push(e[c]),e.shift(c);break}e=d.concat(e)}Hh&&Ae(b),De(b),Si.selectAll("."+f.shape+"-"+b).each(function(a){Dg(a)})}}).on("mouseout",function(a,b){Yd(of.data.targets)||(Kd(),Id(),Be(b),Ee(),Si.selectAll("."+f.shape+"-"+b).each(function(a){Eg(a)}))}).on("mousemove",function(a,b){var c;qi||Yd(of.data.targets)||(c=Dc(of.data.targets).map(function(a){return lc(a.values[b])}),Hd(c,nf.mouse(this)),Jd(c),yg&&(zg||Si.selectAll("."+f.shape+"-"+b).filter(function(a){return Ag(a)}).each(function(){var a=nf.select(this).classed(f.EXPANDED,!0);"circle"===this.nodeName&&a.attr("r",Ih),Qi.select("."+f.eventRect+"-"+b).style("cursor",null)}).filter(function(){return"circle"===this.nodeName?ke(this,Jh):"path"===this.nodeName?le(this):void 0}).each(function(){var a=nf.select(this);a.classed(f.EXPANDED)||(a.classed(f.EXPANDED,!0),"circle"===this.nodeName&&a.attr("r",Jh)),Qi.select("."+f.eventRect+"-"+b).style("cursor","pointer")})))}).on("click",function(a,b){return Yd(of.data.targets)?void 0:ri?void(ri=!1):void Si.selectAll("."+f.shape+"-"+b).each(function(a){Oe(this,a,b)})}).call(nf.behavior.drag().origin(Object).on("drag",function(){Pe(nf.mouse(this))}).on("dragstart",function(){Qe(nf.mouse(this))}).on("dragend",function(){Re()})).call(Pi).on("dblclick.zoom",null)}function Ne(a){a.append("rect").attr("x",0).attr("y",0).attr("width",Gf).attr("height",If).attr("class",f.eventRect).on("mouseout",function(){Yd(of.data.targets)||(Kd(),Id(),Be())}).on("mousemove",function(){var a,b,c,d;qi||Yd(of.data.targets)||(a=nf.mouse(this),b=Ad(of.data.targets,a),c=Cd(of.data.targets,b.x),d=c.map(function(a){return lc(a)}),Hd(d,a),Hh&&(Be(),Ae(b.index,b.id)),Jd(d),qe(b,a)<100?(Qi.select("."+f.eventRect).style("cursor","pointer"),si||(Dg(b),si=!0)):(Qi.select("."+f.eventRect).style("cursor",null),Eg(b),si=!1))}).on("click",function(){var a,b;Yd(of.data.targets)||(a=nf.mouse(this),b=Ad(of.data.targets,a),qe(b,a)<100&&Si.select("."+f.circles+"-"+gd(b.id)).select("."+f.circle+"-"+b.index).each(function(){Oe(this,b,b.index)}))}).call(nf.behavior.drag().origin(Object).on("drag",function(){Pe(nf.mouse(this))}).on("dragstart",function(){Qe(nf.mouse(this))}).on("dragend",function(){Re()})).call(Pi).on("dblclick.zoom",null)}function Oe(a,b,c){var d,e=nf.select(a),g=e.classed(f.SELECTED),h=!1;"circle"===a.nodeName?(h=ke(a,1.5*Jh),d=ue):"path"===a.nodeName&&(h=le(a),d=xe),(zg||h)&&(yg&&Ag(b)&&(Bg||Si.selectAll("."+f.shapes+(zg?gd(b.id):"")).selectAll("."+f.shape).each(function(a,b){var c=nf.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)),Cg(b,a))}function Pe(a){var b,c,d,e,g,h,i,j;Yd(of.data.targets)||yg&&(!vf||Pi.altDomain)&&Bg&&(b=pi[0],c=pi[1],d=a[0],e=a[1],g=Math.min(b,d),h=Math.max(b,d),i=zg?Df.top:Math.min(c,e),j=zg?If:Math.max(c,e),Si.select("."+f.dragarea).attr("x",g).attr("y",i).attr("width",h-g).attr("height",j-i),Si.selectAll("."+f.shapes).selectAll("."+f.shape).filter(function(a){return Ag(a)}).each(function(a,b){var c,d,e,k,l,m,n=nf.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=ue,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=xe,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 Qe(a){Yd(of.data.targets)||yg&&(pi=a,Si.select("."+f.chart).append("rect").attr("class",f.dragarea
},of.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;Qi.selectAll("."+a).transition().duration(d).style("fill-opacity",0).remove(),$h=$h.filter(function(b){return b.classes.indexOf(a)<0})}),$h},of.data.get=function(a){var b=of.data.getAsTarget(a);return d(b)?b.values.map(function(a){return a.value}):void 0},of.data.getAsTarget=function(a){var b=Ac(function(b){return b.id===a});return b.length>0?b[0]:void 0},of.data.names=function(a){return arguments.length?(Object.keys(a).forEach(function(b){ng[b]=a[b]}),hf(xc(of.data.targets),{withTransition:!0}),ng):ng},of.x=function(a){return arguments.length&&(mc(of.data.targets,a),Se({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),of.data.xs},of.xs=function(a){return arguments.length&&(nc(of.data.targets,a),Se({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),of.data.xs},of.axis.labels=function(a){arguments.length&&(Object.keys(a).forEach(function(b){bb(b,a[b])}),Ab())},of.axis.max=function(a){arguments.length&&("object"==typeof a?(b(a.y)&&(hh=+a.y),b(a.y2)&&(qh=+a.y2)):hh=qh=+a,Se())},of.axis.min=function(a){arguments.length&&("object"==typeof a?(b(a.y)&&(ih=+a.y),b(a.y2)&&(rh=+a.y2)):ih=rh=+a,Se())},of.axis.range=function(a){arguments.length&&("undefined"!=typeof a.max&&of.axis.max(a.max),"undefined"!=typeof a.min&&of.axis.min(a.min))},of.legend.show=function(a){Mg||(Mg=!0,Ui.style("visibility","visible")),ff(yc(a)),Se({withTransitionForHorizontalAxis:!1})},of.legend.hide=function(a){Mg&&ne(a)&&(Mg=!1,Ui.style("visibility","hidden")),gf(yc(a)),Se({withTransitionForHorizontalAxis:!1})},of.resize=function(a){rf=a?a.width:null,sf=a?a.height:null,Xe({withLegend:!0,withTransition:!1,withTransitionForTransform:!1})},of.destroy=function(){of.data.targets=void 0,of.data.xs={},Wi.html(""),a.onresize=null},"url"in e.data)nf.xhr(e.data.url,function(a,b){var c,d=nf.csv.parseRows(b.response);1===d.length?(c=[{}],d[0].forEach(function(a){c[0][a]=null})):c=nf.csv.parse(b.response),Le(c)});else if("rows"in e.data)Le(pc(e.data.rows));else{if(!("columns"in e.data))throw Error("url or rows or columns is required.");Le(qc(e.data.columns))}return of},"function"==typeof a.define&&a.define.amd?a.define("c3",["d3"],e):a.c3=e}(window);