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.

2 lines
60 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={},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",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",dragarea:"c3-dragarea",EXPANDED:"_expanded_",SELECTED:"_selected_",INCLUDED:"_included_"};e.version="0.1.24",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)return b;g=f}return g}function i(a){return"url("+document.URL.split("#")[0]+"#"+a+")"}function j(){_h.attr("transform",Mh.main),_h.select("."+f.axisX).attr("transform",Mh.x),_h.select("."+f.axisY).attr("transform",Mh.y),_h.select("."+f.axisY2).attr("transform",Mh.y2),_h.select("."+f.chartArcs).attr("transform",Mh.arc)}function k(){hg&&(ai.attr("transform",Mh.context),ai.select("."+f.axisX).attr("transform",Mh.subx))}function l(a){var b=a!==!1?250:0;kg&&bi.transition().duration(b).attr("transform",Mh.legend)}function m(a){j(a),k(a),l(a)}function n(){hf=q(),jf=r(),kf=P(),lf=O(),af={top:og?v("y2"):Th,right:t(),bottom:v(og?"y":"x")+(og?0:ig)+(Nh?0:kf),left:(og?ig+Sh:0)+s()},df=hf-af.left-af.right,ff=jf-af.top-af.bottom,0>df&&(df=0),0>ff&&(ff=0),bf={top:og?af.top:jf-ig-(Nh?0:kf),right:0/0,bottom:20+(Nh?0:kf),left:og?Rh:af.left},ef=og?af.left-Rh-Sh:df,gf=og?ff:jf-bf.top-bf.bottom,0>ef&&(ef=0),0>gf&&(gf=0),cf={top:Nh?0:jf-kf,right:0/0,bottom:0,left:Nh?hf-lf:0},o(),Nh&&Ed(Pe.data.targets)&&(cf.left=df/2+nf)}function o(){nf=ff/2,mf=.95*nf,of=Dd(Pe.data.targets)?.6*mf:0}function p(){var a=og?f.axisX:f.axisY,b=Oe.select("."+a).node(),c=b?b.getBoundingClientRect():{right:0},d=Oe.select(Re).node().getBoundingClientRect(),e=c.right-d.left-s();return e>0?e:0}function q(){return Se?Se:w()}function r(){var a=Te?Te:x();return a>0?a:320}function s(){return Ed(Pe.data.targets)?0:Ue?Ue:og||!zg||Eg?1:u("y")}function t(){var a=1;return Ed(Pe.data.targets)?0:Ve?Ve:Nh?lf+(Ig&&!og?u("y2"):a):Ig?Ng||og?a:u("y2"):a}function u(a){var b=eb(a);return b.isInner?20+xb(a):40+xb(a)}function v(a){return"y"!==a||zg?"y2"!==a||Ig?(eb(a).isInner?30:40)+("y2"===a?-10:0):Th:kg&&!Nh?10:1}function w(){return+Oe.select(Re).style("width").replace("px","")}function x(){return+Oe.select(Re).style("height").replace("px","")}function y(a){return a?-5:-(af.left-1)}function z(a){return a?-20:-1}function A(){return y(!og)}function B(){return z(!og)}function C(){return y(og)}function D(){return z(og)}function E(a){return a?df+2+4:af.left+20}function F(a){return a?80:ff+2}function G(){return E(!og)}function H(){return F(!og)}function I(){return E(og)}function J(){return F(og)}function K(){var a=og?ff:df,b=qc(),c=Sb()*(Ad(Pe.data.targets)?(b-(zh?.25:1))/b:.98);return b>1?a*c/(b-1):a}function L(a){Oh=a}function M(a){Ph=a}function N(a){Qh=a}function O(){return kg?Nh?Ph*(Oh+1)
})))}).on("click",function(a,b){return Ed(Pe.data.targets)?void 0:Dh?void(Dh=!1):void _h.selectAll("."+f.shape+"-"+b).each(function(a){se(this,a,b)})}).call(Oe.behavior.drag().origin(Object).on("drag",function(){te(Oe.mouse(this))}).on("dragstart",function(){ue(Oe.mouse(this))}).on("dragend",function(){ve()})).call(Yh).on("dblclick.zoom",null)}function re(a){a.append("rect").attr("x",0).attr("y",0).attr("width",df).attr("height",ff).attr("class",f.eventRect).on("mouseout",function(){Ed(Pe.data.targets)||(qd(),od(),fe())}).on("mousemove",function(){var a,b,c;Ch||Ed(Pe.data.targets)||(a=Oe.mouse(this),b=hd(Pe.data.targets,a),c=[gc(b)],nd(c,a),$g&&(fe(),ee(b.index,b.id)),pd(c),Wd(b,a)<100?(Zh.select("."+f.eventRect).style("cursor","pointer"),Eh||(bg(b),Eh=!0)):(Zh.select("."+f.eventRect).style("cursor",null),cg(b),Eh=!1))}).on("click",function(){var a,b;Ed(Pe.data.targets)||(a=Oe.mouse(this),b=hd(Pe.data.targets,a),Wd(b,a)<100&&_h.select("."+f.circles+"-"+Sc(b.id)).select("."+f.circle+"-"+b.index).each(function(){se(this,b,b.index)}))}).call(Oe.behavior.drag().origin(Object).on("drag",function(){te(Oe.mouse(this))}).on("dragstart",function(){ue(Oe.mouse(this))}).on("dragend",function(){ve()})).call(Yh).on("dblclick.zoom",null)}function se(a,b,c){var d,e=Oe.select(a),g=e.classed(f.SELECTED),h=!1;"circle"===a.nodeName?(h=Rd(a,1.5*ah),d=$d):"path"===a.nodeName&&(h=Sd(a),d=be),(Zf||h)&&(Yf&&$f(b)&&(_f||_h.selectAll("."+f.shapes+(Zf?Sc(b.id):"")).selectAll("."+f.shape).each(function(a,b){var c=Oe.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)),ag(b,a))}function te(a){var b,c,d,e,g,h,i,j;Ed(Pe.data.targets)||Yf&&(!We||Yh.altDomain)&&_f&&(b=Bh[0],c=Bh[1],d=a[0],e=a[1],g=Math.min(b,d),h=Math.max(b,d),i=Zf?af.top:Math.min(c,e),j=Zf?ff:Math.max(c,e),_h.select("."+f.dragarea).attr("x",g).attr("y",i).attr("width",h-g).attr("height",j-i),_h.selectAll("."+f.shapes).selectAll("."+f.shape).filter(function(a){return $f(a)}).each(function(a,b){var c,d,e,k,l,m,n=Oe.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=$d,q=c>g&&h>c&&d>i&&j>d):"path"===this.nodeName&&(m=jd(this),c=m.x,d=m.y,e=m.width,k=m.height,l=be,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 ue(a){Ed(Pe.data.targets)||Yf&&(Bh=a,_h.select("."+f.chart).append("rect").attr("class",f.dragarea).style("opacity",.1),Ch=!0,fg())}function ve(){Ed(Pe.data.targets)||Yf&&(_h.select("."+f.dragarea).transition().duration(100).style("opacity",0).remove(),_h.selectAll("."+f.shape).classed(f.INCLUDED,!1),Ch=!1,gg())}function we(a){var c,e,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I=td(),J=Ed(Pe.data.targets),L=wc(Pe.data.targets);if(0!==L.length){if(a=d(a)?a:{},u=d(a.withY)?a.withY:!0,v=d(a.withSubchart)?a.withSubchart:!0,w=d(a.withTransition)?a.withTransition:!0,x=d(a.withTransform)?a.withTransform:!1,y=d(a.withUpdateXDomain)?a.withUpdateXDomain:!1,z=d(a.withUpdateOrgXDomain)?a.withUpdateOrgXDomain:!1,A=d(a.withLegend)?a.withLegend:!1,F=w?_e:0,G=d(a.durationForExit)?a.durationForExit:F,H=d(a.durationForAxis)?a.durationForAxis:F,A&&kg&&Ke(Pe.data.targets,a),z&&(Bf.domain(Oe.extent(Wb(L))),ei=Bf.domain(),We&&Yh.scale(Bf).updateScaleExtent(),Ef.domain(Bf.domain()),Uh.scale(Ef)),y&&(Bf.domain(Uh.empty()?ei:Uh.extent()),We&&Yh.scale(Bf).updateScaleExtent()),Cf.domain(Rb(L,"y")),Df.domain(Rb(L,"y2")),_h.select("."+f.axisX).style("opacity",J?0:1).transition().duration(H).call(Hf),_h.select("."+f.axisY).style("opacity",J?0:1).transition().duration(H).call(If),_h.select("."+f.axisY2).style("opacity",J?0:1).transition().duration(H).call(Jf),B=je(I),D=ke(I,!0),E=ke(I,!1),_h.select("."+f.axisX+" ."+f.axisXLabel).attr("x",lb),_h.select("."+f.axisY+" ."+f.axisYLabel).attr("x",mb).attr("dy",sb),_h.select("."+f.axisY2+" ."+f.axisY2Label).attr("x",nb).attr("dy",tb),Ff.domain(Cf.domain()),Gf.domain(Df.domain()),ci.style("display","none"),_h.select("line."+f.xgridFocus).style("visibility","hidden